OPEN-SOURCE SCRIPT

DK: SMA Crossover BY

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

// Input parameters for short-term and long-term SMAs
shortLength = input.int(9, title="Short SMA Length", minval=1)
longLength = input.int(21, title="Long SMA Length", minval=1)

// Calculate the short-term and long-term SMAs
shortSMA = ta.sma(close, shortLength)
longSMA = ta.sma(close, longLength)

// Plot the SMAs on the chart
plot(shortSMA, color=color.blue, linewidth=2, title="Short SMA")
plot(longSMA, color=color.red, linewidth=2, title="Long SMA")

// Generate Buy and Sell signals
bullishCross = ta.crossover(shortSMA, longSMA)
bearishCross = ta.crossunder(shortSMA, longSMA)

// Plot Buy and Sell signals on the chart
plotshape(bullishCross, color=color.green, style=shape.labelup, location=location.belowbar, title="Buy Signal", text="BUY")
plotshape(bearishCross, color=color.red, style=shape.labeldown, location=location.abovebar, title="Sell Signal", text="SELL")
Moving Averages

開源腳本

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

想在圖表上使用此腳本?

免責聲明