MQL4 Reference
Timeseries access
iBarShift
| 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);
|
|
|