OPEN-SOURCE SCRIPT

MA + RSI Strategy

//version=5
strategy ("MA + RSI Strategy", overlay=true)

// Input Parameters
fastLength = input.int(9, title="Fast Moving Average Length")
slowLength = input.int(21, title="Slow Moving Average Length")
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")

// Moving Averages
fastMA = ta.sma(close, fastLength)
slowMA = ta.sma(close, slowLength)

// RSI
rsi = ta.rsi(close, rsiLength)

// Buy and Sell Conditions
longCondition = ta.crossover(fastMA, slowMA) and rsi < rsiOversold
shortCondition = ta.crossunder(fastMA, slowMA) and rsi > rsiOverbought

// Plotting Moving Averages
plot(fastMA, color=color.blue, title="Fast MA")
plot(slowMA, color=color.red, title="Slow MA")

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

// Strategy Entry and Exit
if longCondition
strategy.entry("Buy", strategy.long)
if shortCondition
strategy.entry("Sell", strategy.short)
Bands and ChannelsCandlestick analysisChart patterns

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明