Cant Draw a simple line between time on the same chart

 


Think i've hit a brick wall


I'm just trying to draw a trend line between 1200 & 1700 showing the previous high and low for those two times but get a screen that looks like lasers have gone wild after 1200


Can anyone help simply the code to just draw on line not a million


int start()

{

Starter = StrToTime("12:00");

End = StrToTime("17:00");

ObjectCreate(topname, OBJ_TREND,0,Starter, High[1],End,Low[1]);

}

 
        string obj_name = "TrendLine";
        
        datetime time1 = D'2018.11.22 12:00';
        datetime time2 = D'2018.11.22 17:00';
        
        int x = iBarShift(NULL, PERIOD_CURRENT, time1);
        int y = iBarShift(NULL, PERIOD_CURRENT, time2);
        
        if (ObjectFind(obj_name) < 0)
        {
                ObjectCreate(obj_name, OBJ_TREND, 0, time1, High[x], time2, Low[y]);
                ObjectSet(obj_name, OBJPROP_WIDTH, 1);
                ObjectSet(obj_name, OBJPROP_COLOR, clrYellow);
        }
 

Much appreciated but still getting a similar result, is there a way of drawing a diagonal line across the chart instead of a horizontal line

 

I do not really understand what you are doing.
My program does not draw horizontal lines.

Trend Line

 
Nagisa Unada:
Where do you create the arrays High[] and Low[] ?
 
René Moll:
Where do you create the arrays High[] and Low[] ?

You don't create them, they are a part of MQL4