OBJ_TREND line crossed by a candle..?

 

Hi MQLers,

I am happy to finally be able to programmatically add trendlines on my charts based on select parameters. However I seem to need help with the next step, which is: how am I able to detect if a trendline is crossed by a candle (or any other symbol)? I suppose I am not able to get the coordinates of the graphical objects so calculating the trendline's slope and then going tick by tick and checking their coords is not a way to go. Or is it? Hope I am wrong in many ways ... Can somebody help, please?

 
Martinigue:

Hi MQLers,

I am happy to finally be able to programmatically add trendlines on my charts based on select parameters. However I seem to need help with the next step, which is: how am I able to detect if a trendline is crossed by a candle (or any other symbol)? I suppose I am not able to get the coordinates of the graphical objects so calculating the trendline's slope and then going tick by tick and checking their coords is not a way to go. Or is it? Hope I am wrong in many ways ... Can somebody help, please?

take the openprice and closeprice of candel no.1
 
deVries:


take the openprice and closeprice of candel no.1

Umm, could you be more specific please? How do I find out if candle 1 touches a trendline?
 
Martinigue:

Umm, could you be more specific please? How do I find out if candle 1 touches a trendline?

if not both values bigger or smaller then trendlinevalue at bar 1 then it has crossed...

how do i find out what you are doing

 
deVries:

if not both values bigger or smaller then trendlinevalue at bar 1 then it has crossed...

how do i find out what you are doing


I see ..so it looks like I am still too much of a novice using mql4; e.g. if I add a trendline spanning Time[10] - Time[25], am I able to iterate it as in Trendline[0]. Trendline[2], ... and check the values? If so, then that is exactly what I need..:-)
 
Martinigue:

I see ..so it looks like I am still too much of a novice using mql4; e.g. if I add a trendline spanning Time[10] - Time[25], am I able to iterate it as in Trendline[0]. Trendline[2], ... and check the values? If so, then that is exactly what I need..:-)
https://www.mql5.com/en/forum/139548
 
Cool. Thanks a lot, deVries!
 
Martinigue: I suppose I am not able to get the coordinates of the graphical objects

Suppose wrong

ObjectGetValueByShift - MQL4 Documentation Look for Low[x]<= VBS(x) <= High(x) where x is between TL start iBarShift( ObjectGet(tl, OBJPROP_TIME1)) and end TIME2, inclusive.

or

ObjectGetShiftByValue - MQL4 Documentation Look for SBV(price) between TL start and end.


Reason: