2017-02-27 31 views
0

說使用EA時,當我檢測到當前的條具有迄今爲止我看到的最低價格時,我會在它下面畫一條水平線,是否可以用EA實現而不是自定義指標?是否可以使用EA繪製指標

回答

2

是的,如果您的條件得到滿足 - 您可以繪製水平線或趨勢線或更新其價格參數。爲了繪製一條線,使用以下函數來移動 - ObjectSetDouble():

bool HLineCreate(const long   chart_ID=0,  // chart's ID 
      const string   name="HLine",  // line name 
      const int    sub_window=0,  // subwindow index 
      double    price=0,   // line price 
      const color   clr=clrRed,  // line color 
      const ENUM_LINE_STYLE style=STYLE_SOLID, // line style 
      const int    width=1,   // line width 
      const bool   back=false,  // in the background 
      const bool   selection=true, // highlight to move 
      const bool   hidden=true,  // hidden in the object list 
      const long   z_order=0)   // priority for mouse click 
{ 
//--- if the price is not set, set it at the current Bid price level 
if(!price) 
    price=SymbolInfoDouble(Symbol(),SYMBOL_BID); 
//--- reset the error value 
    ResetLastError(); 
//--- create a horizontal line 
if(!ObjectCreate(chart_ID,name,OBJ_HLINE,sub_window,0,price)) 
{ 
    Print(__FUNCTION__, 
     ": failed to create a horizontal line! Error code = ",GetLastError()); 
    return(false); 
} 
//--- set line color 
ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); 
//--- set line display style 
ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style); 
//--- set line width 
ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width); 
//--- display in the foreground (false) or background (true) 
ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); 
//--- enable (true) or disable (false) the mode of moving the line by mouse  
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); 
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection); 
//--- hide (true) or display (false) graphical object name in the object list 
ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden); 
//--- set the priority for receiving the event of a mouse click in the chart 
ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); 
//--- successful execution 
return(true); 
} 
相關問題