//@version=4 study("CROCOBOT CARPENTER (meta inside it ) IDEAL PRO MAX ", overlay=true) // β€”β€”β€” Source: Mean of High, Low, Close, Open src = (high + close + open) / 3 // 🎯 Indicators stochK = stoch(src, src, src, 14) rsiVal = rsi(src, 14) cci5 = cci(src, 5) cci20 = cci(src, 20) // βœ… Oversold Conditions stochCond = stochK <= 20 //and stockD<= 20 rsiCond = rsiVal <= 30 cci5Cond = cci5 <= -100 or cci5 >= 100 cci20Cond = cci20 <= -100 or cci20 >= 100 // 🧠 Previous Candle Conditions stochPrev = stochCond[1] rsiPrev = rsiCond[1] cci5Prev = cci5Cond[1] cci20Prev = cci20Cond[1] // ❌ Current Candle Rejection of All Conditions stochNow = not stochCond rsiNow = not rsiCond cci5Now = not cci5Cond cci20Now = not cci20Cond // πŸ” Transition Signal //transition = (stochPrev and rsiPrev) and (cci20Prev and cci5Now) and (stochNow and rsiNow) and (cci20Now and cci5Now) and crossover(atrTrailingStop1,atrTrailingStop2) // πŸ”” Alert //alertcondition(transition, title = "Oversold Recovery Transition", message = "Previous candle met all oversold conditions, current candle rejects all. Possible momentum shift.") // πŸ“ Plot //plotshape(transition, title = "Transition Marker", location = location.abovebar, color = color.green, style = shape.labelup, text = "Shift") // πŸ”Ή **User Inputs for Three ATRs** atrPeriod1 = input(14, title="ATR Period 1") atrMultip1 = input(2, title="ATR Multiplier 1") atrPeriod2 = input(10, title="ATR Period 2") atrMultip2 = input(3, title="ATR Multiplier 2") atrPeriod3 = input(26, title="ATR Period 3") atrMultip3 = input(9, title="ATR Multiplier 3") atrPeriod4 = input(22, title="ATR Period 4") atrMultip4 = input(5, title="ATR Multiplier 4") // πŸ”Ή **Calculate ATR Values** atr1 = atr(atrPeriod1) atr2 = atr(atrPeriod2) atr3 = atr(atrPeriod3) atr4 = atr(atrPeriod4) loss1 = atrMultip1 * atr1 loss2 = atrMultip2 * atr2 loss3 = atrMultip3 * atr3 loss4 = atrMultip4 * atr4 // πŸ”Ή **Trailing Stop Logic for Each ATR** atrTrailingStop1 = float(na) atrTrailingStop1 := close > nz(atrTrailingStop1[1], na) and close[1] > nz(atrTrailingStop1[1], na) ? max(nz(atrTrailingStop1[1], na), close - loss1) : close < nz(atrTrailingStop1[1], na) and close[1] < nz(atrTrailingStop1[1], na) ? min(nz(atrTrailingStop1[1], na), close + loss1) : close > nz(atrTrailingStop1[1], na) ? close - loss1 : close + loss1 atrTrailingStop2 = float(na) atrTrailingStop2 := close > nz(atrTrailingStop2[1], na) and close[1] > nz(atrTrailingStop2[1], na) ? max(nz(atrTrailingStop2[1], na), close - loss2) : close < nz(atrTrailingStop2[1], na) and close[1] < nz(atrTrailingStop2[1], na) ? min(nz(atrTrailingStop2[1], na), close + loss2) : close > nz(atrTrailingStop2[1], na) ? close - loss2 : close + loss2 atrTrailingStop3 = float(na) atrTrailingStop3 := close > nz(atrTrailingStop3[1], na) and close[1] > nz(atrTrailingStop3[1], na) ? max(nz(atrTrailingStop3[1], na), close - loss3) : close < nz(atrTrailingStop3[1], na) and close[1] < nz(atrTrailingStop3[1], na) ? min(nz(atrTrailingStop3[1], na), close + loss3) : close > nz(atrTrailingStop3[1], na) ? close - loss3 : close + loss3 atrTrailingStop4 = float(na) atrTrailingStop4 := close > nz(atrTrailingStop4[1], na) and close[1] > nz(atrTrailingStop4[1], na) ? max(nz(atrTrailingStop4[1], na), close - loss4) : close < nz(atrTrailingStop4[1], na) and close[1] < nz(atrTrailingStop4[1], na) ? min(nz(atrTrailingStop4[1], na), close + loss4) : close > nz(atrTrailingStop4[1], na) ? close - loss4 : close + loss4 // underATR = close < atrTrailingStop1 and close < atrTrailingStop2 aboveATR = close > atrTrailingStop1 and close > atrTrailingStop2 bullishCandle = close > atrTrailingStop1 bearishCandle = close <= atrTrailingStop1 barcolor(bullishCandle ? color.lime : bearishCandle ? color.red : na) //barcolor(underATR ? color.rgb(255, 0, 0) : na) // πŸ”΄ Red for below ATRs //barcolor(aboveATR ? color.rgb(131, 255, 112) : na) // 🟒 Green for above ATRs plot(atrTrailingStop1, color=color.rgb(255, 255, 255), linewidth=2, title="ATR Stop 1") plot(atrTrailingStop2, color=color.rgb(0, 0, 0), linewidth=2, title="ATR Stop 2") plot(atrTrailingStop3, color=color.rgb(255, 0, 0), linewidth=2, title="ATR Stop 3") plot(atrTrailingStop4, color=color.rgb(0, 255, 21, 69), linewidth=2, title="ATR Stop 4") transition = (stochPrev and rsiPrev) and (cci20Prev or cci5Prev) and (stochNow and rsiNow) and (cci20Now or cci5Now) and ((crossover(close,atrTrailingStop2) or crossover(close,atrTrailingStop1)) or crossover(close,atrTrailingStop3) or crossover(close,atrTrailingStop4)) alertcondition(transition, title = "Oversold Recovery Transition", message = "Previous candle met all oversold conditions, current candle rejects all. Possible momentum shift.") //plotshape(transition, title = "Transition Marker", location = location.abovebar, color = color.green, style = shape.triangleup , size = size.small) if (transition) label.new(bar_index, low, text = "Ω…Ψ΄Ϊ©Ω„ Ϊ―Ψ΄Ψ§", style = label.style_label_up, color = color.rgb(0, 0, 0), textcolor = color.rgb(255, 0, 0), size = size.normal) if (transition) // Define rectangle bounds top = low bottom = low left = bar_index right = bar_index + 500 transition6 = (stochPrev and rsiPrev) and (stochNow and rsiNow) and (cci20Prev or cci5Prev) and (cci20Now or cci5Now)//and (crossover(close,atrTrailingStop2) or crossover(close,atrTrailingStop1) or crossover(close,atrTrailingStop3) or crossover(close,atrTrailingStop4)) plotshape(transition6, title = "Transition Marker", location = location.abovebar, color = color.green, style = shape.triangleup , size = size.small) //@version=4 //@author=LucemAnb v=(transition6 and transition) // Define Fractal Length fractalLength = 2 // Detect Bullish Fractal (Higher Low) bullishFractal = low[fractalLength] > low[fractalLength + 1] and low[fractalLength] > low[fractalLength - 1] // Detect Bearish Fractal (Lower High) bearishFractal = high[fractalLength] < high[fractalLength + 1] and high[fractalLength] < high[fractalLength - 1] sma20 = sma(close, 20) sma40 = sma(close, 40) // === Signal Conditions === trendUp = sma20 > sma40 cciExhausted = (cci5 <= -100 or cci20 <= -100) or (cci5 >=100 or cci20 >= 100) priceCrossed = open > sma20 or open < sma40 closedAboveSlow = close >= sma40 and (cross(close,atrTrailingStop1) or cross(close,atrTrailingStop2)) //or cross(close,atrTrailingStop3) or cross(close,atrTrailingStop4)) closedAboveSlow2=close >= sma40 and (cross(close,atrTrailingStop4) or cross(close,atrTrailingStop3)) entrySignal = trendUp and cciExhausted and priceCrossed and closedAboveSlow and atrTrailingStop1 > atrTrailingStop2 and atrTrailingStop2 > atrTrailingStop3 entrySignal2=trendUp and cciExhausted and priceCrossed and closedAboveSlow2 // === Plotting === //plot(sma20, color=color.green, title="SMA 20", linewidth=2) //plot(sma40, color=color.red, title="SMA 40", linewidth=2) //plotshape(entrySignal, location=location.belowbar, style=shape.triangleup, color=color.lime, size=size.small, title="Entry Signal") bgcolor(entrySignal ? color.rgb(0, 255, 127, 15) : na) //plotshape(entrySignal2, location=location.belowbar, style=shape.triangleup, color=color.lime, size=size.small, title="Entry Signal") bgcolor(entrySignal2 ? color.new(color.green, 85) : na) alertcondition(entrySignal or entrySignal2, title = "entrySignal", message = "entrySignal") alertcondition((transition6 and transition) or (entrySignal and entrySignal2), title = "Oversold Recovery Transition", message = "Previous candle met all oversold conditions, current candle rejects all. Possible momentum shift.") bullishSignal = entrySignal2 or transition or entrySignal or transition6 //combinedAlert = bullishSignal // =============================== // πŸ”Ή Signal Candle Low Capture & SL Alert // =============================== // =============================== // πŸ”» Signal Candle Low + SL Alert // =============================== var float signalCandleLow = na signalCandleLow := bullishSignal ? high : signalCandleLow[1] //plot(signalCandleLow, title="Signal Candle Low (SL Level)", color=color.red, style=plot.style_line) //alertcondition(crossunder(close, signalCandleLow), title="SL Breach Alert", message="Price crossed below signal candle low.") // =============================== // πŸ” Reversed Fibonacci Retracement // Uses TrailingStop2 vs signal candle for structural pullback mapping // =============================== useStopAsFib0 = bullishSignal and atrTrailingStop2 < signalCandleLow revFibStart = useStopAsFib0 ? atrTrailingStop2 : signalCandleLow revFibEnd = useStopAsFib0 ? signalCandleLow : atrTrailingStop2 revFib100 = revFibStart revFib786 = revFibStart + (revFibEnd - revFibStart) * 0.786 revFib618 = revFibStart + (revFibEnd - revFibStart) * 0.618 revFib50 = revFibStart + (revFibEnd - revFibStart) * 0.5 revFib382 = revFibStart + (revFibEnd - revFibStart) * 0.382 revFib236 = revFibStart + (revFibEnd - revFibStart) * 0.236 revFib0 = revFibEnd //plot(bullishSignal ? revFib100 : na, title="Rev Fib 0%", color=color.blue, linewidth=2) //plot(bullishSignal ? revFib786 : na, title="Rev Fib 78.6%", color=color.green, linewidth=2) //plot(bullishSignal ? revFib618 : na, title="Rev Fib 61.8%", color=color.orange, linewidth=2) //plot(bullishSignal ? revFib50 : na, title="Rev Fib 50%", color=color.red, linewidth=2) //plot(bullishSignal ? revFib382 : na, title="Rev Fib 38.2%", color=color.purple, linewidth=2) //plot(bullishSignal ? revFib236 : na, title="Rev Fib 23.6%", color=color.yellow, linewidth=2) //plot(bullishSignal ? revFib0 : na, title="Rev Fib 100%", color=color.white, linewidth=2) // =============================== // πŸ”Ί Fibonacci Extension Levels (Take Profit Targets) // Now realigned to project upwards from the bullish structure // =============================== extFibStart = atrTrailingStop2 // Use candle low for bullish anchor extFibEnd = high // Use candle high for bullish move reference extFib1618 = extFibEnd + (extFibEnd - extFibStart) * 0.618 extFib2618 = extFibEnd + (extFibEnd - extFibStart) * 1.618 extFib3618 = extFibEnd + (extFibEnd - extFibStart) * 2.618 extFib4236 = extFibEnd + (extFibEnd - extFibStart) * 3.236 //plot(bullishSignal ? extFib1618 : na, title="TP1 - Fib 1.618", color=color.blue, linewidth=2) //plot(bullishSignal ? extFib2618 : na, title="TP2 - Fib 2.618", color=color.green, linewidth=2) //plot(bullishSignal ? extFib3618 : na, title="TP3 - Fib 3.618", color=color.purple, linewidth=2) //plot(bullishSignal ? extFib4236 : na, title="TP4 - Fib 4.236", color=color.orange, linewidth=2) // Inputs showImpulseZones = input(true, title="Show Impulse Fib Zones") // Impulse anchor logic var float fibStart = na var float fibEnd = na fibStart := bullishSignal ? atrTrailingStop2 : fibStart[1] fibEnd := bullishSignal ? close : fibEnd[1] // Fib reversal zone calculations fib618 = fibEnd - (fibEnd - fibStart) * 0.618 fib786 = fibEnd - (fibEnd - fibStart) * 0.786 // Plot impulse markers //plotshape(showImpulseZones and bullishSignal, location=location.belowbar, color=color.green, style=shape.triangleup, title="Impulse Fib Start") //plotshape(showImpulseZones and bullishSignal, location=location.abovebar, color=color.red, style=shape.triangledown, title="Impulse Fib End") // Plot fib reversal zones //plot(showImpulseZones ? fib618 : na, color=color.orange, title="Impulse Fib 61.8%") //plot(showImpulseZones ? fib786 : na, color=color.purple, title="Impulse Fib 78.6%") // === INPUTS === enableCCIDipLogic = input(true, title="Enable CCI Dip Detection") showDipLabels = input(true, title="Show CCI Dip Labels") useDipAsFibStart = input(true, title="Use CCI Dip as Fib Start") // === Dip Detection Logic === wasExhausted = cci5[1] <= -100 and cci20[1] <= -100 dipFormed = enableCCIDipLogic and cci5 > -100 and cci20 <= -100 and wasExhausted wasntExhausted = cci5[1] >= 100 and cci20[1] >= 100 dipntFormed = enableCCIDipLogic and cci5 >= 100 and cci20 >=100 and wasntExhausted // === Visual Marker === //plotshape(dipFormed, location=location.belowbar, style=shape.circle, color=color.orange, title="CCI Dip Formed") //plotshape(dipntFormed, location=location.belowbar, style=shape.circle, color=color.orange, title="CCI Dipnt Formed") // === INPUTS === // Bollinger Bands Set 1 bb1_len = input(20, title="BB1 Length") bb1_std = input(2.0, title="BB1 StdDev") bb1_src = input(close, title="BB1 Source") bb1_fill = input(true, title="Fill BB1 Area?") // Bollinger Bands Set 2 bb2_len = input(50, title="BB2 Length") bb2_std = input(2.5, title="BB2 StdDev") bb2_src = input(close, title="BB2 Source") bb2_fill = input(true, title="Fill BB2 Area?") // === CCI Inputs === cci_len1 = input(5, title="CCI Length 1") cci_len2 = input(20, title="CCI Length 2") cci_src = input(close, title="CCI Source") // === CALCULATIONS === // Bollinger Bands 1 bb1_basis = sma(bb1_src, bb1_len) bb1_upper = bb1_basis + bb1_std * stdev(bb1_src, bb1_len) bb1_lower = bb1_basis - bb1_std * stdev(bb1_src, bb1_len) // Bollinger Bands 2 bb2_basis = sma(bb2_src, bb2_len) bb2_upper = bb2_basis + bb2_std * stdev(bb2_src, bb2_len) bb2_lower = bb2_basis - bb2_std * stdev(bb2_src, bb2_len) ema40 = ema(close, 40) ema144 = ema(close, 144) // === PLOTTING === // Bollinger Bands 1 plot(bb1_basis, title="BB1 Basis", color=color.orange) p1u = plot(bb1_upper, title="BB1 Upper", color=color.orange, linewidth=1) p1l = plot(bb1_lower, title="BB1 Lower", color=color.orange, linewidth=1) // Bollinger Bands 2 plot(bb2_basis, title="BB2 Basis", color=color.purple) p2u = plot(bb2_upper, title="BB2 Upper", color=color.purple, linewidth=1) p2l = plot(bb2_lower, title="BB2 Lower", color=color.purple, linewidth=1) // Fill Areas fill(p1u, p1l, color=bb1_fill ? color.orange : color.new(color.orange, 100), transp=85, title="BB1 Fill") fill(p2u, p2l, color=bb2_fill ? color.purple : color.new(color.purple, 100), transp=85, title="BB2 Fill") // Moving Averages plot(sma20, title="SMA 20", color=color.blue, linewidth=2) plot(sma40, title="SMA 40", color=color.green, linewidth=2) plot(ema40, title="EMA 40", color=color.red, linewidth=2) plot(ema144, title="EMA 144", color=color.fuchsia, linewidth=2) // === BACKGROUND COLOR === //bgcolor(extreme_cci ? color.white : na, transp=0) // === CCI Calculations === cci1 = cci(cci_src, cci_len1) cci2 = cci(cci_src, cci_len2) // === Anchor Levels === anchor1 = low - tr * 2 // Line for CCI(5) anchor2 = low - tr * 3 // Line for CCI(20) // β€” Signal Flags β€” isEntry = entrySignal or entrySignal2 isTransition = transition or transition6 isDip = dipFormed isFibZone = close >= fib618 and close <= fib786 isFractal = bullishFractal isAboveATR = close > atrTrailingStop1 and close > atrTrailingStop2 // β€” Cluster Scoring β€” clusterScore = (isEntry ? 2 : 0) +(isTransition ? 2 : 0) + (isDip ? 1 : 0) + (isFibZone ? 1 : 0) +(isFractal ? 1 : 0) + (isAboveATR ? 1 : 0) // β€” Threshold for Meta-Signal β€” metaSignal = clusterScore >= 4 // β€” Visual Marker β€” plotshape(metaSignal, location=location.abovebar, style=shape.labelup, color=color.fuchsia, text="META", title="MetaCluster Signal") // β€” Alert β€” alertcondition(metaSignal, title="MetaCluster Alert", message="Multiple modules aligned. High-conviction zone detected.") // β€” Optional: Score Label β€” //plotshape(metaSignal, location=location.abovebar, style=shape.labelup, color=color.fuchsia, text="META", title="MetaCluster Signal") // β€” Optional: Background Heatmap β€” //bgcolor(clusterScore >= 5 ? color.new(color.green, 85) : na) //alertcondition(bullishSignal and cross(close, atrTrailingStop3), title="ATR3 Cross", message="Price crossed ATR Trailing Stop // === Dual Fractal Detection === isBullFractal = low[2] > low[1] and low[1] < low and low[1] < low[3] and low[1] < low[4] isBearFractal = high[2] < high[1] and high[1] > high and high[1] > high[3] and high[1] > high[4] isDualFractal = isBullFractal and isBearFractal //plotshape(isDualFractal, title="Dual Fractal", location=location.abovebar, color=color.orange, style=shape.triangleup, size=size.small) // === Store Fractal Levels (Persistent) var float anchorHigh = na var float anchorLow = na anchorHigh := isDualFractal ? high[1] : anchorHigh anchorLow := isDualFractal ? low[1] : anchorLow // === Draw Horizontal Lines plot(not na(anchorHigh) ? anchorHigh : na, title="Fractal High", color=color.red, style=plot.style_circles ) plot(not na(anchorLow) ? anchorLow : na, title="Fractal Low", color=color.green, style=plot.style_circles) // === Price Crossover Detection longSignal = not na(anchorHigh) and crossover(close, anchorHigh) shortSignal = not na(anchorLow) and crossunder(close, anchorLow) //plotshape(longSignal, title="Long Signal", location=location.belowbar, color=color.rgb(0, 255, 8), style=shape.labelup, text="L") //plotshape(shortSignal, title="Short Signal", location=location.abovebar, color=color.rgb(255, 0, 0), style=shape.labeldown, text="S") alertcondition(longSignal, title="Long Signal Alert", message="Price crossed above fractal low β†’ L") alertcondition(shortSignal, title="Short Signal Alert", message="Price crossed below fractal high β†’ S") // === Fractal Signal Logic (Upgrade Only) === //longSignal = not na(anchorLow) and crossover(close, anchorLow) crossdown1 = not na(anchorHigh) and close[1] < anchorHigh crossdown2 = not na(anchorHigh) and close < anchorHigh //shortSignal = crossdown1 and crossdown2 // === Highlight Signal Logic (L or S + any other signal) highlightSignal = (longSignal or shortSignal) and (entrySignal or entrySignal2 or transition or transition6 ) // === Visual Marker for Highlighted Signal plotshape(highlightSignal, location=location.abovebar, style=shape.labelup, color=color.yellow, text="⚑", size=size.large, title="Highlighted Signal") // === Alert for Highlighted Signal alertcondition(highlightSignal, title="⚑ Highlighted Signal Alert", message="Fractal signal coincides with another major trigger") // === Fractal-Based Fibonacci Retracement (Parallel to ATR-Based) // Only activates when bullishSignal is true and anchorLow is valid useFractalFib = bullishSignal and not na(anchorLow) and anchorLow < signalCandleLow fractFibStart = useFractalFib ? anchorLow : na fractFibEnd = useFractalFib ? signalCandleLow : na fractFib100 = fractFibStart fractFib786 = fractFibStart + (fractFibEnd - fractFibStart) * 0.786 fractFib618 = fractFibStart + (fractFibEnd - fractFibStart) * 0.618 fractFib50 = fractFibStart + (fractFibEnd - fractFibStart) * 0.5 fractFib382 = fractFibStart + (fractFibEnd - fractFibStart) * 0.382 fractFib236 = fractFibStart + (fractFibEnd - fractFibStart) * 0.236 fractFib0 = fractFibEnd //plot(useFractalFib ? fractFib100 : na, title="Fractal Fib 0%", color=color.gray, linewidth=1) //plot(useFractalFib ? fractFib786 : na, title="Fractal Fib 78.6%", color=color.green, linewidth=1) //plot(useFractalFib ? fractFib618 : na, title="Fractal Fib 61.8%", color=color.orange, linewidth=1) //plot(useFractalFib ? fractFib50 : na, title="Fractal Fib 50%", color=color.red, linewidth=1) //plot(useFractalFib ? fractFib382 : na, title="Fractal Fib 38.2%", color=color.purple, linewidth=1) //plot(useFractalFib ? fractFib236 : na, title="Fractal Fib 23.6%", color=color.yellow, linewidth=1) //plot(useFractalFib ? fractFib0 : na, title="Fractal Fib 100%", color=color.white, linewidth=1) // === MetaCluster Between Fractal Anchors === B = metaSignal and close > anchorLow and close < anchorHigh //plotshape(B, title="MetaCluster Between Anchors", location=location.abovebar, style=shape.labelup, color=color.purple, text="METAβœ“") alertcondition(B or metaSignal or highlightSignal or v , title="META TO CHECK Between Anchors Alert", message="META TO CHECK FIRST signal detected between fractal anchors.") allAlerts = B or highlightSignal or metaSignal or v or entrySignal or entrySignal2 alertcondition(allAlerts, title="πŸ”₯ CROCOBOT MASTER ALERT", message="Unified signal detected across CROCOBOT modules. Check dashboard for alignment.") // === Oversold/Overbought Conditions === rsiOversold = rsiVal <= 30 rsiOverbought = rsiVal >= 70 stochOversold = stochK * 100 <= 20 stochOverbought = stochK * 100 >= 80 cciOversold = cci5 <= -100 and cci20 <= -100 cciOverbought = cci5 >= 100 and cci20 >= 100 // === Checkmark Logic === rsiStochCheck = (rsiOversold and stochOversold) or (rsiOverbought and stochOverbought) cciCheck = cciOversold or cciOverbought // === Signal Panel === var table signalPanel = table.new(position.top_right, 1, 8, border_width=1) if bar_index % 5 == 0 table.cell(signalPanel, 0, 0, "πŸ“Š Signal Panel", text_color=color.white, bgcolor=color.gray, text_size=size.normal) table.cell(signalPanel, 0, 1, "RSI: " + tostring(rsiVal, "#.##") + " | Stoch %K: " + tostring(stochK * 100, "#.##") + (rsiStochCheck ? " βœ…" : ""), text_color=color.lime, bgcolor=color.black) table.cell(signalPanel, 0, 2, "CCI(5): " + tostring(cci5, "#.##") + " | CCI(20): " + tostring(cci20, "#.##") + (cciCheck ? " βœ…" : ""), text_color=color.orange, bgcolor=color.black) table.cell(signalPanel, 0, 3, "Status: " + (rsiStochCheck and cciCheck ? "πŸ”₯ All Aligned" : "Waiting..."), text_color=color.white, bgcolor=color.black) // === Dashboard Signal Panel === dashboardSignal = rsiStochCheck and cciCheck if bar_index % 5 == 0 table.cell(signalPanel, 0, 0, "πŸ“Š Signal Panel", text_color=color.white, bgcolor=color.gray, text_size=size.normal) table.cell(signalPanel, 0, 1, "RSI: " + tostring(rsiVal, "#.##") + " | Stoch %K: " + tostring(stochK * 100, "#.##") + (rsiStochCheck ? " βœ…" : ""), text_color=color.lime, bgcolor=color.black) table.cell(signalPanel, 0, 2, "CCI(5): " + tostring(cci5, "#.##") + " | CCI(20): " + tostring(cci20, "#.##") + (cciCheck ? " βœ…" : ""), text_color=color.orange, bgcolor=color.black) table.cell(signalPanel, 0, 3, "Status: " + (dashboardSignal ? "πŸ”₯ All Aligned" : "Waiting..."), text_color=color.white, bgcolor=color.black) //plotshape(dashboardSignal, title="Dashboard Signal", location=location.belowbar, color=color.fuchsia, style=shape.triangleup, text="πŸ“Š", size=size.large) alertcondition(dashboardSignal, title="πŸ“Š Dashboard Signal Alert", message="All dashboard indicators aligned (RSI, Stoch, CCI)") dashboardHighlight = dashboardSignal and highlightSignal //plotshape(dashboardHighlight, title="Dashboard + Highlight", location=location.abovebar, color=color.orange, style=shape.labelup, text="βš‘πŸ“Š", size=size.large) alertcondition(dashboardHighlight, title="βš‘πŸ“Š Dashboard Highlight Alert", message="Dashboard indicators aligned with fractal highlight signal. Check CROCOBOT panel for confirmation.") //dashboardHighlight2 = dashboardSignal and highlightSignal and (entrySignal or entrySignal2 or transition or transition6 ) entryCombo = (entrySignal or entrySignal2 or transition or transition6) entryComboPrev = (entrySignal[1] or entrySignal2[1] or transition[1] or transition6[1]) dashboardHighlight2 = (dashboardSignal or dashboardSignal[1]) and (highlightSignal or highlightSignal[1]) and (entryCombo or entryComboPrev) //plotshape(dashboardHighlight, title="Dashboard + Highlight2", location=location.abovebar, color=color.orange, style=shape.labelup, text="⚑2πŸ“Š", size=size.large) alertcondition(dashboardHighlight, title="βš‘πŸ“Š Dashboard Highlight Alert2", message="Dashboard indicators aligned with fractal highlight signal. Check CROCOBOT panel for confirmation.") alertcondition(dashboardHighlight or dashboardHighlight2, title="βš‘πŸ“Š Dashboard Highlight Alert2", message="Dashboard indicators aligned with fractal highlight signal. Check CROCOBOT panel for confirmation.") // === Trend Envelope Logic === ma1 = ema(close, 13) ma2 = ema(close, 21) ma3 = ema(close, 34) ma = ema(close, 89) range = tr rangema = ema(range, 89) upper = ma + rangema * 0.5 lower = ma - rangema * 0.5 // === Trend Conditions === tr_up = ma1 > upper and ma2 > upper and ma3 > upper tr_down = ma1 < lower and ma2 < lower and ma3 < lower // === Background Pulse (No Value Plotting) === bgcolor(tr_up ? color.green : tr_down ? color.red : na, transp=85) // === 🧠 ATR Multipliers atr1x = 1.5 atr2x = 2.0 atr3x = 2.5 atr4x = 3.0 atr5x = 3.5 // === 🧠 ATR Calculations //atr1 = atr(14) //atr2 = atr(10) //atr3 = atr(26) //atr4 = atr(22) atr5 = atr(7) //loss1 = atr1x * atr1 //loss2 = atr2x * atr2 //loss3 = atr3x * atr3 //loss4 = atr4x * atr4 loss5 = atr5x * atr5 // === 🧠 Trailing Stops var float sl1 = na var float sl2 = na var float sl3 = na var float sl4 = na var float sl5 = na sl1 := close > nz(sl1[1]) ? max(nz(sl1[1]), close - loss1) : min(nz(sl1[1]), close + loss1) sl2 := close > nz(sl2[1]) ? max(nz(sl2[1]), close - loss2) : min(nz(sl2[1]), close + loss2) sl3 := close > nz(sl3[1]) ? max(nz(sl3[1]), close - loss3) : min(nz(sl3[1]), close + loss3) sl4 := close > nz(sl4[1]) ? max(nz(sl4[1]), close - loss4) : min(nz(sl4[1]), close + loss4) sl5 := close > nz(sl5[1]) ? max(nz(sl5[1]), close - loss5) : min(nz(sl5[1]), close + loss5) // === βœ… Breakout Conditions priceAboveAll = close > sl1 and close > sl2 and close > sl3 and close > sl4 and close > sl5 priceBelowAll = close < sl1 and close < sl2 and close < sl3 and close < sl4 and close < sl5 // === 🧠 State Tracking var string lastState = "none" currentState = priceAboveAll ? "buy" : priceBelowAll ? "sell" : "hold" stateChanged = currentState != lastState lastState := stateChanged ? currentState : lastState // === πŸ”” Alerts //alertcondition(stateChanged and currentState == "buy", title="🟒 Buy Breakout", message="Price broke above all SLs β€” Buy setup.") //alertcondition(stateChanged and currentState == "sell", title="πŸ”» Sell Breakdown", message="Price broke below all SLs β€” Sell setup.") // === 🎨 Candle Coloring //barcolor(priceAboveAll ? color.green : priceBelowAll ? color.red : na) // === πŸ“Š Plot SL Trails //plot(sl1, title="SL1", color=color.new(color.red, 0), linewidth=1) //plot(sl2, title="SL2", color=color.new(color.orange, 0), linewidth=1) //plot(sl3, title="SL3", color=color.new(color.yellow, 0), linewidth=1) //plot(sl4, title="SL4", color=color.new(color.green, 0), linewidth=1) //plot(sl5, title="SL5", color=color.new(color.blue, 0), linewidth=1) // === 🧠 Crocobot Entry Overlay //plotshape(priceAboveAll, title="Buy Overlay", location=location.top, style=shape.triangleup, color=color.green, size=size.tiny) //plotshape(priceBelowAll, title="Sell Overlay", location=location.bottom, style=shape.triangledown, color=color.red, size=size.tiny) // === πŸ“Œ PnP: Elliott Wave Trigger via SL Breakout enableElliottOverlay = input(true, title="Ω†Ω…Ψ§ΫŒΨ΄ Ω…ΩˆΨ¬ 3 یا C") strongBreakout = priceAboveAll and close > high[1] and close > high[2] strongBreakdown = priceBelowAll and close < low[1] and close < low[2] plotshape(enableElliottOverlay and strongBreakout, title="شروع Ω…ΩˆΨ¬ 3 (ءعودی)", location=location.belowbar, style=shape.labelup, color=color.lime, text="Ω…ΩˆΨ¬ 3↑", textcolor=color.black) plotshape(enableElliottOverlay and strongBreakdown, title="شروع Ω…ΩˆΨ¬ C (Ω†Ψ²ΩˆΩ„ΫŒ)", location=location.abovebar, style=shape.labeldown, color=color.red, text="Ω…ΩˆΨ¬ C↓", textcolor=color.white) alertcondition(enableElliottOverlay and strongBreakout, title="πŸ“ˆ شروع Ω…ΩˆΨ¬ 3", message="Ψ΄Ϊ©Ψ³Ψͺ ΩΎΨ±Ω‚Ψ―Ψ±Ψͺ Ψ¨Ω‡ Ψ¨Ψ§Ω„Ψ§: Ψ§Ψ­ΨͺΩ…Ψ§Ω„ شروع Ω…ΩˆΨ¬ 3") alertcondition(enableElliottOverlay and strongBreakdown, title="πŸ“‰ شروع Ω…ΩˆΨ¬ C", message="Ψ΄Ϊ©Ψ³Ψͺ ΩΎΨ±Ω‚Ψ―Ψ±Ψͺ Ψ¨Ω‡ ΩΎΨ§ΫŒΫŒΩ†: Ψ§Ψ­ΨͺΩ…Ψ§Ω„ شروع Ω…ΩˆΨ¬ C") // === πŸ“Œ PnP: Elliott Wave Numbering + Alerts enableElliottWaves = input(true, title="ΩΨΉΨ§Ω„β€ŒΨ³Ψ§Ψ²ΫŒ Ω…ΩˆΨ¬β€ŒΩ‡Ψ§ΫŒ Ψ§Ω„ΫŒΩˆΨͺ") useDynamicWaveCount = input(true, title="Use Dynamic Wave Count") manualWaveCount = input(5, title="Max Wave Count (Manual)") // === Signal Flags //isEntry = entrySignal or entrySignal2 //isTransition = transition or transition6 //isDip = dipFormed //isFibZone = close >= fib618 and close <= fib786 //isFractal = bullishFractal //isAboveATR = close > atrTrailingStop1 and close > atrTrailingStop2 // === MetaCluster Score //clusterScore = (isEntry ? 2 : 0) + (isTransition ? 2 : 0) + (isDip ? 1 : 0) + (isFibZone ? 1 : 0) + (isFractal ? 1 : 0) + (isAboveATR ? 1 : 0) // === Confidence Layer confidence = (isEntry and isFractal) ? 100 : (isEntry or isTransition) ? 80 : (isDip or isFibZone) ? 60 : (isAboveATR) ? 50 : 30 // === Dynamic Wave Count via Score + Confidence dynamicWaveCount = clusterScore >= 7 and confidence >= 90 ? 3 : clusterScore >= 5 ? 5 : clusterScore >= 3 ? 2 : clusterScore >= 1 ? 4 : 1 // === Final Wave Count Selector maxWaveCount = useDynamicWaveCount ? dynamicWaveCount : manualWaveCount // === Dashboard Display table.cell(signalPanel, 0, 6, "Wave Count: " + tostring(maxWaveCount), text_color=color.white, bgcolor=color.black) table.cell(signalPanel, 0, 7, "Confidence: " + tostring(confidence), text_color=color.white, bgcolor=color.black) var int waveUp = 0 var int waveDown = 0 newWaveUp = priceAboveAll and close > high[1] and close > high[2] newWaveDown = priceBelowAll and close < low[1] and close < low[2] waveUp := newWaveUp ? waveUp + 1 : waveUp waveDown := newWaveDown ? waveDown + 1 : waveDown waveUp := waveUp > maxWaveCount ? 1 : waveUp waveDown := waveDown > maxWaveCount ? 1 : waveDown // Ω…ΩˆΨ¬β€ŒΩ‡Ψ§ΫŒ ءعودی //plotshape(enableElliottWaves and newWaveUp and waveUp == 1, location=location.belowbar, style=shape.labelup, color=color.green, text="↑ Ω…ΩˆΨ¬ 1", textcolor=color.black) //(enableElliottWaves and newWaveUp and waveUp == 2, location=location.belowbar, style=shape.labelup, color=color.green, text="↑ Ω…ΩˆΨ¬ 2", textcolor=color.black) //plotshape(enableElliottWaves and newWaveUp and waveUp == 3, location=location.belowbar, style=shape.labelup, color=color.green, text="↑ Ω…ΩˆΨ¬ 3", textcolor=color.black) //plotshape(enableElliottWaves and newWaveUp and waveUp == 4, location=location.belowbar, style=shape.labelup, color=color.green, text="↑ Ω…ΩˆΨ¬ 4", textcolor=color.black) //plotshape(enableElliottWaves and newWaveUp and waveUp == 5, location=location.belowbar, style=shape.labelup, color=color.green, text="↑ Ω…ΩˆΨ¬ 5", textcolor=color.black) waveEnd = waveUp == maxWaveCount or waveDown == maxWaveCount // Ω…ΩˆΨ¬β€ŒΩ‡Ψ§ΫŒ Ω†Ψ²ΩˆΩ„ΫŒ //plotshape(enableElliottWaves and newWaveDown and waveDown == 1, location=location.abovebar, style=shape.labeldown, color=color.red, text="↓ Ω…ΩˆΨ¬ 1", textcolor=color.white) //plotshape(enableElliottWaves and newWaveDown and waveDown == 2, location=location.abovebar, style=shape.labeldown, color=color.red, text="↓ Ω…ΩˆΨ¬ 2", textcolor=color.white) //plotshape(enableElliottWaves and newWaveDown and waveDown == 3, location=location.abovebar, style=shape.labeldown, color=color.red, text="↓ Ω…ΩˆΨ¬ 3", textcolor=color.white) //plotshape(enableElliottWaves and newWaveDown and waveDown == 4, location=location.abovebar, style=shape.labeldown, color=color.red, text="↓ Ω…ΩˆΨ¬ 4", textcolor=color.white) ///plotshape(enableElliottWaves and newWaveDown and waveDown == 5, location=location.abovebar, style=shape.labeldown, color=color.red, text="↓ Ω…ΩˆΨ¬ 5", textcolor=color.white) // === Bullish Wave Alerts === alertcondition((enableElliottWaves and newWaveUp and waveUp == 1) or (enableElliottWaves and newWaveDown and waveDown == 1), title="Wave 1/1 Up", message="Wave 1 Up detected") alertcondition(enableElliottWaves and newWaveUp and waveUp == 2, title="Wave 2 Up", message="Wave 2 Up detected") alertcondition(enableElliottWaves and newWaveUp and waveUp == 3, title="Wave 3 Up", message="Wave 3 Up detected") alertcondition(enableElliottWaves and newWaveUp and waveUp == 4, title="Wave 4 Up", message="Wave 4 Up detected") alertcondition((enableElliottWaves and newWaveUp and waveUp == 5) or (enableElliottWaves and newWaveDown and waveDown == 5), title="Wave 5/5 Up", message="Wave 5 Up detected") // === Bearish Wave Alerts === //alertcondition(enableElliottWaves and newWaveDown and waveDown == 1, title="Wave 1 Down", message="Wave 1 Down detected") alertcondition(enableElliottWaves and newWaveDown and waveDown == 2, title="Wave 2 Down", message="Wave 2 Down detected") alertcondition(enableElliottWaves and newWaveDown and waveDown == 3, title="Wave 3 Down", message="Wave 3 Down detected") alertcondition(enableElliottWaves and newWaveDown and waveDown == 4, title="Wave 4 Down", message="Wave 4 Down detected") //alertcondition(enableElliottWaves and newWaveDown and waveDown == 5, title="Wave 5 Down", message="Wave 5 Down detected") // Define your bullish signal condition (example: bullish engulfing) //bullishSignal = close > open and close[1] < open[1] and close > open[1] // Persistent counter var int candleCount = na candleCount := bullishSignal ? 1 : (not na(candleCount) ? candleCount + 1 : na) // Labeling specific candles if candleCount == 8 label.new(bar_index, high, "8", style=label.style_label_down, color=color.rgb(54, 58, 69, 100), textcolor=color.white) if candleCount == 13 label.new(bar_index, high, "13", style=label.style_label_down, color=color.rgb(54, 58, 69, 100), textcolor=color.white) if candleCount == 21 label.new(bar_index, high, "21", style=label.style_label_down, color=color.rgb(54, 58, 69, 100), textcolor=color.white) if candleCount == 34 label.new(bar_index, high, "34", style=label.style_label_down, color=color.rgb(54, 58, 69, 100), textcolor=color.white) if candleCount == 55 label.new(bar_index, high, "55", style=label.style_label_down, color=color.rgb(54, 58, 69, 100), textcolor=color.white) if candleCount == 89 label.new(bar_index, high, "89", style=label.style_label_down, color=color.rgb(54, 58, 69, 100), textcolor=color.white) // Reset counter if desired (optional) // candleCount := someResetCondition ? na : candleCount D = bullishSignal and (enableElliottWaves or enableElliottWaves or enableElliottWaves or enableElliottWaves or enableElliottWaves or candleCount == 8 or candleCount == 13 or candleCount == 34 or candleCount == 55 or candleCount == 89 ) plotshape(D and newWaveUp and waveUp == 1, location=location.bottom, style=shape.labelup, color=color.rgb(255, 255, 255, 100), text="↑ Ω…ΩˆΨ¬ 1", textcolor=color.rgb(255, 255, 255)) alertcondition(D , title="D", message="D") // === INPUTS === iBarsBack = input(defval=2, title="Bars Back", type=input.integer) macdFast = input(defval=40, title="MACD Fast Length", type=input.integer) macdSlow = input(defval=144, title="MACD Slow Length", type=input.integer) macdSignal = input(defval=9, title="MACD Signal Length", type=input.integer) // === MOVING AVERAGES === //sma20 = sma(close, 20) //sma40 = sma(close, 40) //ema40 = ema(close, 40) //ema144 = ema(close, 144) // === SLOPE CALCULATIONS === changeSMA20 = change(sma20, 1) changeSMA40 = change(sma40, 1) slopeSMA20 = changeSMA20 slopeSMA40 = changeSMA40 rad2degree = 180 / 3.14159265359 slopeSMA20Degree = rad2degree * atan(slopeSMA20) slopeSMA40Degree = rad2degree * atan(slopeSMA40) // === BARS BACK SLOPE === sma2sample = sma(close, 20) slopeD20 = rad2degree * atan((sma2sample[1] - nz(sma2sample[iBarsBack])) / iBarsBack) // === CCI CONDITIONS === //cci5 = cci(close, 20) cci55 = cci(close, 5) cciCondition1 = (cci5 <= -99 or cci5 >= 99) or (cci5[1] <= -99 or cci5[1] >= 99) cciCondition2 = (cci55 <= -99 or cci55 >= 99) or (cci55[1] <= -99 or cci55[1] >= 99) cciCondition22 = (cciCondition1 or cciCondition2) // === TOUCH CONDITIONS === touchConditionBottom1 = (low[1] <= sma20[1] or high[1] <= sma20[1]) or (low <= sma20 or high <= sma20) touchConditionBottom2 = close[1] >= sma40[1] // === SMA & SLOPE CONDITIONS === smaSCondition = sma20[1] >= sma40[1] slopeSMA20Condition = slopeSMA20Degree > 0 slopeSMA40Condition = slopeSMA40Degree > 0 // === BEARISH OVERRIDE === bearishOverride = close < sma20 or close < sma40 // === MAIN SIGNAL === finalResult = cciCondition22 and touchConditionBottom1 and touchConditionBottom2 and smaSCondition and slopeSMA20Condition and slopeSMA40Condition // === MACD FLIP LOGIC === macdLine = ema(close, macdFast) - ema(close, macdSlow) macdSignalLine = ema(macdLine, macdSignal) bullFlip = crossover(macdLine, macdSignalLine) bearFlip = crossunder(macdLine, macdSignalLine) // === SIGNAL TYPES === confirmedBull = finalResult and bullFlip and not bearishOverride pendingBull = finalResult and not bullFlip and not bearishOverride bearishSignal = finalResult and bearishOverride // === SMA COLOR LOGIC (Max Saturation) === sma20Color = close > sma20 ? color.lime : color.maroon sma40Color = close > sma40 ? color.lime : color.maroon // === BACKGROUND COLOR === bgcolor(confirmedBull ? color.lime : na, transp=85) entryStrong = entrySignal and transition and isAboveATR metaFractal = bullishFractal and clusterScore >= 4 transitionFiltered = transition and isAboveATR and isFibZone highlightSignalOnce = (longSignal or shortSignal) and (entrySignal or entrySignal2 or transition or transition6) longSignalOnce = bullishFractal and close > anchorLow shortSignalOnce = bearishFractal and close < anchorHigh entryModerate = entrySignal or entrySignal2 waveMid = waveUp == floor(maxWaveCount / 2) or waveDown == floor(maxWaveCount / 2) waveStart = waveUp == 1 or waveDown == 1 // === PLOTTING === //plot(finalResult ? 1.0 : na, title="Main Signal", color=color.green, linewidth=2) //plot(confirmedBull ? 2.0 : na, title="Confirmed Flip", color=color.blue, linewidth=3) plotshape(confirmedBull, title="Bull Flip Overlay", location=location.belowbar, color=color.green, style=shape.arrowup) plotshape(pendingBull, title="Pending Signal", location=location.belowbar, color=color.gray, style=shape.labeldown, text="P") plotshape(bearishSignal, title="Bearish Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="S") alertcondition(D or pendingBull or bearishSignal or confirmedBull , title="D+", message="D+") //alertcondition(confirmedBull and metaSignal, title="Meta Bull Flip", message="Confirmed bull flip with cluster alignment") alertcondition(D and newWaveUp and waveUp == 1, title="D Wave 1 Trigger", message="Wave 1 detected with D+ alignment") // === SMA OVERLAYS WITH MAX GREEN/RED === //plot(sma20, title="SMA 20", color=sma20Color, linewidth=2) //plot(sma40, title="SMA 40", color=sma40Color, linewidth=2) // === Signal Strength Calculation === slBreachMetaSignal = crossunder(close, signalCandleLow) and metaSignal signalStrength = confirmedBull ? 90 : entryStrong ? 85 : metaFractal ? 80 : v ? 75 : transitionFiltered ? 70 : highlightSignalOnce ? 65 : longSignalOnce or shortSignalOnce ? 60 : entryModerate ? 55 : pendingBull ? 50 : dipFormed and isAboveATR ? 45 : waveStart ? 40 : waveMid ? 35 : waveEnd ? 30 : bearishSignal ? 25 : slBreachMetaSignal ? 20 : 0 // === Plot Signal Strength Line === plot(signalStrength, title="Signal Strength", color=color.new(color.teal, 0), linewidth=2, style=plot.style_line) // === Background Heatmap === bgcolor( signalStrength >= 80 ? color.new(color.green, 85) : signalStrength >= 60 ? color.new(color.orange, 85) : signalStrength >= 40 ? color.new(color.red, 85) : na, title="Signal Strength Heatmap") // === Top-Right Panel (existing) === //var table signalPanel = table.new(position.top_right, 1, 1, border_width=1) // === Tactical Descriptions === actionText = signalStrength >= 90 ? "πŸ”₯ Aggressive Entry" : signalStrength >= 80 ? "βœ… Full Entry / Scale In" : signalStrength >= 70 ? "🟒 Light Entry / Probe" : signalStrength >= 60 ? "🟠 Prep Entry / Watchlist" : signalStrength >= 40 ? "πŸ” Monitor / Structure Forming" : signalStrength >= 20 ? "⚠️ Avoid / Weak Signal" : "❌ No Signal" confidenceText = confidence >= 90 ? "πŸ”₯ High Conviction" : confidence >= 80 ? "βœ… Strong Agreement" : confidence >= 60 ? "🟒 Moderate Alignment" : confidence >= 40 ? "🟠 Mixed Signals" : confidence >= 20 ? "⚠️ Low Confidence" : "❌ No Alignment" strengthColor = signalStrength >= 70 ? color.green : signalStrength >= 40 ? color.rgb(63, 60, 100) : color.red // === Signal Panel === //var table signalPanel2 = table.new(position.bottom_left, 1, 8, border_width=1) if bar_index % 5 == 0 //table.cell(signalPanel2, 0, 0, "πŸ“Š Signal Panel", text_color=color.white, bgcolor=color.gray) //table.cell(signalPanel, 0, 1, "RSI: " + tostring(rsiVal, "#.##") + " | Stoch %K: " + tostring(stochK * 100, "#.##") + (rsiStochCheck ? " βœ…" : ""), text_color=color.lime, bgcolor=color.black) //table.cell(signalPanel, 0, 2, "CCI(5): " + tostring(cci5, "#.##") + " | CCI(20): " + tostring(cci20, "#.##") + (cciCheck ? " βœ…" : ""), text_color=color.orange, bgcolor=color.black) //table.cell(signalPanel, 0, 3, "Status: " + (dashboardSignal ? "πŸ”₯ All Aligned" : "Waiting..."), text_color=color.white, bgcolor=color.black) table.cell(signalPanel, 0, 4, "Signal Strength: " + tostring(signalStrength), text_color=color.white, bgcolor=strengthColor) table.cell(signalPanel, 0, 5, "Action: " + actionText, text_color=color.white, bgcolor=color.gray) table.cell(signalPanel, 0, 6, "Confidence: " + tostring(confidenceText) + "% | " , text_color=color.white, bgcolor=color.navy) //table.cell(signalPanel2, 0, 7, "Wave: " + tostring(waveCount) + " | Flip: " + (flip ? "βœ…" : "β€”"), text_color=color.white, bgcolor=color.black) alertcondition(signalStrength >= 80, title="πŸ”₯ Strong Signal Alert", message="Signal strength is high ({{signalStrength}}) on {{ticker}} β€” consider tactical entry.") alertcondition(confidence >= 80, title="βœ… High Confidence Alert", message="Confidence score is high ({{confidence}}%) on {{ticker}} β€” indicators are aligned.") alertcondition(signalStrength >= 80 and confidence >= 80, title="πŸ”₯βœ… Strong + Confident Signal", message="High signal strength and confidence on {{ticker}} β€” tactical setup confirmed.")