如何将标签移到当前蜡烛后面?

时间:2020-02-01 00:34:19

标签: mql4

#property       strict
#property       indicator_chart_window
int OnInit(){

   if( ObjectFind("MyLabel") == -1)
      ObjectCreate(0, "MyLabel", OBJ_LABEL, 0, 0, 0);

   return(INIT_SUCCEEDED);

}

void OnDeinit(const int reason){

   if( ObjectFind("MyLabel") >=0 )
      ObjectDelete(0, "MyLabel");

}

//+------------------------------------------------------------------+
//| 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[])
  {

   ObjectSetText( "MyLabel", "$"+DoubleToString(((Close[0]-Close[4])*10000),1), 12, "Times New Roman", clrBlue);
   ObjectMove( "MyLabel", OBJ_TEXT, Time[0], Close[0]);

   return(rates_total);
  }

Chart Label

我想将$ 72.9移到放置红色箭头的蜡烛上,不仅是我希望标签立即出现在新蜡烛上,所以将标签移到当前蜡烛上?

提前谢谢

1 个答案:

答案 0 :(得分:1)

您已经创建了一个Label对象,其属性为x和y。 您应该创建Text对象(使用OBJ_TEXT),以便可以在时间/价格轴上移动它