ibarshift()
Previous  Next

The function returns bar shift with the open time specified.
int ibarshift (int timeframe, // timeframe
long datetimeserial, // time
int limit, // bars back
bool exact=0 // mode
);

Parameters
timeframe
[in] Timeframe. It can be one of the period constants.
datetimeserial
[in] Value to find (bar's open unix time).
limit
[in] Limit the search to the specified number of bars back
exact=0
[in] Return mode when bar not found (0 : ibarshift returns nearest, 1 : ibarshift returns -1).
Returned value
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.
Example:
long some_time=timeb[5];
int shift=ibarshift(PERIOD_D1,some_time);
Printf("shift of bar with open time ",some_time," is ",shift);