indicator · on price · open source
Pivot Trend Filter
Running…
Loading chart…
About
Pivot Trend Filter layers a daily standard pivot over a mid-period trend MA and tints the background when price is above PP and the MA slopes up — i.e., trend and structure agree.
- Removes chop signals that fight the trend.
- Use the green tint as a long bias, red tint as a short bias, neutral as no-trade.
Source code
//@version=5
indicator("Pivot Trend Filter", overlay=true)
maLen = input.int(50, "Trend MA length", minval=5, maxval=200)
pp = (ta.highest(high, 1)[1] + ta.lowest(low, 1)[1] + close[1]) / 3
r1 = 2*pp - ta.lowest(low, 1)[1]
s1 = 2*pp - ta.highest(high, 1)[1]
trendMa = ta.rma(close, maLen)
bullConf = close > pp and close > trendMa and trendMa > trendMa[1]
bearConf = close < pp and close < trendMa and trendMa < trendMa[1]
p_PP = plot(pp, "PP", color=color.yellow, style=plot.style_linebr)
p_R1 = plot(r1, "R1", color=color.green, style=plot.style_linebr)
p_S1 = plot(s1, "S1", color=color.red, style=plot.style_linebr)
p_Trend_MA = plot(trendMa, "Trend MA", color=color.blue, linewidth=2)
alertcondition(bullConf and not bullConf[1], "Bullish confluence", "Pivot + MA both turned bullish")
alertcondition(bearConf and not bearConf[1], "Bearish confluence", "Pivot + MA both turned bearish")
No comments yet.
Sign in to comment.