How to draw trend line

 

I am trying to drawn a TREND line but I just get a line running across the screen (the wide GOLD line below).

EAM55_2 & EMA55_1 are the EMA's for 2 consecutive figures. The start time on the right hand side appears correct but I just want the length to be (in this example 5 (or 6) periods).

Trying to figure out what is wrong? Any help appreciated



//code used to call my routine
Draw_my_WideLine("WideLine", Time[0],EMA55_2,Time[5],EMA55_1,  Gold);

void Draw_my_WideLine( string obj_name, datetime A_time, double A_value, datetime B_time, double B_value,  color colour)
{  
   if ( ObjectFind(obj_name) == 0 ) ObjectDelete(obj_name); 
   string t1 = "obj_name = "+obj_name+"\nA_time = "+A_time+"\nA_value = "+DoubleToStr(A_value,Digits)+"\nB_value = "+DoubleToStr(B_value,Digits);
   Comment (t1);   
   ObjectCreate(obj_name, OBJ_TREND, 0, A_time, A_value, B_time,  B_value);
   ObjectSet(obj_name, OBJPROP_COLOR,colour);
   ObjectSet(obj_name, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(obj_name, OBJPROP_WIDTH, 10);
   return(0);
}  
 
peterhw1:

I am trying to drawn a TREND line but I just get a line running across the screen (the wide GOLD line below).

EAM55_2 & EMA55_1 are the EMA's for 2 consecutive figures. The start time on the right hand side appears correct but I just want the length to be (in this example 5 (or 6) periods).

Trying to figure out what is wrong? Any help appreciated

Turn Ray off . . .  ObjectSet()  with OBJPROP_RAY  false
 
RaptorUK:
Turn Ray off . . .  ObjectSet()  with OBJPROP_RAY  false

Done, works, thanks.

HAPPY NEW YEAR to you and colleagues, who work so hard to answer MT users - thanks again

 
peterhw1:

Done, works, thanks.

HAPPY NEW YEAR to you and colleagues, who work so hard to answer MT users - thanks again

You are most welcome,  more than happy to help those that try first.  Happy New Year to you  :-)
 

Hello Guys! Is it possible to create a code for drawing trendlines like the one in the picture? Many thanks! Bac