#property strict
#property indicator_chart_window //將這個指標秀在主圖上
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit() //這個函式只在程式開始前執行一次
{
//--- indicator buffers mapping
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---寫出目前價格
iSetLable("ClosePrice", "Price:"+DoubleToStr(iClose(Symbol(),0,0),4), 10, 5, 12, "Arial", Yellow);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
void iSetLable(string LableName, string LableDoc, int LableX, int LableY, int DocSize, string DocStyle, color DocColor){ //此函式參考自索羅斯都要用的外匯交易術
ObjectCreate(LableName, OBJ_LABEL, 0, 0, 0); //建立物件和它的名稱
ObjectSetText(LableName, LableDoc, DocSize, DocStyle, DocColor); //物件要秀出的文本內容
ObjectSet(LableName, OBJPROP_XDISTANCE, LableX); //X座標
ObjectSet(LableName, OBJPROP_XDISTANCE, LableY); // Y座標
}