Showing posts with label EA's for MT5. Show all posts
Showing posts with label EA's for MT5. Show all posts

In Metatrader 5 Strategy Tester you can test an Expert Advisor using different currencies, but you can also automatically test a multi-currency EA without the need of switching the currencies as in MT4.

To test a single currency EA using different currencies you must select the option "All Symbols Selected in Market Watch" in the optimization types selection. You can also select the currencies you want to test in the Market Watch window. In my case, i have selected the Heiken Ashi Expert from the example EA's folder using 5 different symbols. The input parameters were standard:

Multi-Currency Strategy Testing with MetaTrader 5

Note that for each tested symbol, around 10-15MB of history will be downloaded, so if you have selected a lot of symbols it may take a while.

In the optimization results you can see which currencies have performed the best. So using the "All Symbols Selected in Market Watch" option you can automatically test an EA on many symbols, without the need to do it manually.

Multi-Currency Strategy Testing with MetaTrader 5

One of the big advantages of the new Metatrader 5 strategy tester is the option to backtest multi-currency EA's. This was not possible in MT4. The testing and optimization process of an multi-currency expert advisor is the same as with other EA's. Metatester 5 will automatically read the code for multiple-symbol testing. The optimization results ad the equity curve will combine all symbols in one result.

To demonstrate the multi-currency EA testing i have modified the GuruEX03 EA so that it will have 3 currencies. But you can always add more symbols if you want, it's very simple, just copy the code for symbol 4 from previous symbols at the comment "// add more symbols". The EA is a simple moving average crossover trading system. It will enter the market when the slow MA and fast MA are crossed. In the input parameters you can specify all the EA variables. The symbols used in this EA are EURUSD, GBPUSD and USDJPY. You can change them in the line 25-27 of the EA's source code. Download the multi-currency MA crossover EA (.mq5)

Multi-Currency Strategy Testing with MetaTrader 5
I have done a simple 96 step fast optimization and here are the results:

Multi-Currency Strategy Testing with MetaTrader 5
In the log file you can see that the testing process has used all 3 symbols:

Multi-Currency Strategy Testing with MetaTrader 5

FraMa Cross Indicator and EA (author - Paul, see his blog Paul's Forex random walk)

This indicator will show a fast and slow Fractal Moving Average (FRAMA) and places arrows at the open of each bar following an MA cross event. FRAMA is an exponential style moving average and can be a valuable technical indicator because it rapidly follows significant changes in price but becomes very flat in congestion zones so that bad whipsaw trades can be eliminated. The FRAMA is an alternative indicator to the default fractals that is included with the Metatrader 5 installation. Read more about the background of FRAMA here.

FraMa Cross for Metatrader 5

FraMa Cross for Metatrader 5

You can customize the fast and slow MA period. The EA is triggered using the indicator. Because the strategy tester is not available yet, the EA can not be tested for it's effectiveness.

Paul also wrote a useful MQH include file which converts error codes and OrderSend results to strings and a debugging file.

Go to Paul's blog and download

A new version of the CLOSEPRC Expert for Metatrader 5 was posted today. This EA can automatically close all open orders when a certain deposit percentage is reached. There is also a button for manual closing of all current positions. This EA is made by Yuraz

Close All Expert for Metatrader 5

You have to allow the EA to autotrade to work. You can input the deposit percentage in the black box with red borders ( see screenshot).

The button text and error codes of this EA are written in Russian. If you want it in English, open MetaEditor 5 ( it is part of the Metatrader 5 Beta ) and replace some lines of code with the translated text:



Replace lines 64-83 with the following:

case TRADE_RETCODE_REQUOTE: sRetCode=(string)retcode+" REQUOTE"; break;// 10004
case TRADE_RETCODE_REJECT: sRetCode=(string)retcode+" REQUEST REJECTED"; break;
case TRADE_RETCODE_CANCEL: sRetCode = (string)retcode+" CANCELLED"; break;
case TRADE_RETCODE_PLACED: sRetCode = (string)retcode+" ORDER PLACED"; break;
case TRADE_RETCODE_DONE: sRetCode=(string)retcode+" DONE"; break;
case TRADE_RETCODE_DONE_PARTIAL: sRetCode=(string)retcode+" DONE PARTIALLY"; break;
case TRADE_RETCODE_ERROR: sRetCode=(string)retcode+" REQUEST ERROR"; break;
case TRADE_RETCODE_TIMEOUT: sRetCode = (string)retcode+" REQUEST REJECTED BY TIMEOUT"; break;
case TRADE_RETCODE_INVALID: sRetCode = (string)retcode+" INVALID REQUEST"; break;
case TRADE_RETCODE_INVALID_VOLUME: sRetCode=(string)retcode+" INVALID VOLUME"; break;
case TRADE_RETCODE_INVALID_PRICE: sRetCode = (string)retcode+" INVALID PRICE"; break;
case TRADE_RETCODE_INVALID_STOPS: sRetCode = (string)retcode+" INVALID STOPS"; break;
case TRADE_RETCODE_TRADE_DISABLED: sRetCode=(string)retcode+" TRADE DISABLED"; break;
case TRADE_RETCODE_MARKET_CLOSED: sRetCode =(string)retcode+" MARKET IS CLOSED"; break;
case TRADE_RETCODE_NO_MONEY: sRetCode=(string)retcode+" NO MONEY TO HANDLE REQUEST"; break;
case TRADE_RETCODE_PRICE_CHANGED: sRetCode=(string)retcode+" PRICE CHANGED"; break;
case TRADE_RETCODE_PRICE_OFF: sRetCode=(string)retcode+" NO QUOTES TO HANDLE REQUEST"; break;
case TRADE_RETCODE_INVALID_EXPIRATION: sRetCode=(string)retcode+" INVALID EXPIRATION DATE"; break;
case TRADE_RETCODE_ORDER_CHANGED: sRetCode=(string)retcode+" ORDER STATUS CHANGED"; break;
case TRADE_RETCODE_TOO_MANY_REQUESTS: sRetCode=(string)retcode+" TOO MANY REQUESTS"; break;


line 242: ObjectSetString(0,buttonID,OBJPROP_TEXT,"Close all orders with one click");
line 262: ObjectSetString(0,labelID1,OBJPROP_TEXT,"Close orders when deposit percent is");
line 347: message="Button is pressed";
line 353: message="Button is not pressed";


Download the EA
View the MQL5 source code

Here i will post all information about Metatrader 5 indicators, scripts and EA's. This post will be regularly updated with links to new content. In the future, i will sort the indicators, scripts and EA's to apart categories.



- MT 5 Indicator Update
- 8 new indicators for Metatrader 5
- Rewrite MQL 4 to MQL 5 Script
- FraMa Cross Indicator and EA for MT5
- Bma and Double Smoothed Stoch Indicators for MT5
- Prev-Next Timeframe Script for MT5
- More indicators for Metatrader 5
- Delete all Objects Script for MT5
- Close All Expert for MT5
- First Metatrader 5 Indicators