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

 

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

// Function call:
string Sympol = CheckSympol( "EURUSD,USDJPY,GBPUSD,USDCHF,AUDUSD,USDCAD,NZDUSD,EURGBP,EURJPY,GBPJPY,CHFJPY" );
// Function:
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);
}
 
I am pretty sure to have an EA active on a symbol, it does need to be attached to a chart to be able to function.  Doing that is not that bad a deal though.  If you want to trade the same EA on multiple currency pairs and/or timeframes, just open the respective charts and attach the EA to each of them.  You can have the same EA active like that.  The thing you can't have multiples of is signals on 1 account.
 

The problem is that the ea I am trying to code is looking for a very rare condition.

So I need to run it on as many symbols as possible to get better profit in shorter time. 

 
void Symbols(bool only_main=false)
{
   int iCount=SymbolsTotal(false);
   Print("Symbols Count: ", iCount);
   int i;
   for(i=0; i<iCount; i++)
   {
      string sSymbol=SymbolName(i, false);
      string desc=SymbolInfoString(sSymbol, SYMBOL_DESCRIPTION);
   }
}


You can list the symbols available in MT4 like this above.

 
szgy74:


You can list the symbols available in MT4 like this above.

 

where in the code should I add the symbols?

Thank you 

 

In your code you declare an array

string symbols[]

 But you don't size it or assign any values to it.

So

Sympol = symbols[i]; 

 this cannot do anything.

Read the documentation for StringSplit() as this will enable you to populate the array. This only needs to be done once and so can be done in init. 

Once the array is populated, this

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);
}

 will only return the last value in the array.

 
szgy74:


You can list the symbols available in MT4 like this above.

Shouldn't it be String not Void ?
 
GumRai:

In your code you declare an array

 But you don't size it or assign any values to it.

So

 this cannot do anything.

Read the documentation for StringSplit() as this will enable you to populate the array. This only needs to be done once and so can be done in init. 

Once the array is populated, this

 will only return the last value in the array.

Thanks,

I will read the documentation of StringSplit() . 

 
Also check your thread on MQL5.com, as someone has answered you there as well.  https://www.mql5.com/en/forum/61041
 
extern bool Trade_On_All_Market_Currencies=true;
string _Sympols;




// Function Call
if (Trade_On_All_Market_Currencies){
                                     _Sympols=Symbols();
                                   }
else _Sympols=Symbol();
//end of function call

//Function
string Symbols()
{
   int iCount=SymbolsTotal(false); // true, the function returns the number of symbols selected in MarketWatch. If the value is false, it returns the total number of all symbols.
Print("Symbols Count: ", iCount);
   int i;
   for(i=0; i<iCount; i++)
   {
      string sSymbol=SymbolName(i, false);// true, the symbol is taken from the list of symbols selected in MarketWatch. If the value is false, the symbol is taken from the general list.
     // string desc=SymbolInfoString(sSymbol, SYMBOL_DESCRIPTION);
   }
   return(sSymbol);
}

and what about this : Modified from szgy74

 
Thank you 
Reason: