How to read co-ordinate of trend line ?

 

When drew trend line by --> ObjectCreate("Trendline",OBJ_TREND,0,Time1,Price1,Time2,Price2) .

How to read price at time 3 ?


thank you

 
sorasit46:

When drew trend line by --> ObjectCreate("Trendline",OBJ_TREND,0,Time1,Price1,Time2,Price2) .

How to read price at time 3 ?

Linear interpolation or use ObjectGetValueByShift()
 

with these functions:

int iBarShift( string symbol, int timeframe, datetime time, bool exact=false)

double ObjectGetValueByShift( string name, int shift)


iBarShift changes time to bar nr., use this as "shift" in ObjectGetValueByShift.


when you know the trendline parameters you can calculate the trendline value at any point like this:

price_at_any_point = TLprice2-(TLprice2-TLprice1)/(TLshift2-TLshift1)*any_point_shift;

 
szgy74:


correction: you don't need iBarShift
 
Thank you
Reason: