Help needed on getting a value for a specified hour of the day

 

Hi,

I couldn't find a way to get a quote for a specific hour of the day. Let's say I need the close price for EURUSD at 13.00 for the last 5 days.

Is there a function that does something like this?

Your help would be much appreciated. Thanks.

 

One way, which has its advantages, would be to write a data capture EA to write away the 1300 close time to a file, and have it running all the time on an H1 chart.

Then have your trading EA read the last 5 entries from the aforementioned file.


CB

 

It is a good ideea but it would require my computer to be on all the time running the EA (or at least everyday at 13.00) and this is a little hard to do.

I was wondering if there is a function similar to iClose where a certain time could be specified, the data is there on historical charts I just don't have any ideea how to get it automatically :)

Thanks for your answer.

 

And there should be another way, using the shift with (DAYS-1)*24+11+current round hour. (11 is calculated as 24-13) on H1 charts.

Now I need to find out how to get an integer of an hour :) .. at least I got to a decent point.

 

Try this on a H1


double closeArray[5];

int count = 0,
i = 0,
myHour = 13,
T;
while(count != 5)
{
T = TimeHour(Time[i]);
if(T == myHour)
{
closeArray[count] = Close[i];
Print(closeArray[count]);
count++;
}
i++;
}
 
int iBarShift( string symbol, int timeframe, datetime time, bool exact=false)
Search for bar by open time. The function returns bar shift with the open time specified. If the bar having the specified open time is missing, the function will return -1 or the nearest bar shift depending on the exact.
Parameters:
symbol - Symbol the data of which should be used to calculate indicator. NULL means the current symbol.
timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.
time - value to find (bar's open time).
exact - Return mode when bar not found. false - iBarShift returns nearest. true - iBarShift returns -1.
Sample:
  datetime some_time=D'2004.03.21 12:00';
  int      shift=iBarShift("EUROUSD",PERIOD_M1,some_time);
  Print("shift of bar with open time ",TimeToStr(some_time)," is ",shift);
 
Xtrdr:

It is a good ideea but it would require my computer to be on all the time running the EA (or at least everyday at 13.00) and this is a little hard to do.

Isn't this going to severely restrict your automated trading options?


CB

 

This is all you need to get what you want https://docs.mql4.com/series

.

Jon

Reason: