SMA Crossover System
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Michael71825

//@version=5
indicator("SMA Crossover System", shorttitle="SMA Crossover System", overlay=true)

smaShortPeriod = input(13, title="Short SMA Period")
smaMiddlePeriod = input(48, title="Middle SMA Period")
smaLongPeriod = input(200, title="Long SMA Period")

smaShort = ta.sma(close, smaShortPeriod)
smaMiddle = ta.sma(close, smaMiddlePeriod)
smaLong = ta.sma(close, smaLongPeriod)

plot(smaShort, color=color.green, linewidth=1)
plot(smaMiddle, color=color.blue, linewidth=1)
plot(smaLong, color=color.red, linewidth=1)

buyCondition = ta.crossover(smaShort, smaMiddle) and smaShort > smaLong and smaMiddle > smaLong
sellCondition = ta.crossunder(smaShort, smaMiddle) and smaShort < smaLong and smaMiddle < smaLong

if (buyCondition)
    label.new(bar_index, low, text="Buy", color=color.green, style=label.style_label_up, yloc=yloc.belowbar)

if (sellCondition)
    label.new(bar_index, high, text="Sell", color=color.red, style=label.style_label_down, yloc=yloc.abovebar)