PROTECTED SOURCE SCRIPT

MACD + RSI Strategy Manish

40
//version=5
indicator("MACD + RSI Strategy", overlay=true)

// Input parameters
rsiLength = input.int(14, title="RSI Length")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")
macdFastLength = input.int(12, title="MACD Fast Length")
macdSlowLength = input.int(26, title="MACD Slow Length")
macdSignalSmoothing = input.int(9, title="MACD Signal Smoothing")

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

// MACD Calculation
[macdLine, signalLine, _] = ta.macd(close, macdFastLength, macdSlowLength, macdSignalSmoothing)

// Buy Condition: RSI is oversold and MACD line crosses above Signal line
buyCondition = (rsi < rsiOversold) and (ta.crossover(macdLine, signalLine))

// Sell Condition: RSI is overbought and MACD line crosses below Signal line
sellCondition = (rsi > rsiOverbought) and (ta.crossunder(macdLine, signalLine))

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

// Plot MACD and Signal Line (optional, for visualization)
hline(0, "Zero Line", color=color.gray)
plot(macdLine, color=color.blue, title="MACD Line")
plot(signalLine, color=color.orange, title="Signal Line")

// Alerts for Buy and Sell signals
alertcondition(buyCondition, title="Buy Alert", message="BUY signal generated")
alertcondition(sellCondition, title="Sell Alert", message="SELL signal generated")

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.