Download MetaTrader 5

Multi-Currency EA for MT5

To add comments, please log in or register
andrew.potter77
54
andrew.potter77  
Hello, my EA can work well on multiple currencies so I would like to test it with the portfolio tester on more than one currency.  Is there any recommendations or resources for designing a multi-currency EA for the portfolio tester in MT5?  Is it necessary to modularize the EA code and test each pair simultaneously within the EA?  Or is there some shortcut for expediting this?  Is there any code or templates you could recommend for this?  Thank you 
meisme
39
meisme  
I guess you can wrap your current code to class.  It's the fastest way that i can think :)

Karlis Balcers
7037
Karlis Balcers  

It's easy! Here is example how I do it. By using it, you can test USDCAD, GBPUSD, USDCHF or any other currency by selecting EURUSD and get the same results (or use them all in the same time).

int OnInit()
{
   //Add all currencies you want to test
   MarketBookAdd("USDCHF");
   MarketBookAdd("GBPUSD");
   MarketBookAdd("USDCAD");

   //Add timer in case if EURUSD (if you use it as base currency for testing) does not have any ticks.
   //I use 2 seconds and only when in real trading. It is not necessary for optimisation and testing
   if(!MQL5InfoInteger(MQL5_OPTIMIZATION) && !MQL5InfoInteger(MQL5_TESTING))
   {
      EventSetTimer(2);
   } 

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
{
   Work();
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTimer()
{
   Work();
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Work()
{
   //Do your strategy here.
}


andrew.potter77
54
andrew.potter77  
tsaktuo:

It's easy! Here is example how I do it. By using it, you can test USDCAD, GBPUSD, USDCHF or any other currency by selecting EURUSD and get the same results (or use them all in the same time).


great thanks
To add comments, please log in or register