I would like to know if it is possible to generate signal depending on if price is below or above a trendline
and how would i convert that into code.
i have attached a picture of what im looking for.
ofcourse it depends on how you calculate the Highs and lows etc..
or is it possible to use the ProReal Oblique trendlines as a signal in below or above in some way?
It’s not possible to know about ojects drawn on the chart.
The solution is to calculate your own trendline.
I will code something asap.
Sorry for the long delay 😔, but I couldn’t write the code you need. I’ll be busy for the next 3 weeks, but I’ll do it soon after.
Sorry for the delay.
I came up with this one:
DEFPARAM DrawOnLastBarOnly = true
ONCE LB = 20 //20 LookBack periods
myMax = max(open,close)
myMin = min(open,close)
IF BarIndex > (LB * 2) THEN
HH2 = highest[LB](myMax[1])
LL2 = lowest[LB](myMin[1])
HH1 = highest[LB](myMax[1+LB])
LL1 = lowest[LB](myMin[1+LB])
DrawSegment(BarIndex[LB*2],HH1,BarIndex,HH2) coloured("Green") style(line,2)
DrawSegment(BarIndex[LB*2],LL1,BarIndex,LL2) coloured("Red") style(line,2)
ENDIF
RETURN
it’s a starting point. Let me know if this is somewhat helpful.
Hi Roberto,
just a question, how do you call this trendline in a strategy? I mean, If I say close crosses over “what” ?
thank’s in advance
You need to build affine function of the trendline and check if price is above/below of the current value of the function, example: https://www.prorealcode.com/topic/etendre-drawray-sur-x-barres/#post-137968
ZigoParticipant
Master
DEFPARAM DrawOnLastBarOnly = true
ONCE LB = n //20 LookBack periods
myMax = max(open,close)
myMin = min(open,close)
IF BarIndex > (LB * 2) THEN
HH2 = highest[LB](myMax[1])
LL2 = lowest[LB](myMin[1])
HH1 = highest[LB](myMax[1+LB])
LL1 = lowest[LB](myMin[1+LB])
DrawSegment(BarIndex[LB*2],HH1,BarIndex+Lb,HH2) coloured("Green") style(line,2)
DrawSegment(BarIndex[LB*2],LL1,BarIndex+Lb,LL2) coloured("Red") style(line,2)
ENDIF
RETURN
ZigoParticipant
Master
2 times the indicator once with a Lookback period of 20 and one with the lookback period of 10 candles.
In the modification also 10 Candles forwards.