Multi Symbol and Multi TimeFrame EA in Mql5

 

I've been trying to code my EA to trade multiple symbols and multiple timeframes and have reached a point where i do not know how to proceed, it complies just fine but i know it's not how it should be done, should i use 3d arrays ? and how so ? How do i get the ChartOpen() to distinguish which symbol and tmeframe to trade ? 

   ENUM_TIMEFRAMES TF[]= {PERIOD_M1,PERIOD_M2,PERIOD_M3,PERIOD_M4,PERIOD_M5,PERIOD_M6,PERIOD_M10,PERIOD_M12,PERIOD_M15,PERIOD_M20,PERIOD_M30,PERIOD_H1};
   for(int i=0; i<=SymbolsTotal(1); i++)
     {
      for(int j=0; j<=ArraySize(TF); j++)
        {
         string    sym = SymbolName(i,1);
         double    open[];
         double    close[];
         double    high[];
         double    low[];
         ArraySetAsSeries(open,true);
         ArraySetAsSeries(close,true);
         ArraySetAsSeries(high,true);
         ArraySetAsSeries(low,true);
         CopyOpen(sym,TF[j],0,35,open);
         CopyClose(sym,TF[j],0,35,close);
         CopyHigh(sym,TF[j],0,35,high);
         CopyLow(sym,TF[j],0,35,low);
         double   bid = SymbolInfoDouble(sym,SYMBOL_BID);
         double   ask = SymbolInfoDouble(sym,SYMBOL_ASK);
         if(.............)
           {
            ChartOpen(sym,TF[j]);
           }
        }
     }
 
DroidM :

I've been trying to code my EA to trade multiple symbols and multiple timeframes and have reached a point where i do not know how to proceed, it complies just fine but i know it's not how it should be done, should i use 3d arrays ? and how so ? How do i get the ChartOpen() to distinguish which symbol and tmeframe to trade ? 

Bad method is to target the selected symbols in the symbols window.

I recommend: decide on the necessary symbols and only then build the logic of the robot.

 
Vladimir Karputov:

Bad method is to target the selected symbols in the symbols window.

I recommend: decide on the necessary symbols and only then build the logic of the robot.

I've selected only the symbols i need and deleted the rest from the symbols windows, so there are only 10 symbols at max

 
DroidM :

I've selected only the symbols i need and deleted the rest from the symbols windows, so there are only 10 symbols at max

Oh, like that? Then that's good.

Now describe what exactly do you need from these ten characters? And why do you need the 'ChartOpen' command?

 
Vladimir Karputov:

Oh, like that? Then that's good.

Now describe what exactly do you need from these ten characters? And why do you need the 'ChartOpen' command?

an array can be used to copy bar info and indicator handles and so on, but 10 symbols across 10 timeframes would be 100 charts, each with its unique info, how do i get it so that i can copy buffers without actually creating each individual symbol and timeframe, use a 3d array ? confused at this point. The ChartOpen() i use to manually inspect the strategy one last time before opening a buy or sell order, The ChartOpen() is in place of buy and sell.

So say the EA meets all the conditions on GBPUSD on M3 chart, how do i code the EA to figure out which symbol and which timeframe has my strategy and then send that to the ChartOpen() ?

Thanks in advance

 
DroidM :

an array can be used to copy bar info and indicator handles and so on, but 10 symbols across 10 timeframes would be 100 charts, each with its unique info, how do i get it so that i can copy buffers without actually creating each individual symbol and timeframe, use a 3d array ? confused at this point. The ChartOpen() i use to manually inspect the strategy one last time before opening a buy or sell order , The ChartOpen() is in place of buy and sell.

So say the EA meets all the conditions on GBPUSD on M3 chart, how do i code the EA to figure out which symbol and which timeframe has my strategy and then send that to the ChartOpen() ?

Thanks in advance

To send a trade order, you DO NOT need to open a chart - an Expert Advisor using the CTrade library can open a position for any symbol.

 
Vladimir Karputov:

To send a trade order, you DO NOT need to open a chart - an Expert Advisor using the CTrade library can open a position for any symbol.

i know that and that's what i chose to do, what i meant is that there is some bit that i would like to visually confirm than just coding the logic for it, kind of like a semi-automatic expert advisor, it'll send trade signals and openchart which meets with my rules, i confirm and then open trade. So getting the multi symbol and multi timeframe part is what im struggling with

 
DroidM :

i know that and that's what i chose to do, what i meant is that there is some bit that i would like to visually confirm than just coding the logic for it, kind of like a semi-automatic expert advisor, it'll send trade signals and openchart which meets with my rules, i confirm and then open trade. So getting the multi symbol and multi timeframe part is what im struggling with

You probably need the following: let's say you are analyzing 5 symbols and 5 timeframes - that means you need to open 5 * 5 = 25 charts. You need to attach a panel advisor to each chart. After that, you manually view all 25 charts. If any chart satisfies you, you simply press the "BUY" or "SELL" button on the panel advisor.

Did I understand you correctly?

 
Vladimir Karputov:

You probably need the following: let's say you are analyzing 5 symbols and 5 timeframes - that means you need to open 5 * 5 = 25 charts. You need to attach a panel advisor to each chart. After that, you manually view all 25 charts. If any chart satisfies you, you simply press the "BUY" or "SELL" button on the panel advisor.

Did I understand you correctly?

No, that just would end up eating a lot of memory and will start lagging.

i need the EA to be attached on a single chart and monitor multiple charts and timeframes, and the the condition is met open the chart with the ChartOpen()

 
DroidM :

No, that just would end up eating a lot of memory and will start lagging.

i need the EA to be attached on a single chart and monitor multiple charts and timeframes, and the the condition is met open the chart with the ChartOpen()

Sorry, We're going in circles. I got out of the discussion.

 
DroidM:

I've been trying to code my EA to trade multiple symbols and multiple timeframes and have reached a point where i do not know how to proceed, it complies just fine but i know it's not how it should be done, should i use 3d arrays ? and how so ? How do i get the ChartOpen() to distinguish which symbol and tmeframe to trade ? 

I suggest you watch the following video that explains a good method of building a multi-symbol EA:  

1.1) Why you REALLY need to start using Multi-Symbol Expert Advisors in MetaTrader 5 - YouTube
1.1) Why you REALLY need to start using Multi-Symbol Expert Advisors in MetaTrader 5
1.1) Why you REALLY need to start using Multi-Symbol Expert Advisors in MetaTrader 5
  • 2020.06.08
  • www.youtube.com
This video looks at the benefits of using a multi-symbol EA (expert advisor) in MetaTrader MT5 and how it could improve your trading results. It also covers ...