Triple Moving Average EA
This Expert advisor (EA) places trades when 3 moving averages (MA) are in sequence and at a certain distance from each other. It adopts a not very well known strategy used by some institutional traders. It involves the MAs 10, 20 and 30. The strategy works best on the H4 time frame but can also produce good results on H1 and D1 on some pairs. Works best with a trailing stop.
The EA can also be used in a more universal way by using other MAs than the ones which are intended for the strategy.
The behavior of the EA can be explained in the following steps (please also see separate screenshot for visualization):
- Look for a trade when all 3 MAs are in sequence and the minimum distance between them has been reached.
- Exit when trailing stop or any other condition (described below) has been hit.
- Spread and slippage filter.
- Moving average trend filter.
- Possibility to select between adding a fixed lot or let the system set the lot size according to risk percentage.
- Possibility to trade in a reverse way (buy when sell, sell when buy) by setting a very wide distance between the MAs which could indicate a reversal.
The EA is NFA FIFO compliant and supports ECN accounts.
- Time frame to operate on - Default is H4. This is intended to work as a protection so that no unwanted trades will be taken in case the time frame on the chart is manually changed.
- Send alert instead of opening trade - When set to 'true' an alert will be sent instead of opening a trade.
- Reverse system (sell when buy, buy when sell) - 'true' or 'false'.
- ECN account - 'true' or 'false'.
- Open buy/sell order - 'true' or 'false'.
- Trade only between given times (computer time) - Hour filter for opening trades.
- Trade from/to time - Hour from/to.
- Maximum allowed slippage in points - Please note that not all brokers/account types support slippage control.
- Maximum allowed spread in points (0 = not used) - Can be set to avoid taking trades with high spread directly after midnight market opening or at news releases. Could be used if you have variable spreads.
- Allow pin bar on previous candle - 'true' or 'false'. Trades will not be taken if previous candle is a pin bar where the tail is >= 60% of the candle size.
- Risk in percentage (>0 = auto lot) - If set to 0 the Manual lots value below will be used. Sets the risk for the trade based on Account Free Margin. It will implement true risk only if combined with a stop loss.
- Point value for risk percentage - Default is 1. Is normally not changed. Only in some rare cases where the broker has unconventional tick values for CFDs. A setting of 0.1 could then be used.
- Manual lots - Will be used if Risk above is set to 0.
- Type of stop-loss/exit - Combo box with the following selections:
- MA1/MA2 cross (default) - The position will be closed automatically when the first MA has crossed the second at candle close.
- MA1/MA2 distance < min. distance - Will speed up the closing (stop loss) of the order. Will not wait for the first MA to cross the second. Instead it will close the order when the distance between them is less than the minimum distance. Has been proven to be effective on some pairs.
- MA1/MA2 distance < than MA2/MA3 distance
- Which of the above occurs first
- Fixed stop-loss
- Take profit method - Combo box with the following selections:
- Trailing stop
- Risk/Reward (based on SL)
- Fixed take profit
- Trailing stop - Will trail the stop loss constantly with the distance you have set as soon as the trade is in profit. If the Trailing step parameter is set to 0 then the trailing stop will be adjusted each 3rd second.
- Trailing step - The trailing stop will be adjusted every time the price has moved the amount of points you have set here.
- Risk/Reward ratio: You need to set the “Take profit method” parameter to Risk/Reward in order for this value to have any effect. You need also to set “Type of stop-loss” to Fixed and a fixed stop loss value. A stop loss value of 200 points and a R/R ratio of 1.5 would mean that the take profit level would be automatically set to 300 points when an order is opened.
- Break-even (0 = disabled) - Break-even level.
- Break-even trigger - Price has to reach this level before the stop loss will be moved to break even.
- Use trend moving average - With this option enabled trades will only be placed when the signal is above/below the MA.
- MA period
- MA method
- MA time frame
- Signal moving average periods - Default values are 10, 20, 30.
- Signal moving average shifts - Default values are 0. You could for instance simulate the Alligator oscillator by using other values for Period and Shift.
- Signal MA method - default is Exponential.
- MA price type - Valid for both trend and signal MA.
- Min. distance in points between signal MA:s - For the H4 timeframe all values between 30 and 150 points can be used (according to my back testing).
- ALERTS (if alert instead of trade is enabled) - Set to 'true' for each alert type you would like to activate.
- Magic number
- Order comment
- added possibility for trailing step
- added combo boxes for stop-loss (exit) and take profit methods
- added parameter checkup when loading the EA
- added possibility to disable comments on chart
- added possibility for exit if the distance between the first and second MA is less than the distance between the second and third MA