How to run an ea on many symbols by attaching it to one chart ?

Back to topics list  | 1 2 To post a new topic, please log in or register
avatar
Moderator
3419
GumRai 2015.07.05 02:11 #
 

Not tested or compiled. Just a suggestion that you may be able to use

extern bool Trade_On_All_Market_Currencies=true;
string _Sympols[];   //Now _Sympols is declared as an array

 Then in init as there is no need to run this code every tick.

int OnInit()
  {
   if(Trade_On_All_Market_Currencies)
     {
      int iCount=SymbolsTotal(false); // false, the function returns the number of all symbols.
      ArrayResize(_Sympols,iCount);
      Print("Symbols Count: ",iCount);
      int i;
      for(i=0; i<iCount; i++)
        {
         _Sympols[i]=SymbolName(i,false);// false, the symbol is taken from the list of all symbols.
        }
     }
   else  //Just trade on symbols in the market watch window
     {
      int iCount=SymbolsTotal(true); // true, the function returns the number of symbols selected in MarketWatch.
      ArrayResize(_Sympols,iCount);
      Print("Symbols Count: ",iCount);
      int i;
      for(i=0; i<iCount; i++)
        {
         _Sympols[i]=SymbolName(i,true);// true, the symbol is taken from the list of symbols selected in MarketWatch.
        }
     }

//---
   return(INIT_SUCCEEDED);
  }

 

Then in the main code

  int size=ArraySize(_Sympols);
      for(i=0; i<size; i++)
        {
        string symbol_to_work_with=_Sympols[i];
        //
        //Code to work with the symbol
        //
        }

 

Note that if you are working with symbols that or not in the market watch list, you may have to add them to the list to get price information etc. 

This can be done with a function, but I rarely use it so I can't remember it, you will need to look in the documentation and find the function 

avatar
13006
WHRoeder 2015.07.05 13:52 #
 
elkurdiforex: So I need to run it on as many symbols as possible to get better profit in shorter time. 
  1. Do not trade multiple currencies, you can't use any predefined variables, can't use the tester, must poll (not OnTick,) and usually other problems.
  2. Code it to trade the chart pair only. Look at the others if you must.
  3. Then put it on other charts to trade the other pairs. Done.
Back to topics list   | 1 2  

To add comments, please log in or register