Expert Advisors for MT5 - Examples E-mail

 

Some of these examples are based on the 20 Trade Signals in MQL5 Article published by Metaquotes at http://www.mql5.com/en/articles/130 (Copyright Metaquotes)

Please note that these Expert Advisors were created for educational purposes and do not constitute any financial advice.

 

Before using the following EAs, please take into account the following:

  • THE DOWNLOAD FILES ARE IN MOL5 FORMAT (MOLANIS 5 FORMAT - A .MOL5 FILE FOR THE EA VISUAL WIZARD). TO OBTAIN THE EA FOR MT5, DOWNLOAD THE  STRATEGY FILE - .MOL5 FILE, OPEN IT WITH THE EXPERT ADVISOR VISUAL WIZARD AND CLICK ON GENERATE MQL5 CODE.
  • The examples use a basic logic and avoid trading using the current bar to reduce false signals. In some cases it seems that the EA is missing trades but the EA is just trading as per the definitions in the TA icon that reduce the number of signals and flickering.
  • If you want to know what the EA is doing, in MetaTrader 5, go to the Toolbox window and click on the Experts tab. It shows all the logs - the expert advisor prints its logic/actions.
  • MetaTrader 5 is different than MetaTrader 4, most users will say: But in MT4 I was able to ...  Instead of trying to replicate what you did with MT4, embrace MT5 and learn it.
  • MT5 has trading concepts that are in line with the majority of trading platforms for forex.
  • MT5 has new concepts related to positions and orders that are totally different than MT4 concepts:
    • As opposed to MT4, MT5 manages one position per pair. An order becomes a deal and then a position. In MT4, two consecutive orders will be managed as two positions in the same pair. One could identify open price, and profit per order. Also one could change the take profit and stop loss per order. MT4 even allows hedging. In MT5 two consecutive orders of 0.1 for EURUSD will become a 0.2 position in EURUSD. Open price, profit, take profit and stop loss are related to the position. MT5 does not allow hedging.
  • MQL5 is different than MQL4. They are not even compatible.
  • MetaTrader 5 is a beta software so it may contains bugs.
  • Our software is a beta software since it is developed for MetaTrader 5 (which is a beta software).
  • Every time you want to change your EA inputs, detach the EA from the chart and then re attach it. We have seen some slowness in MT5 if you don’t do it that way.
  • Usually your EAs are located in C:\Program Files\MetaTrader 5\MQL5\Experts However, in certain Windows versions, MT5 will look for the EA in C:\Users\YOUR USER\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts\ D0E8209F77C8CF37AD8BF550E51FF075 is a randon name that changes on every installation. This feature is called Windows Roaming. Issues may arise because the files at C:\Program Files\MetaTrader 5\MQL5\Experts and at C:\Users\YOUR USER\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts are not synchronized. This is a windows issue out of our control. If this happens, you may have to copy the EA files manually from C:\Program Files\MetaTrader 5\MQL5\Experts to C:\Users\YOUR USER\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Experts A solution to this issue is to create the EA file in the MetaEditor and copy the code from the Expert Advisor Visual Wizard.
  • To download the examples, right click on top of the download link and then select save as (Save target as or Save link as).

0. Download all expert advisors for Metatrader 5 in a zip file

Download all EA examples for MetaTrader 5 now!

The examples are in a mol5 format. Open them with the ea visual wizard, then generate the code.
For the examples that use custom indicators, you need to put the indicators in the mt5 indicators folder. Then you need to compile the indicators.


1. Simple moving average

Download EA for MT5 now!

Widely used EA. This Expert Advisor opens a long position when the fast moving average is higher that the slow moving average and vice versa. Please note that this EA does not use any Close Long (CL) or Close Short (CS) icons. MT5 does not support hedging, so before going long all short positions are closed and vice-versa.

 

Remember, every time a trading condition is true, the EA will send an order. In this EA the maximum volume per pair is set to 0.2. Thus every time the moving average trading condition is true, a new 0.1 position will be added to the existing position until the position volume reaches 0.2. If you trade using ticks (Execution Mode = Every Tick in the EA Visual Wizard, or CompletedBars = false in MT5 EA inputs) you can see how two orders –due to two ticks received- can be executed in the same bar until 0.2 volume is reached. Change the MT5 variable MaxVolumePosition to 0.1 to restrict the volume per pair to 0.1 – this way only one order is executed given the ma trading condition.

 

When testing this EA people ask: Why do you use shift =1 in the TA icon?

Shift is used to select the bar to be used in the moving average calculation. Shift=0 means, get the ma value for the current bar; Shift=1 means, get the ma value for the previous bar. Some people prefer to use Shift=0 to get the signal as soon as it happens,  others prefer Shift=1 to get a stronger confirmation.

 

The next graph shows the difference between trading using the current (top graph - shift=0) and the previous bar (bottom graph - shift=1). Using the previous bar the signal is delayed but you get less false signals.

 

MA shift0-1

 

The following graph shows the same scenario in a choppy market. Note the difference in the number of signals

 

Moving Average - Sensible

 

You need to decide which bar to use finding your own balance between sensibility and signal speed.

 

2. Multi-Currency Simple moving average

Download EA for MT5 now!

This EA uses the same trading conditions as the Simple moving average example above but it trades two currency pairs.  Please remember, if you are not creating multi-currency EAs always use the option Current Symbol - This way your Expert Advisors will work on any currency pair. Please note that in the example, the EA uses the EURCAD and EURUSD pairs but it uses Time frame = Period_Current. So the EA, gets the time frame from the chart and uses the same time frame for both pairs.

 

When working with muti-currency EAs take into account that you attach the EA to one chart but you need to have historical bars for all the pairs in the EA. Thus before using the EA, open the charts for the pairs in the EA and verify you have enough bars. (You can close them later but leave one chart to attach the EA) Also, remember that the EA is executed every time there is a new bar (or tick) in the chart where the EA is attached. So trading every bar means trading every bar in the chart where the EA is attached. Thus trading using ticks may be better. The good thing about MetaTrader 5 is that multi-currency EAs (and multi-frame EAs) can be backtested while in MT4 this is not possible.

3. Multi-timeframe Simple moving average

Download EA for MT5 now!

This EA opens a long position when the fast moving average (timeframe 1 minute) is higher that the slow moving average (timeframe 1 minute) and the fast moving average (timeframe 5 minute) is higher that the slow moving average (timeframe 5 minute)  and vice-versa.  Thus the ma conditions are evaluated in two different timeframes for a doble confirmation. Both conditions have to be true to open/close positions.

 

This EA evaluates the trading condition on time frames Period M1 (one minute) and Period M5 (five minutes) but it takes the currency pair from the chart where the EA is attached. When creating multi-timeframe EAs attach the EA to the smallest time frame – in this case Period M1. Please remember, if you are not creating multi-timeframe EAs always use the option Period Current - This way your EA will work on any timeframe.

 

4. Multi-timeframe Advanced Simple moving average

Download EA for MT5 now!

Similar to the previous example but this EA opens a new position looking at both the 1 minute and the 5 minute timeframe; and closes it evaluating the trading condition at the 1 minute timeframe.

 

Close Long (CL) and Close short icons are used to close the position when the 1 minute chart shows a change in trend direction.


5. Moving Average Crossover

Download EA for MT5 now!

Intersection of two Moving Averages (МА): the fast one with period 8 and the slow one with period 16. If the value of the fast MA at the 2-nd bar is less than the value of the slow MA at the 1-st bar, and the value of the fast MA at the 1-st bar is greater than the value of the slow MA at the 1-st bar, it means that the fast MA crossed the slow one upwards; that is our signal to buy. The signal to sell is formed in the similar way. If the fast MA at the 2-nd bar is greater than the slow MA at the 1-st bar, and if the fast MA at 1-st bar is less than the slow MA at the 1-st bar, it means top-down crossing of the slow MA by the fast MA.

 

Please note that MA Crossovers can be defined in several ways. We use the definition from the MT5 article which reduces flickering.

 

6. Intersection of the Main and Signal Line of MACD

Download EA for MT5 now!

If the signal line crosses the main one from top downwards, it is the signal  to buy. If the signal line crosses the main one bottom-up, it is the signal to sell.

 

7. Breakthrough of the Price Channel Range

Download EA for MT5 now!

Download MQL5 Custom Indicator now!

If the price pierces the upper border of the Price Channel and the price is fixed above this border, it is the signal to buy. If the price pierces the lower border of the Price Channel and the price is fixed below this border, then it's the signal to sell. This EA uses the custom indicator Price Channel (Price Channel.mq5 by Sergey Greecie). Please Download the indicator to C:\Program Files\MetaTrader 5\MQL5\Indicators (for standards MetaTrader installations) and compile it to generate the .ex4 file.

 

This indicator has three signals (modes or buffers):
Signals are identified as:
Mode 0,High
Mode 1,Low
Mode 2,Mid
In the EA, mode 0 and mode 1 are used.

 

8. RSI indicator Overbuying/Overselling strategy

Download EA for MT5 now!

We buy, as RSI  falls lower than a certain level (30) and then rises above it. We sell, as RSI rises higher than a certain level (70) and then falls below it.

 

9. Exit from the Overbuying/Overselling Zones of CCI

Download EA for MT5 now!

We buy, as CCI  falls lower than -100 level and then rises above it. We sell, as CCI  rises above 100 level and then falls below it.

 

10. Exit from the Overbuying/Overselling Zones of Williams Percentage Range

Download EA for MT5 now!

We buy, as Williams %  falls lower than -80 level and then rises above it. We sell, as Williams % rises above -20 level and then falls below it.

 

11. Bounce from the Borders of the Bollinger Channel

Download EA for MT5 now!

If the price pierces or touches the upper border of the Bollinger band and then returns back, it is a signal to sell. If the price pierces or touches the lower border of the Bollinger band, then it is a signal to buy.

 

12. ADX Adaptive Channel Breakthrough

Download EA for MT5 now!

Download MQL5 Custom Indicator now!

Signal to buy: If the price pierces the upper border of the adaptive channel ADX and the close price is fixed above this border. (Close > upper border)
Signal to sell: If the price pierces the lower border of the Price Channel and the close price is fixed below this border. (Close < lower border)

 

This Expert Advisor uses the custom indicator ADX Adaptive Channel (AdaptiveChannelADX.mq5 by Sergey Greecie). Modes (signals) for this indicator are:
Mode 0, to get the indicator value for the upper border
Mode 1, to get the indicator value for the lower border

 

13. Bounce from the Borders of the Standard Deviation Channel

Download EA for MT5 now!

Download MQL5 Custom Indicator now!

Buy: If the price pierces or touches the lower border of the standard deviation channel and then returns back.
Sell: If the price pierces or touches the upper border of the standard deviation channel and then returns back.

 

This EA uses the custom indicator Standard Deviation Channel (StandardDeviationChannel.mq5 by Sergey Greecie). Modes (signals) for this indicator are:
Mode 0, to get the indicator value for the lower band
Mode 1, to get the indicator value for the upper band

 

14. NRTR Change of Trend

Download EA for MT5 now!

Download MQL5 Custom Indicator now!

Buy Signal: If the NRTR indicator shows a rising trend.
Sell Signal: If the NRTR indicator shows a descending trend.

 

15. Detect Change of Trend using the Adaptative Moving Average (AMA) indicator

Download EA for MT5 now!

Buy if the AMA indicator is directed upwards. Sell if the AMA indicator is directed downwards.

 

 

Quick Links