Download MetaTrader 5

How to Draw line from Price1 / Time1 to Price2 / Time2 ?

To add comments, please log in or register
Copy the deals of successful traders. Subscribe to signals!
Miroslav Popov
Miroslav Popov 2016.06.14 09:32 



How can we draw a dashed, colored line from a (Price 1, Time 1) point  to another   (Price 2, Time 2) point?


Something like the blue dashed lines on this screenshot:



Keith Watford
Keith Watford 2016.06.14 10:31  
Use a trendline and set the style to dash
Miroslav Popov
Miroslav Popov 2016.06.14 12:15  

Thank you. It works like a charm!




void CreatePositionLine(datetime time1, double price1, datetime time2, double price2, int lineColor) 
  string name = "Position line " + TimeToString(time1);
  if (!ObjectCreate(0, name, OBJ_TREND, 0, time1, price1, time2, price2))
   ObjectSetInteger(0, name, OBJPROP_COLOR, lineColor);
   ObjectSetInteger(0, name, OBJPROP_STYLE, STYLE_DOT);
   ObjectSetInteger(0, name, OBJPROP_WIDTH, 1);
   ObjectSetInteger(0, name, OBJPROP_BACK, false);
   ObjectSetInteger(0, name, OBJPROP_SELECTABLE,false);
   ObjectSetInteger(0, name, OBJPROP_SELECTED, false);
   ObjectSetInteger(0, name, OBJPROP_RAY_RIGHT, false);
   ObjectSetInteger(0, name, OBJPROP_HIDDEN, true);
   ObjectSetInteger(0, name, OBJPROP_ZORDER, 0);
To add comments, please log in or register