Trendline price at specific time not working !!

 

Hi, I'm coding an EA that opens Buy a Sell trades when the Price breaks the Trendline.

To do so, I'm comparing price values to trend line values. But I don't understand why it's not working.

Basically the conditions are 

--> Buy

if(Close[1] < NormalizeDouble(ObjectGetValueByShift(trendlineName,1),Digits)

&& Close[0] >  NormalizeDouble(ObjectGetValueByShift(trendlineName,0),Digits)  )

 

--> Sell

   if(Close[1] > NormalizeDouble(ObjectGetValueByShift(trendlineName,1),Digits) 

&& Close[0] < NormalizeDouble(ObjectGetValueByShift(trendlineName,0),Digits) 


Shouldn't the  ObjectGetValueByShift(trendlineName,1)  return the value of the trendline at a specific Shift 1 ??

Can anyone help me ? Thanks. 

 
jfortes:

 

Shouldn't the  ObjectGetValueByShift(trendlineName,1)  return the value of the trendline at a specific Shift 1 ??



yes

maybe the conditions not met 

or maybe the trendlineName isn't the right name 

 

I've debugged the code and the trendlineName is correct.

The problem is that the price returned by ObjectGetValueByShift(trendlineName,1)  is not at the Shift 1 (in relation to Time[0] ) , but in relation to anchor point 2.

Can anyone confirm ? Thanks.

 

I've decided to create my own regression function that calculates the price at the Trendline, for a given time.

y = mx +b 

Thanks anyways. 

 
jfortes:

Shouldn't the  ObjectGetValueByShift(trendlineName,1)  return the value of the trendline at a specific Shift 1 ??

Yes, it works as expected on my platform (build 670)

jfortes:

The problem is that the price returned by ObjectGetValueByShift(trendlineName,1)  is not at the Shift 1 (in relation to Time[0] ) , but in relation to anchor point 2.

Are you moving the trend-line's 2nd anchor point to Close[1] in your code?
 

Anchor point 2 is static. I'm using build 670.

You can close the ticket, I've managed to resolve this issue with a linear regression function. 

 
  • ObjectGetvalueByShift() works correctly.
  • None of the coordinates of a trend line are static.
  • There is no need to move anchor points to extend the trend line use OBJPROP_RAY.
  • The shift parameter is not relative to Anchor point 2. It is relative to Time[0].