ChartPeriod
ChartPeriod
返回指定图表的时间表 周期 。
ENUM_TIMEFRAMES ChartPeriod(
long chart_id=0 // 图表 ID
);参量
- chart_id=0
[in] 图表 ID. 0 意味着当前图表。
返回值
函数返回ENUM_TIMEFRAMES值之一,如果图表不存在,返回0。
示例:
//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 取得当前图表的周期并在日志中显示取得的值
ENUM_TIMEFRAMES period=ChartPeriod();
Print("Current chart period: ", EnumToString(period));
//--- 获取已有(本例中为当前)图表的ID
long chart_id=ChartID();
period=ChartPeriod(chart_id);
PrintFormat("Chart period with ID %I64d: %s", chart_id, EnumToString(period));
//--- 设置一个随机的图表ID
period=ChartPeriod(1234567890);
if(period==0)
Print("The chart with ID 1234567890 does not exist");
else
Print("Chart period with ID 1234567890: ", EnumToString(period));
/*
结果:
Current chart period: PERIOD_M15
Chart period with ID 133510090240498505: PERIOD_M15
The chart with ID 1234567890 does not exist
*/
}