ChartIndicatorName
ChartIndicatorName
在指定图表窗口根据指标列表编号返回指标缩略名。
string ChartIndicatorName(
long chart_id, // 图表 id
int sub_window // 子窗口数量
int index // 添加到图表子窗口的指标列表中的指标标引
);参数
- chart_id
[in] 图表 ID。0 表示当前图表。
- sub_window
[in] 图表子窗口的数量。0代表主图表的子窗口。
- index
[in] 指标列表中的指标标引。指标编号从0开始,例如列表中的第一个指标编号为0。若要获得列表中的指标数量,请使用ChartIndicatorsTotal()函数。
返回值
使用IndicatorSetString() 函数在INDICATOR_SHORTNAME 属性设置的指标的缩略名。若要获得错误 信息,请使用 GetLastError()函数。
注意
不要混淆指标缩略名和使用函数 iCustom() 和 IndicatorCreate()创建指标时指定的文件名。 如果指标缩略名没有明确设置,那么包含指标源代码的文件名将在编译期被指明。
指标缩略名应该正确设置。它将使用IndicatorSetString() 函数被写入INDICATOR_SHORTNAME属性。建议缩略名应该包含指标所有输入参数的值,因为通过ChartIndicatorDelete()函数从图表删除的指标通过缩略名识别。
示例:
//+------------------------------------------------------------------+
//| 脚本程序起始函数 |
//+------------------------------------------------------------------+
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 window %d indicators: ", w);
//--- 在循环中写入附加到所选窗口的所有指标的名称
string ind_names="";
for(int i=0; i<ind_total; i++)
{
ind_names+=" "+ChartIndicatorName(chart_id, w, i)+(i<ind_total-1 ? "\n": "");
}
//--- 在日志中打印附加于指定图表窗口的所有指标的名称
Print(ind_names);
}
/*
结果:
Chart window 0 indicators:
AMA(9,2,30)
SAR(0.02,0.20)
Fractals
Chart window 1 indicators:
RSI(14)
AMA(9,2,30)
Chart window 2 indicators:
MFI(14)
*/
}另见
ChartIndicatorAdd(), ChartIndicatorDelete(), ChartIndicatorsTotal(), iCustom(), IndicatorCreate(), IndicatorSetString()