Download MetaTrader 5
To add comments, please log in or register
Do you wonder how to use widgets? Read the article!
andrew.potter77
54
andrew.potter77 2011.09.05 18:44 
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 2011.09.06 19:28  
I guess you can wrap your current code to class.  It's the fastest way that i can think :)

Karlis Balcers
6573
Karlis Balcers 2011.09.09 14:49  

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 2011.09.18 04:28  
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