Forcing History download for non-current symbols - MT5

To add comments, please log in or register
Torinex
90
Torinex  

HI all.


Just recently converted to MT5 to use multi-pair strategies. Currently trying to write a currency strength meter indicator that looks at 28 pairs.

At present, the only way I can make Bars("XXXYYY",PERIOD_CURRENT) work across all 28 pairs is to open all the relevant charts using  ChartOpen(SymbolIndex_Array[i],PERIOD_CURRENT).

If the a relevant chart is not open, Bars("XXXYYY",PERIOD_CURRENT)  returns a zero value, eve though the relevant symbol is available in the MarketWatch (using  SymbolSelect function).


Does anyone have any suggestions apart from opening all the other 27 windows......??


thanks


Alain Verleyen
36527
Alain Verleyen  
Torinex
90
Torinex  
Alain Verleyen:

Read the documentation maybe ? ;-)


Fair point!

I started on MT5 yesterday and have been reading as much as I can. However I'm no programmer and have been struggling with the increased flexibility of MT5 v. MT4 as well as the Object Oriented nature of MT5.


Cheers

whroeder1
17927
whroeder1  
Unless the chart is that specific pair/TF, you must handle 4066/4073 errors. Don't assume that Time[i] == iTime(otherPair,TF, i) always use iBarShift.
Alain Verleyen
36527
Alain Verleyen  
whroeder1:
Unless the chart is that specific pair/TF, you must handle 4066/4073 errors. Don't assume that Time[i] == iTime(otherPair,TF, i) always use iBarShift.
Irrelevant, the topic is about MT5.
whroeder1
17927
whroeder1  
Alain Verleyen: Irrelevant, the topic is about MT5.

Irrelevant how? I mentioned the MT5 Copy functions. Either check at OnTick or when you use them. Either way it has to be done.

Alain Verleyen
36527
Alain Verleyen  
whroeder1:

Irrelevant how? I mentioned the MT5 Copy functions. Either check at OnTick or when you use them. Either way it has to be done.

There is no error 4066 or 4073 with mql4, please don't confuse people by mixing both.

It's useless and confusing to provide mql4 links when answering to mql5 question. Please don't do this.

(by the way I didn't see you mentioned MT5 Copy at first, I had to read your post 3 times to see it).

Torinex
90
Torinex  
Alain Verleyen:

There is no error 4066 or 4073 with mql4, please don't confuse people by mixing both.

It's useless and confusing to provide mql4 links when answering to mql5 question. Please don't do this.

(by the way I didn't see you mentioned MT5 Copy at first, I had to read your post 3 times to see it).


Alain;


I reread the article you referenced a couple of times (had read it before my original post) and, probably because of my ignorance, I still don't understand it.

The MQL5 reference makes it clear that data must be synchronised or Bars returns -1.

What is not clear to me is how to force synchronisation (if this is possible) or is it a case of just waiting for it to happen?

I have tried both:

- waiting with a while loop until all returned values are greater than 1 (and with all Symbols available in Market Watch); and

- opening all relevant charts (with ChartOpen()) and then looping through all Symbols


The waiting option does not seem to work at all. The opening all charts works fine, but is cumbersome.

If you or others can give some guidance, that would be great.


thanks

Alain Verleyen
36527
Alain Verleyen  
Torinex:

Alain;


I reread the article you referenced a couple of times (had read it before my original post) and, probably because of my ignorance, I still don't understand it.

The MQL5 reference makes it clear that data must be synchronised or Bars returns -1.

What is not clear to me is how to force synchronisation (if this is possible) or is it a case of just waiting for it to happen?

I have tried both:

- waiting with a while loop until all returned values are greater than 1 (and with all Symbols available in Market Watch); and

- opening all relevant charts (with ChartOpen()) and then looping through all Symbols


The waiting option does not seem to work at all. The opening all charts works fine, but is cumbersome.

If you or others can give some guidance, that would be great.


thanks

In the article provided there is a function CheckLoadHistory() and a complete example how to use it, not sure how I can help more ?

What is your code ?

EDIT: and please don't start to ask the same question elsewhere, I removed your off-topic post on mql4 section.
Torinex
90
Torinex  
Alain Verleyen:

In the article provided there is a function CheckLoadHistory() and a complete example how to use it, not sure how I can help more ?

What is your code ?

EDIT: and please don't start to ask the same question elsewhere, I removed your off-topic post on mql4 section.

//+------------------------------------------------------------------+
//Ensure adequate Bar History avaialble for all symbols

   //open all required symbols charts to force MT5 to load history (there must be a better way??)
   for(i=0; i<=27; i++)
   {
      ChartOpen(SymbolIndex_Array[i],PERIOD_CURRENT);
   }   
   
   MinBars_Required     = LookBackPeriod + StdDevPeriod;
   MinBars_Available    = 0;
   n=0;
   
   while(MinBars_Available < MinBars_Required)
   {
      BarsHistory_Array[0]   =Bars("AUDCAD",PERIOD_CURRENT);
      BarsHistory_Array[1]   =Bars("AUDCHF",PERIOD_CURRENT);
      BarsHistory_Array[2]   =Bars("AUDJPY",PERIOD_CURRENT);
      BarsHistory_Array[3]   =Bars("AUDNZD",PERIOD_CURRENT);
      BarsHistory_Array[4]   =Bars("AUDUSD",PERIOD_CURRENT);
      BarsHistory_Array[5]   =Bars("EURAUD",PERIOD_CURRENT);
      BarsHistory_Array[6]   =Bars("GBPAUD",PERIOD_CURRENT);
      BarsHistory_Array[7]   =Bars("CADCHF",PERIOD_CURRENT);
      BarsHistory_Array[8]   =Bars("CADJPY",PERIOD_CURRENT);
      BarsHistory_Array[9]   =Bars("EURCAD",PERIOD_CURRENT);
      BarsHistory_Array[10]  =Bars("GBPCAD",PERIOD_CURRENT);
      BarsHistory_Array[11]  =Bars("NZDCAD",PERIOD_CURRENT);
      BarsHistory_Array[12]  =Bars("USDCAD",PERIOD_CURRENT);
      BarsHistory_Array[13]  =Bars("CHFJPY",PERIOD_CURRENT);
      BarsHistory_Array[14]  =Bars("EURCHF",PERIOD_CURRENT);
      BarsHistory_Array[15]  =Bars("GBPCHF",PERIOD_CURRENT);
      BarsHistory_Array[16]  =Bars("NZDCHF",PERIOD_CURRENT);
      BarsHistory_Array[17]  =Bars("USDCHF",PERIOD_CURRENT);
      BarsHistory_Array[18]  =Bars("EURGBP",PERIOD_CURRENT);
      BarsHistory_Array[19]  =Bars("EURJPY",PERIOD_CURRENT);
      BarsHistory_Array[20]  =Bars("EURNZD",PERIOD_CURRENT);
      BarsHistory_Array[21]  =Bars("EURUSD",PERIOD_CURRENT);
      BarsHistory_Array[22]  =Bars("GBPJPY",PERIOD_CURRENT);
      BarsHistory_Array[23]  =Bars("GBPNZD",PERIOD_CURRENT);
      BarsHistory_Array[24]  =Bars("GBPUSD",PERIOD_CURRENT);
      BarsHistory_Array[25]  =Bars("NZDJPY",PERIOD_CURRENT);
      BarsHistory_Array[26]  =Bars("USDJPY",PERIOD_CURRENT);
      BarsHistory_Array[27]  =Bars("NZDUSD",PERIOD_CURRENT);
      
      MinBars_Available = BarsHistory_Array[ArrayMinimum(BarsHistory_Array,0,0)];  
      
      n++;
   }   
   
   Print("Line#: ",__LINE__,
         " | Sufficient History loaded for all Symbols:",
         " | Iterations = ",       n,
         " | MinBars_Required = ", MinBars_Required,
         " | MinBars_Available = ",MinBars_Available);

Alain;

What I'm really trying to understand is if once symbols are in the MarketWatch, the Bars(_Symbol, Period) should return the bars in history or not.

Thanks

Alain Verleyen
36527
Alain Verleyen  
Torinex:

Alain;

What I'm really trying to understand is if once symbols are in the MarketWatch, the Bars(_Symbol, Period) should return the bars in history or not.

Thanks

No.

There is not even an attempt to use CheckLoadHistory() in your code ? No need to open all charts, use the function and check the returned code. Act accordingly.

12
To add comments, please log in or register