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

 

Hello,

 

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:

 

 

 
Use a trendline and set the style to dash
 

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))
      return;
   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);
}
Reason: