OPEN-SOURCE SCRIPT

MA & EMA Crossover

//version=5
indicator("MA & EMA Crossover", overlay=true)

// Input Parameters
ma_length = input.int(20, title="MA Length", minval=1)
ema_length = input.int(10, title="EMA Length", minval=1)

// Calculations
ma = ta.sma(close, ma_length)
ema = ta.ema(close, ema_length)

// Signal Conditions
buy_signal = ta.crossover(ema, ma) // EMA crosses above MA
sell_signal = ta.crossunder(ema, ma) // EMA crosses below MA

// Plot MA and EMA
plot(ma, color=color.blue, title="MA (20)", linewidth=2)
plot(ema, color=color.red, title="EMA (10)", linewidth=2)

// Buy and Sell Signals
plotshape(series=buy_signal, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY")
plotshape(series=sell_signal, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL")

// Alerts
alertcondition(buy_signal, title="Buy Alert", message="EMA crossed above MA - Buy Signal")
alertcondition(sell_signal, title="Sell Alert", message="EMA crossed below MA - Sell Signal")
crossoverExponential Moving Average (EMA)

開源腳本

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

想在圖表上使用此腳本?

免責聲明