// Indicators ema = ta.ema(close, emaLength) rsi = ta.rsi(close, rsiLength)
// 1. BULLISH PATTERN (Double Bottom + Retest) // ------------------------------------------- var float necklineBullish = na var bool breakoutBullish = false
// Detect Double Bottom (two lows with a peak in between) swingLow = ta.lowest(low, 5) swingLowPrev = ta.lowest(low, 5)[5] swingHighBetween = ta.highest(high, 5) isDoubleBottom = swingLow >= swingLowPrev * 0.99 and swingLow <= swingLowPrev * 1.01 and swingHighBetween > swingLow and swingHighBetween > swingLowPrev
// Update neckline on pattern detection if isDoubleBottom necklineBullish := swingHighBetween breakoutBullish := false
// Check breakout above neckline if not breakoutBullish and close > necklineBullish breakoutBullish := true
// Retest after breakout (price returns to neckline and bounces) retestBullish = breakoutBullish and low <= necklineBullish and close > necklineBullish and rsi < oversold
// 2. BEARISH PATTERN (Double Top + Retest) // ------------------------------------------- var float necklineBearish = na var bool breakoutBearish = false
// Detect Double Top (two highs with a trough in between) swingHigh = ta.highest(high, 5) swingHighPrev = ta.highest(high, 5)[5] swingLowBetween = ta.lowest(low, 5) isDoubleTop = swingHigh <= swingHighPrev * 1.01 and swingHigh >= swingHighPrev * 0.99 and swingLowBetween < swingHigh and swingLowBetween < swingHighPrev
// Update neckline on pattern detection if isDoubleTop necklineBearish := swingLowBetween breakoutBearish := false
// Check breakout below neckline if not breakoutBearish and close < necklineBearish breakoutBearish := true
// Retest after breakout (price returns to neckline and rejects) retestBearish = breakoutBearish and high >= necklineBearish and close < necklineBearish and rsi > overbought
// 3. EMA + RSI Conditions // ----------------------- emaBuy = ta.crossover(close, ema) and rsi < oversold emaSell = ta.crossunder(close, ema) and rsi > overbought
// Final Buy/Sell Signals (Combine Retest & EMA/RSI) buySignal = retestBullish or emaBuy sellSignal = retestBearish or emaSell
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.
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.