How to Draw Lines without Buffer?

 

I can draw diagonal lines using indicator_buffers but it require many buffers.
The prices change day by day starting from the beginning of pair's history by an external library.
*note: please ignore the vertical lines

Lines

How to draw this lines by using OBJECT_CREATE?
I tried with below code:

void DrawLines(string text, double priceindex, color linecolor, int linestyle, int linewidth)
{
  datetime = begin_day;
  string linename = "Line: " + text;
  if (ObjectFind(linename) != 0)
  {
    ObjectCreate(linename, OBJ_TREND, 0, TimeToStr(begin_day,TIME_DATE), priceindex, 0, priceindex);
    ObjectSet(linename, OBJPROP_STYLE, linestyle);
    ObjectSet(linename, OBJPROP_COLOR, linecolor);
    ObjectSet(linename, OBJPROP_WIDTH, linewidth);
    ObjectSet(linename, OBJPROP_RAY, false);
  }
  else
  {
    ObjectMove(linename, 0, Time[10], priceindex);
  }
}

And then insert into the loop like this:

int FutureBars=100;
int BarLimits=1000;
int Shift0=0;
int shift_start;
int shift_end;
int counted_bars=IndicatorCounted();
int limit = Bars-counted_bars;

shift_start = MathMin(Bars-1, BarLimits-FutureBars);
shift_end = MathMax(shift_start-BarLimits, Shift0-FutureBars);
price = Open[shift_start]*pips2dbl;

for (int t=limit; t>=shift_end; t--)
{
  DrawLines("Line", price, LineColor, LineStyle, LineWidth);
}

But it failed.
Can someone help me please?

 
Panjianom Adi Pratomo:

I can draw diagonal lines using indicator_buffers but it require many buffers.
The prices change day by day starting from the beginning of pair's history by an external library.
*note: please ignore the vertical lines



How to draw this lines by using OBJECT_CREATE?
I tried with below code:

And then insert into the loop like this:

But it failed.
Can someone help me please?


You used object crate function incorrectly . Fist you converted time to string which is wrong you don't have to convert it . Then in the price you used indec instead of actual price . Then why did you object move if you could have just set both date and time for the second anchor point of the treand line