How to get longer TF price data from shorter TF?

 

I want to get candle price data with iHigh and iLow.

When I backtest EA in TF H1 and try to read TFM5 price data, but I can not.


double  price = iHigh(NULL, 5, 0);

 If I run this code in TFH1, why I can not get data?

 
Hong Ling Mu:
double  price = iHigh(NULL, 5, 0);

PERIOD_M5

 
You can always check documentation for more examples and clarification.
 
Yashar Seyyedin #:
You can always check documentation for more examples and clarification.

Thanks.

I will test again.

 
Yashar Seyyedin #:
You can always check documentation for more examples and clarification.

I have just tested

   Print(iHigh(NULL,PERIOD_M5,1));

When I backtest in TF H1 and price out the result.

always zero....

Do you know why ?



 

When requesting data from other than current chart you need to check several error codes to ensure you have received valid data. One of them is 4066:

ERR_HISTORY_WILL_UPDATED 4066 Requested history data in updating state.



ResetLastError();
double h = iHigh(NULL,PERIOD_M5,1);
if(GetLastError()!=0) Print(h);
else Print("Could not load data!");
 

On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
          Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)

 
Yashar Seyyedin #:
ERR_HISTORY_WILL_UPDATED 4066 Requested history data in updating state.


I see...

ERR_HISTORY_WILL_UPDATED 4066 Requested history data in updating state.


That means it will take sometime to get other timeframe data?

 
Hong Ling Mu #:


I see...

ERR_HISTORY_WILL_UPDATED 4066 Requested history data in updating state.


That means it will take sometime to get other timeframe data?

Yes