- December 14, 2013
- Posted by: Forex Wiki Team
- Category: Expert Advisor
|Author:||WhooDoo22 (2012.09.29 09:59)|
MMA_Breakout_strategy_Volume I – coded by WhooDoo22 (Multi Moving Average Breakout Strategy Volume I).
Currency pair: EUR/USD.
(Be sure to run EA from years 2003.01.01-2012.06.01 and be sure to run strategy in strategy tester using “Open prices only” instead of “Every tick” to speed up testing)
Strategy is based on the equation resistance over support (R/S) and the theory that the market moves in trends (containing smaller ranges) or consolidated horizontal movement (containing smaller ranges).
Capture profits of trends and ranges.
1. To capture small range profits, the EA uses small moving averages like an EMA period of 5 and an SMMA period of 25.
2. To capture large trend profits, the EA uses larger moving averages such as an SMMA period of 50 and an SMMA period of 200.
Strategy Open Signal:
Open buy/sell order of 0.04 lots when SMMA period of 1 crosses above/below SMMA period of 200.
Strategy Close Signal:
Close buy/sell orders of 0.01 lots when SMMA period of 1 crosses back below/above slower moving averages of EMA 5, SMMA 25, SMMA 50, and SMMA 200.
(partial order close function included )
1. Big Breakouts = Good signal for closing big profits for smaller moving averages of EMA 5 and SMMA 25.
2. Strong Trends = Good signal for closing big profits for larger moving averages of SMMA 50 and SMMA 200.
Decrease Weakness to Increase Strength:
If you choose to improve this strategy and use it to further improve your MQL4 education, you can incorporate the following two updates.
1. Use an icustom indicator which draws multiple moving averages that adjust its moving averages to a certain period of bars in history ago (example: Multiple Moving Averages icustom indicator will count the last sixty bars and write its moving averages to “spear” through the ranges.)
2. Adjust the order close functions to close orders more efficiently. (A. Sell order example. Sometimes when the SMMA 1 crosses below SMMA 200, the slower moving averages of 5,25, and 50 are still above the 200 moving average. The problem is this: If the SMMA 1 crosses back above the SMMA 200, only 0.01 lots are closed. This leaves 3/4ths of the orders open. This should be fixed so that all orders (0.04 lots) are closed when SMMA 1 crosses back above SMMA 200. The reason is to minimize losses. If orders 0.03 are left open, this means more loss (with a small possibility of profit). B. Incorporate a consolidated price movement filter to remove “Bad signals” in consolidated price movements. (Consider coding the EA to let it “wait” for a breakout during consolidated price movements, because breakouts are this strategy’s strength )
Me and the MQL4 community.
Going to add it to this Best Forex Robot Competition on a demo account.
01.10.2013 03:45 forexfbi
This one seems to be quite popular here, will have to give it an in depth look. I’ll see if I can get it added on this EA comparison here:
11.06.2013 10:24 Beakon
I think it’ll be better and profitable if more indicators are added in the EA’s ordersend() conditions. Whether it’s better the ordersend time is limited in certain time period, i.e., from European at 10:36 am to American 3:36 pm, in which the market is more active and error trading signals are less.
Anyway, your code is very good for new coders/traders. Wish to discuss with you about the Forex market and EAs. Expecting…….
20.01.2013 14:37 WilliamWang
Hello WhooDoo22, thanks for your share. I’m a fresh bird in coding EAs. Although my C programing experience helps coding MQL4, it’s a big difficulty for me. I gained very substantially froom your code I. And expect your next code “II” and discuss with you.
20.01.2013 13:47 WilliamWang
I thought it would be helpful for new coders (and experienced coders) to post an updated version of MMA_Breakout_strategy_Volume I, so novice/experienced coders alike could have a chance of understanding the two important updates required for this EA (volume I) to run smoother and more efficiently. This version does not include money management or market filtration and is still considered volume I. (I am still deciding how to implement both money management and market filtration features into volume I to ultimately evolve volume I to volume II. I will share a portion of my thoughts of accomplishing both tasks of MM (money management) and MF (market filtration). MM: As you well know, volume I uses a single order and partially closes its order as the moving averages cross. This goal for MM is to increase the lot size as the account balance grows (example: account balance increases $1,000, code block will adjust the current lot size to double the current lot size. This code block will also decrease the lot size to half the current lot size if the account balance loses $1,000. This is the current objective for MM. As for MF: I am thoroughly considering all options before opening this door to my inexperienced coding territory. I can think of multiple ways to accomplish this task. The question remains for me, which option should I choose? I have begun coding versions of volume II with MF feature to become familiar with new and different techniques. Repetition of trial and error will guide me to the completion of this project. Be sure to run from 1999-2012.10 on M15 time frame EURUSD to verify most recent back test posted of volume I (it is also considered partly volume II). On a side note, I am blown away volume I has been downloaded 10,000 times within two or so months! WOW! 🙂 I am so glad my work has proven itself valuable to coders/traders. Thank you. – WhooDoo22. MMA_Breakout_strategy_Volume I (updated) download link
11.12.2012 05:34 WhooDoo22
Thanks for this good EA, but can be only run on demo account because actually is too risky for real.
Need to improve…
07.11.2012 21:14 aide-forex.fr
Hello MQL4 community,
DO NOT RUN MMA_Breakout_strategy Volume I – coded by WhooDoo22 on a LIVE account!
This is because I did not filter out consolidated market conditions in the signal parameters of this EA. If this EA is run on a live account during consolidated market conditions false signals will gobble up an account balance very quickly. The purpose I chose to share this EA is to educate coders and traders. If all goes as planned, Volume II will be able to run on a live account no problem and will be added to the code base if “higher-ups” allow it to be added to the code base. Study this EA to your benefit if you wish. The choice is yours.
A significant coding mistake to be corrected in “MMA_Breakout_strategy_Volume_I – coded by WhooDoo22” is contained within the “OrderClose()” code blocks. Replace “Ask” and “Bid” prices with the opposite market price. Example: If “Ask” is contained within the “OrderClose()” code block, replace “Ask” with “Bid”. If “Bid” is contained within the “OrderClose()” code block, replace “Bid” with “Ask”.
1. Replace the order close functions containing decisions of closing orders by iMAs to a shift of 1 ONLY and erase all order closing iMas shift values of zero aka .
2. Erase “if order profit >= 0” and “if order profit < 0”. Just designate iMAs to a shift of 1 ONLY aka .
Following steps 1. and 2. will make your tests much more profitable. You can even try using it on other currency pairs like GBP/USD or others to visualize possible “iMA 200 trend patterns” that can be profited if filtered using
“market filtration” (“market filtration” will be touched up on below).
Helpful tips to coders searching to write a “more profitable” expert advisor:
1. Decide upon a currency pair with the lowest spread. EUR/USD is an example.
2. Run tests in mt4 strategy tester on your designated currency pair with low spread.
3. Hunt for market patterns. FOREX EUR/USD pair has three market patterns: 1. Trends, 2. Ranges within trends or 3. Ranges within consolidated aka consolidated ranges.
4. Decide what pattern you will be profiting from first. When you decide, you can use strictly price arrays (example: 30 bars) OR an indicator (example: iMAs) that takes advantage of the decided pattern.
5. If you are using price arrays OR indicators, realize that both run on designated periods. You cannot profit from every market move. You must decide which move to profit from AND be sure that the move is big enough to carry your order from point A. to point B. (low spread helps because this means that your order does not need to travel as far from point A. to point B. to move into profit. KEY factor).
READ: All Currency pairs are based on the physics of SUPPORT AND RESISTANCE. Euro VS. Dollar. Which currency is stronger? AND is the strength of one currency so much stronger than the opposing currency that an opportunity to send an order presents itself? Once this is understood, you will understand that you must look for big enough moves of support OR resistance that will carry your order from point A. to point B. What now becomes most important is to realize that if a big move of support or resistance is made, understand that the move can continue up with the same force OR reverse with the same force. The key is to be ready for a move of either up OR down. “For every action, there is an equal and opposite reaction” – Sir Isaac Newton (physicist).
6. Here is the fun part 😉
Once you understand the above statements you understand that your indicator or allotted price array works well under specific market conditions that work well under that period ALONE.
What you might not understand is, “How do I filter market conditions that work well under the designated period?”
An answer to this question is to save the price values where your order would have closed IF an order was sent. Add or subtract these values from the price value of where you would send an order. Once these price values go positive, subtract the spread value from these calculations. If the result is still positive, it is time to start sending orders. Remember, “Birds of a feather flock together.” This statement pertains to market patterns 😉
I would advise the use of partial order closing to maximize return of potential market movement. (You never know which direction the currency pair will go OR how far it will travel, BUT ;), you can be ready for what the market could do). Remember to maximize profit and minimize risk. KEY.
Once a buy order loses, DO NOT open any more buy orders UNLESS the next sell order goes into profit. If the sell order DOES NOT go into profit, it is time to wait until price values go positive once again.
In essence, the expert advisor is waiting for appropriate market conditions to apply the strategy of your choosing. The expert advisor chooses these appropriate market conditions if an “artificial order” would have profited from the condition assigned by your price array or indicator. The EA’s strategy must use an allotted period of the market to scan. If the EA scans a profitable market condition, it should wait for a signal of a similar market condition in the future. The strategy should use history and current price. That should pretty much cover it.
A back-test snapshot using open prices only was done for MMA_Breakout_strategy_Volume II from date 1999-2012.10 (eurusd, m15). this test was performed without market filtration or money management.
Thats all for now, but if I have any information of any value regarding MMA_Breakout_strategy_Volume I or II, I will post below. Thank you for your interest in my EA.