OPEN-SOURCE SCRIPT

Buy and Sell Signals Example

//version=5
indicator("Buy and Sell Signals Example", overlay=true)

// Input parameters for the moving averages and RSI
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")
shortMaLength = input.int(50, title="Short MA Length")
longMaLength = input.int(200, title="Long MA Length")

// Calculate the RSI and moving averages
rsi = ta.rsi(close, rsiLength)
shortMa = ta.sma(close, shortMaLength)
longMa = ta.sma(close, longMaLength)

// Define Buy and Sell conditions
buyCondition = rsi < rsiOversold and shortMa > longMa // RSI is oversold and short MA is above long MA
sellCondition = rsi > rsiOverbought and shortMa < longMa // RSI is overbought and short MA is below long MA

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

// Strategy logic for backtesting (optional)
strategy.entry("Buy", strategy.long, when=buyCondition)
strategy.exit("Sell", from_entry="Buy", when=sellCondition)

// Plotting moving averages for visual reference
plot(shortMa, color=color.blue, title="Short MA")
plot(longMa, color=color.orange, title="Long MA")
forecasting

Skrip open-source

Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menerbitkannya sebagai sumber terbuka, sehingga para trader dapat memahami dan memverifikasinya. Hormat untuk penulisnya! Anda dapat menggunakannya secara gratis, namun penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk digunakan pada chart

Inggin menggunakan skrip ini pada chart?

Pernyataan Penyangkalan