//+------------------------------------------------------------------+
//| 自定义指标初始化函数 |
//+------------------------------------------------------------------+
int OnInit()
{
//--- 指标缓冲映射
SetIndexBuffer(0,Label1Buffer,INDICATOR_DATA);
// 获得用于指标计算的数据类型
Print("_AppliedTo=",_AppliedTo);
Print(getIndicatorDataDescription(_AppliedTo));
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| 用于指标计算的数据描述 |
//+------------------------------------------------------------------+
string getIndicatorDataDescription(int data_id)
{
string descr="";
switch(data_id)
{
case(0):descr="It's first type of OnCalculate() - no data buffer";
break;
case(1):descr="Indicator calculates on Close price";
break;
case(2):descr="Indicator calculates on Open price";
break;
case(3):descr="Indicator calculates on High price";
break;
case(4):descr="Indicator calculates on Low price";
break;
case(5):descr="Indicator calculates on Median Price (HL/2)";
break;
case(6):descr="Indicator calculates on Typical Price (HLC/3)";
break;
case(7):descr="Indicator calculates on Weighted Price (HLCC/4)";
break;
case(8):descr="Indicator calculates Previous Indicator's data";
break;
case(9):descr="Indicator calculates on First Indicator's data";
break;
default: descr="Indicator calculates on data of indicator with handle="+string(data_id);
break;
}
//---
return descr;
}
|