OPEN-SOURCE SCRIPT
Reversal Hunter X - Private v2

//version=5
indicator("Reversal Hunter X - Private v2", overlay=true)
// === INPUTS ===
rsiSource = input.source(close, "RSI Source")
rsiLen = input.int(14, "RSI Length")
rsiOB = input.int(70, "Overbought Level")
rsiOS = input.int(30, "Oversold Level")
vwapLookback = input.int(50, "VWAP Lookback for Deviation")
vwapDeviation = input.float(2.5, "VWAP Deviation Threshold (%)")
bollLen = input.int(20, "Volatility Band Length")
bollMult = input.float(2.5, "Volatility Band Multiplier")
volAvgLen = input.int(20, "Volume Average Length")
volSpikeRatio = input.float(1.3, "Volume Spike Threshold (1.3 = 30%+)")
showSignals = input.bool(true, "Show Top/Bottom Signals")
// === CALCULATIONS ===
// RSI and divergence
rsi = ta.rsi(rsiSource, rsiLen)
rsiHigh = ta.pivothigh(rsi, 3, 3)
rsiLow = ta.pivotlow(rsi, 3, 3)
priceHigh = ta.pivothigh(high, 3, 3)
priceLow = ta.pivotlow(low, 3, 3)
bearDiv = (not na(rsiHigh) and not na(priceHigh)) and rsiHigh < rsi[3] and priceHigh > high[3]
bullDiv = (not na(rsiLow) and not na(priceLow)) and rsiLow > rsi[3] and priceLow < low[3]
// VWAP Deviation
vwap = ta.vwap
vwapDev = ((close - vwap) / vwap) * 100
vwapOver = vwapDev > vwapDeviation
vwapUnder = vwapDev < -vwapDeviation
// Volatility Bands (like Bollinger Bands)
basis = ta.sma(close, bollLen)
dev = bollMult * ta.stdev(close, bollLen)
upperBand = basis + dev
lowerBand = basis - dev
// SFP trap detection
sfpTop = high > ta.highest(high, 20)[1] and close < open and close < high[1]
sfpBottom = low < ta.lowest(low, 20)[1] and close > open and close > low[1]
// === Trend Filter ===
ema200 = ta.ema(close, 200)
bullTrend = close > ema200
bearTrend = close < ema200
// === Volume Filter ===
volAvg = ta.sma(volume, volAvgLen)
volSpike = volume > (volAvg * volSpikeRatio)
// === FINAL SIGNAL CONDITIONS ===
topSignal = bearDiv and vwapOver and close > upperBand and sfpTop and bearTrend and volSpike
bottomSignal = bullDiv and vwapUnder and close < lowerBand and sfpBottom and bullTrend and volSpike
// === PLOTS ===
plotshape(showSignals and topSignal, title="Top Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="TOP")
plotshape(showSignals and bottomSignal, title="Bottom Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BOTTOM")
plot(ema200, title="EMA 200", color=color.orange)
// === ALERTS ===
alertcondition(topSignal, title="Top Signal Alert", message="Reversal Hunter X: TOP Signal")
alertcondition(bottomSignal, title="Bottom Signal Alert", message="Reversal Hunter X: BOTTOM Signal")
indicator("Reversal Hunter X - Private v2", overlay=true)
// === INPUTS ===
rsiSource = input.source(close, "RSI Source")
rsiLen = input.int(14, "RSI Length")
rsiOB = input.int(70, "Overbought Level")
rsiOS = input.int(30, "Oversold Level")
vwapLookback = input.int(50, "VWAP Lookback for Deviation")
vwapDeviation = input.float(2.5, "VWAP Deviation Threshold (%)")
bollLen = input.int(20, "Volatility Band Length")
bollMult = input.float(2.5, "Volatility Band Multiplier")
volAvgLen = input.int(20, "Volume Average Length")
volSpikeRatio = input.float(1.3, "Volume Spike Threshold (1.3 = 30%+)")
showSignals = input.bool(true, "Show Top/Bottom Signals")
// === CALCULATIONS ===
// RSI and divergence
rsi = ta.rsi(rsiSource, rsiLen)
rsiHigh = ta.pivothigh(rsi, 3, 3)
rsiLow = ta.pivotlow(rsi, 3, 3)
priceHigh = ta.pivothigh(high, 3, 3)
priceLow = ta.pivotlow(low, 3, 3)
bearDiv = (not na(rsiHigh) and not na(priceHigh)) and rsiHigh < rsi[3] and priceHigh > high[3]
bullDiv = (not na(rsiLow) and not na(priceLow)) and rsiLow > rsi[3] and priceLow < low[3]
// VWAP Deviation
vwap = ta.vwap
vwapDev = ((close - vwap) / vwap) * 100
vwapOver = vwapDev > vwapDeviation
vwapUnder = vwapDev < -vwapDeviation
// Volatility Bands (like Bollinger Bands)
basis = ta.sma(close, bollLen)
dev = bollMult * ta.stdev(close, bollLen)
upperBand = basis + dev
lowerBand = basis - dev
// SFP trap detection
sfpTop = high > ta.highest(high, 20)[1] and close < open and close < high[1]
sfpBottom = low < ta.lowest(low, 20)[1] and close > open and close > low[1]
// === Trend Filter ===
ema200 = ta.ema(close, 200)
bullTrend = close > ema200
bearTrend = close < ema200
// === Volume Filter ===
volAvg = ta.sma(volume, volAvgLen)
volSpike = volume > (volAvg * volSpikeRatio)
// === FINAL SIGNAL CONDITIONS ===
topSignal = bearDiv and vwapOver and close > upperBand and sfpTop and bearTrend and volSpike
bottomSignal = bullDiv and vwapUnder and close < lowerBand and sfpBottom and bullTrend and volSpike
// === PLOTS ===
plotshape(showSignals and topSignal, title="Top Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="TOP")
plotshape(showSignals and bottomSignal, title="Bottom Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BOTTOM")
plot(ema200, title="EMA 200", color=color.orange)
// === ALERTS ===
alertcondition(topSignal, title="Top Signal Alert", message="Reversal Hunter X: TOP Signal")
alertcondition(bottomSignal, title="Bottom Signal Alert", message="Reversal Hunter X: BOTTOM Signal")
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.