跳至内容

iBarShift

iBarShift

通过时间搜索条形图。该函数返回覆盖指定时间的条形的索引。

int  iBarShift(
   string           symbol,          // symbol
   int              timeframe,       // timeframe
   datetime         time,            // time
   bool             exact=false      // mode
   );

参数

symbol

[in] 符号名称。NULL表示当前符号。

timeframe

[in] 时间范围。可以是ENUM_TIMEFRAMES枚举值中的任何一个。0表示当前图表时间范围。

time

[in] 用于搜索的时间值。

exact=false

[in] 当找不到条形图时的返回模式(false - iBarShift返回最近的条形图索引,true - iBarShift返回-1)。

返回值

覆盖指定时间的条形的索引。如果指定时间没有条形图(历史“gap”),函数将返回-1或最近的条形图索引(取决于exact参数)。

示例:

datetime some_time=D'2004.03.21 12:00';
  int      shift=iBarShift("EURUSD",PERIOD_M1,some_time);
  Print("index of the bar for the time ",TimeToStr(some_time)," is ",shift);
最后更新于