// Update neckline on pattern detection if isDoubleBottom necklineBullish := swingHighBetween breakoutBullish := false
// Breakout and Retest Logic breakoutBullish := close > necklineBullish and not breakoutBullish retestBullish = breakoutBullish and low <= necklineBullish and close > necklineBullish and rsi < oversold
// ============== BEARISH PATTERN (Double Top Retest) ============== var float necklineBearish = na var bool breakoutBearish = false
// Update neckline on pattern detection if isDoubleTop necklineBearish := swingLowBetween breakoutBearish := false
// Breakdown and Retest Logic breakoutBearish := close < necklineBearish and not breakoutBearish retestBearish = breakoutBearish and high >= necklineBearish and close < necklineBearish and rsi > overbought
// ~~~~~~~~~~~~~~ BUY/SELL CONDITIONS ~~~~~~~~~~~~~~ // BUY Signal: Bullish retest OR EMA crossover + RSI oversold buyCondition = retestBullish or (ta.crossover(close, ema) and rsi < oversold)
// SELL Signal: Bearish retest OR EMA crossunder + RSI overbought sellCondition = retestBearish or (ta.crossunder(close, ema) and rsi > overbought)
// ==================== PATTERNS ==================== // 1. Double Bottom (Bullish) var float bullishNeckline = na var bool bullishBreakout = false swingLow1 = ta.lowest(low, 5) swingLow2 = ta.lowest(low, 5)[5] swingHighBetween = ta.highest(high, 5) isDoubleBottom = swingLow1 >= swingLow2 * 0.99 and swingLow1 <= swingLow2 * 1.01 and swingHighBetween > swingLow1 if isDoubleBottom bullishNeckline := swingHighBetween bullishBreakout := false bullishBreakout := close > bullishNeckline and not bullishBreakout retestBullish = bullishBreakout and low <= bullishNeckline and close > bullishNeckline and rsi < oversold
// 2. Double Top (Bearish) var float bearishNeckline = na var bool bearishBreakout = false swingHigh1 = ta.highest(high, 5) swingHigh2 = ta.highest(high, 5)[5] swingLowBetween = ta.lowest(low, 5) isDoubleTop = swingHigh1 <= swingHigh2 * 1.01 and swingHigh1 >= swingHigh2 * 0.99 and swingLowBetween < swingHigh1 if isDoubleTop bearishNeckline := swingLowBetween bearishBreakout := false bearishBreakout := close < bearishNeckline and not bearishBreakout retestBearish = bearishBreakout and high >= bearishNeckline and close < bearishNeckline and rsi > overbought
// 3. Trendline Breakout/Breakdown upTrendline = ta.lowest(low, trendlineLength) downTrendline = ta.highest(high, trendlineLength) breakout = close > upTrendline and volume > ta.sma(volume, 20) breakdown = close < downTrendline and volume > ta.sma(volume, 20)
// ~~~~~~~~~~~~~~~~~~~~ BUY/SELL SIGNALS ~~~~~~~~~~~~~~~~~~~~ buyCondition = retestBullish or breakout sellCondition = retestBearish or breakdown
// ~~~~~~~~~~~~~~~~~~~~ PLOT "BUY" AND "SELL" TEXT ON CHART ~~~~~~~~~~~~~~~~~~~~ plotshape(buyCondition, title="BUY", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", textcolor=color.white, size=size.normal) plotshape(sellCondition, title="SELL", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", textcolor=color.white, size=size.normal)
// ~~~~~~~~~~~~~~~~~~~~ EXECUTE ORDERS ~~~~~~~~~~~~~~~~~~~~ if (buyCondition) strategy.entry("BUY", strategy.long) if (sellCondition) strategy.close("BUY")
No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.