Multipair test

 

Hi there community, I'd like to take a step forward into my coding knowledge with your well appreciated help.

The main idea besides on the possibility of taking multipair tests through the 'SymbolList' input, I've been checking some samples but still need some help to fit this into my own way of coding.

As this is intended just for testing purpose, I'm trying to fit the proper lines into the OnTesterPass void but don't even know how or if it's correct. By this template you can see how I'm trying to make this work:

//+--- Parameters ---------------------------------------------------!
input bool   ManageAll     = true; // ManageAll (MarketWatch)
input bool   Multipair     = true; // Multipair test
input string SymbolList    = "EURUSD,USDJPY,EURJPY,GBPUSD,EURGBP,GBPJPY";
input string CustomComment = "MyMCbot";
input ulong  MagicNumber   = 12358;
// ...
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick(){
   for(int s=0;s<SymbolsTotal(true);s++){  // Get MarketWatch symbols.
      string SName=SymbolName(s,true);     // Symbol name filtering.
      if(ManageAll==false){SName=_Symbol;} // ManageAll (true/false) on live testing.
      //+---------------------------------------------- Variables ---!
      //+--------------------------------------------- Indicators ---!
      //+--------------------------------------- Money management ---!
      //+------------------------------------------------ Signals ---!
      //+------------------------------------------ Internal loop ---!
      //+-------------------------------------------------- Start ---!
      //+--------------------------------------------------- Stop ---!
      //+---------------------------------------------- Main loop ---!
      }
   }
//+------------------------------------------------------------------+
//| TesterPass function                                              |
//+------------------------------------------------------------------+
void OnTesterPass(){
   if(Multipair==true){ // Multipair test from SymbolList.
      // How to apply SymbolList to make this work following the OnTick code?
      }
   }
//+--------------------------------------------------------- End. ---+

Along the inputs you can see the ManageAll function which's fair implemented into the OnTick event, then I wrote the Multipair testing option with its correspondant 'SymbolList'.

Then, into the code, used the OnTesterPass function with the hope to call the OnTick event from the specified symbols.

Still have not the proper advisor but just for educational purpose, any help is welcome.

Documentation on MQL5: Integration / MetaTrader for Python / order_calc_margin
Documentation on MQL5: Integration / MetaTrader for Python / order_calc_margin
  • www.mql5.com
order_calc_margin - MetaTrader for Python - Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
OnTester Events are called in a different instance than OnTick is.

The Strategy Tester will run your EA and test the Market data by utilizing your OnTick function (and other events related to trading)

Then, when a test has completed, the main Tester will call a second instance of your EA and send the OnTester Events to it.

I don't see how you would be able to pass data between the two instances.

There would be an external data exchange required to do this task. (Like a Database).
 
Dominik Egert #:
OnTester Events are called in a different instance than OnTick is.

The Strategy Tester will run your EA and test the Market data by utilizing your OnTick function (and other events related to trading)

Then, when a test has completed, the main Tester will call a second instance of your EA and send the OnTester Events to it.

I don't see how you would be able to pass data between the two instances.

There would be an external data exchange required to do this task. (Like a Database).

You mean this should be done from the OnTick event, right?

What if I call void OnTick from the OnTester event, would be some way to make it work through the whole SymbolList?

 
Let's say you open two instances of a text editor. How do you make them sync the inputs?

That's what you are facing.
 
Dominik Egert #:
Let's say you open two instances of a text editor. How do you make them sync the inputs?

That's what you are facing.

Ok, I tried to apply the code into I was looking for the multipair test operation and I'm near to the solution but still having issues. This is the code:

      string SName=SymbolName(s,true);
      if(ManageAll==false){SName=_Symbol;}
      else if(Multipair==true){
         ushort sep=StringGetCharacter(",",0);
         StringSplit(SymbolList,sep,symbolList);
         int TotalSymbols=ArraySize(symbolList);        // Get the number of how many symbols are in the symbolList array
         //ArrayResize(symbolListFinal,numSymbols); // Resize finals symbol list to correct size
         for(int i=0;i<TotalSymbols;i++){               // Combines postfix, symbol, prefix names together
            /*symbolListFinal[i]=symbolPrefix+symbolList[i]+symbolSuffix;
            if(NewBar(symbolListFinal[i])){
               Trade(symbolListFinal[i]);
               }*/
            SName=symbolList[i]; // Here I'm trying to get the input list as operation symbol with testing purpose.
            }
         }

Trying to test on 3 different pairs (EURUSD/GBPUSD/EURGBP) from EURUSD chart, the advisor is only trading EURGBP.

This means it's only trading the last symbol from the list, some help on this matter?