How to get the OHLC values missing between the dates?

To add comments, please log in or register
jaffer wilson
923
jaffer wilson  

Hello I am trying to collect the OHLC values of EUR USD, in realtime. But I see some values are missing as there was a bit of processing what I tried and then again started to collect. See the values:  

2018-07-26 11:06:00     1.17268 1.17273 1.17261 1.17264
2018-07-26 11:10:00     1.17258 1.1726  1.17242 1.17242

The values between 11:06:00 and 11:10:00 got missed during the process.   

Kindly, help me get those missing values so that the process completes.

Marco vd Heijden
Moderator
8625
Marco vd Heijden  

Well you can try to reduce the processing if that is an option..

Otherwise you can call:

iTime(_Symbol,PERIOD_M1,X);

Where X is the bar.

To get the minute and:

iOpen(_Symbol,PERIOD_M1,X);
iHigh(_Symbol,PERIOD_M1,X);
iLow(_Symbol,PERIOD_M1,X);
iClose(_Symbol,PERIOD_M1,X);

For the other values.

jaffer wilson
923
jaffer wilson  
Marco vd Heijden:

Well you can try to reduce the processing if that is an option..

Otherwise you can call:

Where X is the bar.

To get the minute and:

For the other values.

How do I decide the X, as it is not know to me sir? Please guide me.

Marco vd Heijden
Moderator
8625
Marco vd Heijden  

Zero or 0 is the current bar.

1 is the bar one minute ago.

2 is the bar two minutes ago.

So every time a bar closes all bars shift like +1. 

Small example:

datetime bar_0=iTime(_Symbol,PERIOD_M1,0);
datetime bar_1=iTime(_Symbol,PERIOD_M1,1);
datetime bar_0=iTime(_Symbol,PERIOD_M1,2);

double open_0=iOpen(_Symbol,PERIOD_M1,0);
double open_1=iOpen(_Symbol,PERIOD_M1,1);
double open_2=iOpen(_Symbol,PERIOD_M1,2);

Print("Last bar: "+TimeToString(bar_0,TIME_MINUTES)+" Open: "+DoubleToString(open_0,_Digits));
Print("Previous bar: "+TimeToString(bar_1,TIME_MINUTES)+" Open: "+DoubleToString(open_1,_Digits));
Print("3 bars ago: "+TimeToString(bar_2,TIME_MINUTES)+" Open: "+DoubleToString(open_2,_Digits));
jaffer wilson
923
jaffer wilson  
Marco vd Heijden:

Zero or 0 is the current bar.

1 is the bar one minute ago.

2 is the bar two minutes ago.

So every time a bar closes all bars shift like +1. 

Small example:

Respected sir, I can understand that the X if nothing but an offset.

But how I can get the value. Say as per my example: 11:06:00 and 11:10:00, so this means that after 11:06:00, there are 3 candles missing. I want to discover it programmatically. The 2018-07-26 11:06:00  figure I am fetching from a file and then want to check it with the latest time. and then Fetch the missing candles. 

Sir I do not wish to open files everytime. As there are huge file. Please can you help me with that?

Marco vd Heijden
Moderator
8625
Marco vd Heijden  

I am not totally sure what is the task can you please describe it bit more clear.

If you have missing candles the function will return 0 or false,  NO_DATA

But a download will be initiated.

So when you call for the data once more, it should be present.

Im not sure why or what you want to do with files.

Here is the function description: https://www.mql5.com/en/docs/series/iopen

Documentation on MQL5: Timeseries and Indicators Access / iOpen
Documentation on MQL5: Timeseries and Indicators Access / iOpen
  • www.mql5.com
The Open price of the bar (indicated by the 'shift' parameter) on the corresponding chart or 0 in case of an error. For error details, call the GetLastError() function. The function always returns actual data. For this purpose it performs a request to the timeseries for the specified symbol/period during each call. This means that if there is...
jaffer wilson
923
jaffer wilson  
Marco vd Heijden:

I am not totally sure what is the task can you please describe it bit more clear.

If you have missing candles the function will return 0 or false,  NO_DATA

But a download will be initiated.

So when you call for the data once more, it should be present.

Im not sure why or what you want to do with files.

Here is the function description: https://www.mql5.com/en/docs/series/iopen

I understood. I try it.

To add comments, please log in or register