SP Indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Smoker024

//@version=5
indicator("SP Indicator", overlay=true)
ma(src, len) => ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len)))

BBMC = ma(close, 60)
rangema = ta.ema(ta.tr, 60)
upperk =BBMC + rangema * 0.2
lowerk = BBMC - rangema * 0.2
color_bar = close > upperk ? color.blue : close < lowerk ? color.fuchsia : color.gray

ExitHigh = ma(high, 15)
ExitLow = ma(low, 15)
Hlv3 = int(na)
Hlv3 := close > ExitHigh ? 1 : close < ExitLow ? -1 : Hlv3[1]
sslExit = Hlv3 < 0 ? ExitHigh : ExitLow
base_cross_Long = ta.crossover(close, sslExit)
base_cross_Short = ta.crossover(sslExit, close)
codiff = base_cross_Long ? 1 : base_cross_Short ? -1 : na 

plotarrow(codiff, colorup=color.blue, colordown=color.fuchsia,title="Exit Arrows", maxheight=20, offset=0)
plot(BBMC, color=color_bar, linewidth=4,title='MA Trendline')
alertcondition(codiff == 1, 'Long', 'Long Condition at {{close}}')
alertcondition(codiff == -1, 'Short', 'Short Condition at {{close}}')

plot(close)
