Trend Reversal Indicator (Bull/Bear)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Crunchster1

//@version=5

indicator("Trend Reversal Indicator (Bull/Bear)", shorttitle="TRI", timeframe="W", timeframe_gaps=false)
length = input.int(52, 'Momo length (slow MA)', inline='01')
flength = input.int(13, 'Fast MA length', inline='01')

price = close
momentum(seria, length) =>
	mom = seria[1] - seria[length + 1]
	mom
mom0 = momentum(price, length)
mom1 = momentum(price, flength)
mom0n = mom0 / ta.ema(mom0, length)
mom1n = mom1 / ta.ema(mom1, flength)
s_mom0n = math.sign(mom0) * 2
s_mom1n = math.sign(mom1)
signal = s_mom0n + s_mom1n
smaMom = ta.sma(mom0[1], length)
fmaMom = ta.sma(mom0[1], flength)

bull = signal > 1
corr = signal > 0 and signal <= 1
bear = signal < -1
rebnd = signal < 0 and signal >= -1

plot(mom0n, 'Normalised Slow Momentum', color=color.blue, display=display.none)
plot(signal, 'Signal', color = (bull ? color.green : corr ? color.yellow : rebnd ? color.orange : bear ? color.red : na), style = plot.style_area)
plot(smaMom, 'sMA Momentum', color=color.rgb(20, 164, 20), display=display.none)
plot(fmaMom, 'fMA Momentum', color=color.rgb(13, 14, 13), display=display.none)
hline(0, "Middle Band", color=color.new(#787B86, 50))
