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

 

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 

 
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.
 
Mohamed Elkurdi:
Thank you 

could u plz help me as i m nt able to run the ea on multiple pairs (pairs listed in a broker by default)whn i attach th EA on one single chart..

is ther any easy code ?? 

 
Mohamed Elkurdi:

Dear all,

I need help to code an ea that checks the same conditions to open and close trades on as many symbols as it can from the symbols that the broker is dealing in, without opening their charts.

  •   any help on a code that returns " Symbol" and adds it tho the Ordersend.it is a try to run the ea on many currencies by attaching it to one chart.

Here is my try but I do not know if it will work

string CheckSympol( string Sympol )
{
    string symbols[];
    string Sympol = "NONE";
    for( int i=0; i<11; i++) // 11 is the maximum number to loop the condition and it equals the number of symbols to check.
    {
           Sympol = symbols[i];    
    }
    return (Sympol);
}
this code is nt working???..could u plz update it "whts wrong with the code"
 
tasaoirse: this code is nt working???..could u plz update it "whts wrong with the code"
string symbols[];
:
Sympol = symbols[i];    
  1. The array has zero length, so of course you get an array exceeded.
  2. learn to code it, or pay (Freelance) someone. We're not going to code it FOR you.
    We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
Reason: