mql5 - How to draw a trend line on the chart? -


i want draw trend line on chart in mql5. tried method:

chartindicatoradd(0,0,handle); 

however, did not work , getting below error:-

runtime error (4107)

do want attach indicator chart or want draw (trend) line?

if want draw line, use objectcreate function create line objects.

for instance: objectcreate(chart_id,"bullish",obj_trend,sub_window,time1,price1,time2,price2);

if want draw trend line on current chart, use 0 chart_id. in addition, sub_window refers chart sub-window (i.e. 0 main chart window).

the objectcreate method returns false in case of error, result may want add check this:

if(!objectcreate(chart_id,"bullish",obj_trend,sub_window,time1,price1,time2,price2))      {         print(__function__,": failed draw trend line! error code: ",getlasterror());      } 

make sure reset error code resetlasterror();.

last not least, object properties color can set objectsetinteger function.

read more: objectcreate, objectsetinteger.


Comments