OPEN-SOURCE SCRIPT

EMA 5 & EMA 20 with Buy/Sell Alerts

//version=5
indicator("EMA 5 & EMA 20 with Buy/Sell Alerts", overlay=true)

// Define the 5-period EMA
ema5 = ta.ema(close, 5)
plot(ema5, color=color.blue, linewidth=2, title="EMA 5")

// Define the 20-period EMA
ema20 = ta.ema(close, 20)
plot(ema20, color=color.orange, linewidth=2, title="EMA 20")

// Generate Buy Signal (5 EMA crosses above 20 EMA)
buySignal = ta.crossover(ema5, ema20)
plotshape(buySignal, color=color.green, style=shape.labelup, location=location.belowbar, text="BUY", title="Buy Signal")

// Generate Sell Signal (5 EMA crosses below 20 EMA)
sellSignal = ta.crossunder(ema5, ema20)
plotshape(sellSignal, color=color.red, style=shape.labeldown, location=location.abovebar, text="SELL", title="Sell Signal")

// Alert conditions for Buy and Sell signals
alertcondition(buySignal, title="Buy Alert", message="5 EMA crossed above 20 EMA - Buy Signal!")
alertcondition(sellSignal, title="Sell Alert", message="5 EMA crossed below 20 EMA - Sell Signal!")
Candlestick analysis

開源腳本

在真正的TradingView精神中,這個腳本的作者以開源的方式發佈,這樣交易員可以理解和驗證它。請向作者致敬!您可以免費使用它,但在出版物中再次使用這段程式碼將受到網站規則的約束。 您可以收藏它以在圖表上使用。

想在圖表上使用此腳本?

免責聲明