OPEN-SOURCE SCRIPT

MACD + RSI Buy/Sell Strategy

//version=5
strategy("MACD + RSI Buy/Sell Strategy", overlay=true)

// MACD Settings
[macdLine, signalLine, _] = ta.macd(close, 12, 26, 9)

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

// Buy & Sell Conditions
buyCondition = ta.crossover(macdLine, signalLine) and rsi < 30
sellCondition = ta.crossunder(macdLine, signalLine) and rsi > 70

// Plot Buy and Sell Signals
plotshape(series=buyCondition, location=location.belowbar, color=color.green, style=shape.labelup, size=size.small, title="Buy Signal")
plotshape(series=sellCondition, location=location.abovebar, color=color.red, style=shape.labeldown, size=size.small, title="Sell Signal")

// Execute Trades
strategy.entry("Buy", strategy.long, when=buyCondition)
strategy.close("Buy", when=sellCondition)

คำจำกัดสิทธิ์ความรับผิดชอบ