ChartIndicatorsTotal
ChartIndicatorsTotal
返回应用到指定图表窗口的指标数量。
int ChartIndicatorsTotal(
long chart_id, // 图表 id
int sub_window // 子窗口数量
);参数
- chart_id
[in] 图表ID。0 表示当前图表。
- sub_window
[in] 图表子窗口的数量。0代表主图表的子窗口。
返回值
指定图表窗口的指标数量。若要获得错误信息,请使用 GetLastError() 函数。
注意
函数允许搜寻附加在图表的所有指标。图表窗口的总数可以使用ChartGetInteger()函数从CHART_WINDOWS_TOTAL属性获得。
示例:
//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 取得当前图表ID和它的主窗口加子窗口的数量
long chart_id = ChartID();
int wnd_total= (int)ChartGetInteger(0,CHART_WINDOWS_TOTAL);
//--- 在当前图表的所有窗口中循环迭代
for(int w=0; w<wnd_total; w++)
{
//--- 根据指定的循环索引取得附加到图表窗口中的指标数量
int ind_total=ChartIndicatorsTotal(chart_id, w);
//--- 取得附加于指定图表窗口的指标数量
PrintFormat("Chart ID %I64d, subwindow %d. Attached indicators: %d", chart_id, w, ind_total);
}
/*
结果:
Chart ID 133246248352168439, subwindow 0. Attached indicators: 3
Chart ID 133246248352168439, subwindow 1. Attached indicators: 2
Chart ID 133246248352168439, subwindow 2. Attached indicators: 1
*/
}另见
ChartIndicatorAdd(), ChartIndicatorDelete(), iCustom(), IndicatorCreate(), IndicatorSetString()