OPEN-SOURCE SCRIPT

Enhanced Crypto Master Indicator v6

//version=5
indicator("Enhanced Crypto Master Indicator v6", overlay=true, max_labels_count=500)

// ———— 1. Trend Filter (EMA Cross + ADX Trend Strength) ————
emaFast = ta.ema(close, 50)
emaSlow = ta.ema(close, 200)
emaBullish = ta.crossover(emaFast, emaSlow)
emaBearish = ta.crossunder(emaFast, emaSlow)

// ADX Trend Strength (Fixed DMI Parameters)
adxLength = input(14, "ADX Length")
adxSmoothing = input(14, "ADX Smoothing") // Added missing parameter
[dip, din, adx] = ta.dmi(adxLength, adxSmoothing) // Corrected DMI syntax
strongTrend = adx > 25

// ———— 2. Momentum Filter (RSI Hidden Divergence) ————
rsiLength = input(14, "RSI Length")
rsi = ta.rsi(close, rsiLength)

// Bullish Divergence: Price Lower Low + RSI Higher Low
priceLL = ta.lowest(low, 5)[0] < ta.lowest(low, 5)[1]
rsiHL = ta.lowest(rsi, 5)[0] > ta.lowest(rsi, 5)[1]
bullishDivergence = priceLL and rsiHL

// Bearish Divergence: Price Higher High + RSI Lower High
priceHH = ta.highest(high, 5)[0] > ta.highest(high, 5)[1]
rsiLH = ta.highest(rsi, 5)[0] < ta.highest(rsi, 5)[1]
bearishDivergence = priceHH and rsiLH

// ———— 3. Volume Surge (2x Average) ————
volumeAvg = ta.sma(volume, 20)
volumeSpike = volume > volumeAvg * 2

// ———— 4. Volatility Filter (Bollinger Squeeze) ————
bbLength = input(20, "BB Length")
bbMult = input(2.0, "BB Multiplier")
[bbUpper, bbBasis, bbLower] = ta.bb(close, bbLength, bbMult)
kcLength = input(20, "KC Length")
kcMult = input(1.5, "KC Multiplier")
kcUpper = ta.ema(close, kcLength) + ta.atr(kcLength) * kcMult
kcLower = ta.ema(close, kcLength) - ta.atr(kcLength) * kcMult
squeeze = bbUpper < kcUpper and bbLower > kcLower

// ———— 5. Time-Based Confirmation ————
bullishConfirmation = close[1] > emaFast and close > emaFast
bearishConfirmation = close[1] < emaFast and close < emaFast

// ———— Final Signals ————
buySignal = emaBullish and bullishDivergence and volumeSpike and squeeze and bullishConfirmation and strongTrend
sellSignal = emaBearish and bearishDivergence and volumeSpike and squeeze and bearishConfirmation and strongTrend

// ———— Plots ————
plotshape(buySignal, style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.small)
plotshape(sellSignal, style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.small)
plot(emaFast, color=color.blue)
plot(emaSlow, color=color.red)

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