// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © pAulseperformance
//@version=5
indicator("[preset] Supertrend", overlay = true)
[supertrend, direction] = ta.supertrend(3, input(14, 'ST_ATR Period'))
plot(direction < 0 ? supertrend : na, "Up direction", color.green, 1, style=plot.style_linebr)
plot(direction > 0 ? supertrend : na, "Down direction", color.red, 1, style=plot.style_linebr)
ema1 = ta.ema(close, input.int(100, 'EMA Period'))
plot(ema1, "EMA", close > ema1 ? color.green : color.red, 1, style=plot.style_linebr)
buy = ta.crossunder(direction, 0) and close > ema1
sell = ta.crossover(direction, 0) and close < ema1
plotshape(buy, 'BUY', shape.labelup, location.belowbar, color.green, 0, 'BUY')
plotshape(sell, 'SELL', shape.labeldown, location.abovebar, color.red, 0, 'SELL')
signal = buy ? 1 : sell ? -1 :na
plot(signal, 'signal')