OPEN-SOURCE SCRIPT

Gold Trading Signal

101
//version=5
indicator("Gold Trading Signal", overlay=true)

// Input parameter
emaLength = input(200, title="EMA Length")

// Calculate EMA
ema200 = ta.ema(close, emaLength)

// Buy & Sell Conditions
buyCondition = ta.crossover(close, ema200)
sellCondition = ta.crossunder(close, ema200)

// Plot signals
plot(ema200, title="EMA 200", color=color.blue, linewidth=2)
plotshape(buyCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="BUY")
plotshape(sellCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="SELL")

// Alerts
alertcondition(buyCondition, title="Buy Signal", message="Gold Buy Signal")
alertcondition(sellCondition, title="Sell Signal", message="Gold Sell Signal")

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.