커뮤니티

지표 변환 부탁드립니다.

프로필 이미지
삼손감자
2025-05-15 14:02:06
570
글번호 190852
답변완료
//@version=6 //----------------------------------------------------------------------------- // NeuroTrend &#8211; Adaptive AI Trend Engine // //: // NeuroTrend is an adaptive, AI-assisted trend indicator designed for momentum // and swing trading. It uses dynamic EMAs, slope forecasting, neural memory, // and a trend classification engine to deliver real-time insights. The system // includes confidence scoring, reversal detection, and a premium visual dashboard. // // Key Features: // &#8226; Adaptive EMA smoothing based on volatility and momentum conditions // &#8226; Real-time slope angle, power, and projected trend forecasts // &#8226; Neural memory system for volatility-aware threshold calibration // &#8226; Classification of trend phases: Impulse, Cooling, Reversal, Stall, Neutral // &#8226; Confidence score derived from DMI, slope, and volatility ratio // &#8226; Reversal and stall zone detection with alert labeling // &#8226; AI-style commentary with smart coaching logic // &#8226; Compact dashboard with all trend diagnostics in one view // // Usage: // Best used to time entries // into strong trend conditions, confirm trend continuation, or detect exhaustion // before reversals. // // Author: AresIQ // License: Mozilla Public License 2.0 // Terms: This open-source 스크립트 may be modified and reused with attribution. // // Link to License: https://www.mozilla.org/en-US/MPL/2.0/ //----------------------------------------------------------------------------- indicator("NeuroTrend", overlay=true) // USER INPUTS ₩₩ enableReflex = input.bool(false, "Enable Reflex Mode", inline="reflex", group="Turbo Mode") showCommentary = input.bool(true, "Show AI Commentary", inline="ai", group="Neuro Settings") tablePosition = input.string("Top Right", "Dashboard Position", options=["Top Left", "Top Middle", "Top Right", "Bottom Left", "Bottom Middle", "Bottom Right"], group="Neuro Settings") pos = tablePosition == "Top Left" ? position.top_left : tablePosition == "Top Middle" ? position.top_center : tablePosition == "Top Right" ? position.top_right : tablePosition == "Bottom Left" ? position.bottom_left : tablePosition == "Bottom Middle" ? position.bottom_center : position.bottom_right commentaryTextColor = input.color(color.white, "Commentary Text Color", inline="commentaryColor", group="Neuro Settings") tableTextColor = input.color(color.white, "Dashboard Text Color", group="Neuro Settings") baseFast = input.int(10, "Base Fast EMA") baseSlow = input.int(21, "Base Slow EMA") showConfidence = input.bool(true, "Show Confidence Score", inline="conf", group="Neuro Settings") showReversal = input.bool(true, "Show Reversal Warnings", inline="rev", group="Neuro Settings") showStall = input.bool(true, "Show Stall Alerts", inline="stall", group="Neuro Settings") showProjection = input.bool(true, "Show Slope Projection", inline="proj", group="Neuro Settings") enableAlerts = input.bool(true, "Enable Smart Alerts", inline="alerts", group="Alerts") // CUSTOM ALERT BUILDER ₩₩ customEnableAlerts = input.bool(false, "Enable Custom Alerts", group="Alerts") customMinConfidence = input.int(60, "Min Confidence", minval=0, maxval=100, group="Alerts") customRequireImpulse = input.bool(true, "Require Impulse", group="Alerts") customRequireBullish = input.bool(false, "Only Bullish Trends", group="Alerts") customRequireBearish = input.bool(false, "Only Bearish Trends", group="Alerts") customBlockReversal = input.bool(true, "Ignore Reversal Risk", group="Alerts") customBlockStall = input.bool(false, "Ignore Stall", group="Alerts") // SESSION PHASE DETECTION ₩₩ hourNow = hour(time) minuteNow = minute(time) sessionMinute = (hourNow - 9) * 60 + minuteNow - 30 // 0 at 9:30 AM sessionPhase = sessionMinute < 90 ? "&#9200; Morning Drive" : sessionMinute < 270 ? "&#128564; Midday Drift" : sessionMinute <= 390 ? "&#9889; Power Hour" : "&#9203; After Hours" // CONTEXT ₩₩ atr = ta.atr(14) rsi = ta.rsi(close, 14) volFactor = atr / close momentumFactor = (rsi - 50) / 100 // ADAPTIVE LENGTHS ₩₩ fastLen = enableReflex ? baseFast * 0.75 : baseFast - volFactor * 5 + momentumFactor * 5 slowLen = enableReflex ? baseSlow * 0.85 : baseSlow + volFactor * 5 - momentumFactor * 5 alphaFast = 2.0 / (fastLen + 1.0) alphaSlow = 2.0 / (slowLen + 1.0) // ADAPTIVE EMA FUNCTION ₩₩ adaptiveEMA(src, alpha) => var float result = na result := na(result[1]) ? src : alpha * src + (1 - alpha) * result[1] // EMAS ₩₩ emaFast = adaptiveEMA(close, alphaFast) emaSlow = adaptiveEMA(close, alphaSlow) // SLOPE METRICS ₩₩ slopeDeg = math.atan(emaFast - emaSlow) * 180 / math.pi slopePower = enableReflex ? slopeDeg * (1 + volFactor * 0.5 + momentumFactor * 1.5) : slopeDeg * (1 + volFactor + momentumFactor) glowIntensity = math.min(math.abs(slopePower), 50) // COLOR ENGINE ₩₩ baseColor = slopePower > 0 ? color.rgb(38, 230, 0) : color.rgb(168, 45, 36) // RENDER LAYERS ₩₩ glowBase = slopePower > 0 ? color.rgb(80, 255, 100) : color.rgb(255, 70, 70) coreColor = color.new(glowBase, 0) glow1 = color.new(glowBase, 75) glow2 = color.new(glowBase, 85) shadowTrail = color.new(glowBase, 92) plot(emaFast, title="Fast EMA Core", color=coreColor, linewidth=3) plot(emaFast, title="Glow Layer 1", color=glow1, linewidth=6) plot(emaFast, title="Glow Layer 2", color=glow2, linewidth=9) plot(emaSlow, title="Slow EMA", color=color.new(glowBase, 80), linewidth=2) plot(emaFast[5], title="Shadow Trail", color=shadowTrail, linewidth=1, style=plot.style_line) // FILLS ₩₩ fill(plot(emaFast), plot(emaSlow), color=color.new(glowBase, 90), title="Trend Ribbon Fill") // NEURAL MEMORY ENGINE ₩₩ atrMemory = ta.sma(atr, enableReflex ? 20 : 50) slopeStdDev = ta.stdev(slopePower, enableReflex ? 20 : 50) volatilityState = (atr / atrMemory + slopeStdDev / 30) / 2 volatilityFactor = math.min(math.max(volatilityState, 0.5), 1.5) // Auto-calibrated thresholds impulseThreshold = 40 * volatilityFactor coolingThreshold = 20 * volatilityFactor stallSlopeLimit = 10 * volatilityFactor rsiFlatMin = 48 - (5 * (volatilityFactor - 1)) rsiFlatMax = 52 + (5 * (volatilityFactor - 1)) // TREND STATE CLASSIFIER ₩₩ isImpulse = math.abs(slopePower) > impulseThreshold isCooling = math.abs(slopePower) > coolingThreshold and math.abs(slopePower) <= impulseThreshold isNeutral = math.abs(slopePower) <= 20 isReversal = ta.change(slopeDeg, 1) < -30 or ta.rsi(close, 14) < 40 trendDir = slopePower > 0 ? "Bullish" : "Bearish" // TREND AGE & DECAY ₩₩ var int trendAge = 0 trendAge := trendDir == trendDir[1] ? trendAge + 1 : 1 decayFactor = math.max(1.0 - trendAge / 100, 0.5) // Caps decay at 50% trendColor = slopePower > 0 ? color.lime : color.red phaseText = isImpulse ? "&#128293; Impulse" : isCooling ? "&#127744; Cooling" : isReversal ? "&#9888;&#65039; Reversal Risk" : "&#9940; Neutral" // PHASE MEMORY ENGINE ₩₩ var string prevPhase = na phaseChanged = not na(prevPhase) and phaseText != prevPhase prevPhase := phaseText slopeScore = math.round(math.abs(slopePower) * 2) // CONFIDENCE SCORING ENGINE ₩₩ [plusDI, minusDI, adx] = ta.dmi(14, 14) trendStrength = math.min(adx, 50) / 50 directionBias = math.abs(plusDI - minusDI) / 100 volatilityRatio = math.min(atr / math.abs(emaFast - emaSlow), 3.0) / 3.0 slopeNorm = math.min(math.abs(slopePower), 50) / 50 // CONFIDENCE SCORE ₩₩ confidenceRaw = (trendStrength + directionBias + slopeNorm + (1 - volatilityRatio)) / 4 confidenceScore = math.round(confidenceRaw * 100 * decayFactor) confidenceLabel = confidenceScore >= 75 ? "High" : confidenceScore >= 50 ? "Medium" : "Low" // REVERSAL SENSOR ENGINE ₩₩ slopeFlipping = ta.change(math.sign(slopePower)) != 0 slopeCollapsing = math.abs(slopePower) < 10 rsiDro*pping = rsi < 45 reversalRisk = (slopeFlipping and slopeCollapsing) or (rsiDro*pping and slopePower < 0) // REVERSE SYMMETRY ₩₩ isBullishReversal = reversalRisk and slopePower > 30 and close > emaFast and close > emaSlow isBearishReversal = reversalRisk and slopePower < -30 and close < emaFast and close < emaSlow isReversingNow = isBullishReversal or isBearishReversal reversalLabel = isBullishReversal ? "&#128640; Bullish Reversal" : isBearishReversal ? "&#128680; Bearish Reversal" : reversalRisk ? "&#9888;&#65039; Reversal Threat" : "&#9989; Stable" // RECOVERY DETECTION ENGINE ₩₩ wasBearish = trendDir[1] == "Bearish" emaCrossover = close > emaFast and close[1] < emaFast[1] and close > emaSlow recoveryBounce = isBullishReversal and wasBearish and emaCrossover // STALL DETECTOR ENGINE ₩₩ slopeLow = math.abs(slopePower) < stallSlopeLimit rsiFlat = rsi > rsiFlatMin and rsi < rsiFlatMax atrCompression = atr < ta.sma(atr, 20) stallDetected = rsiFlat and slopeLow and atrCompression stallLabel = stallDetected ? "&#128721; Dead Zone" : "&#9989; Active" // SLOPE PROJECTION ENGINE ₩₩ slopeNow = slopeDeg slopePrev = math.atan(emaFast[1] - emaSlow[1]) * 180 / math.pi slopeDelta = slopeNow - slopePrev slopeAccel = slopeDelta - (slopePrev - math.atan(emaFast[2] - emaSlow[2]) * 180 / math.pi) slopeForecast = slopeNow + slopeDelta + slopeAccel // ADAPTIVE SLOPE CLAMPING ENGINE ₩₩ baseClamp = 45.0 dynamicRange = 15.0 forecastVolatilityFactor = math.min(math.max((atr / ta.sma(atr, 50) + ta.stdev(slopePower, 50) / 30) / 2, 0.5), 1.5) adaptiveClamp = baseClamp + (forecastVolatilityFactor - 1.0) * dynamicRange slopeForecastClamped = math.max(math.min(slopeForecast, adaptiveClamp), -adaptiveClamp) // SLOPE PROJECTION CONFIDENCE ₩₩ slopeMomentum = math.abs(slopeAccel) forecastConfidence = slopeMomentum > 2.5 ? "High" : slopeMomentum > 1.0 ? "Medium" : "Low" projectionLabel = slopeForecastClamped > 15 ? "&#128200; Rising" : slopeForecastClamped < -15 ? "&#128201; Falling" : "&#10134; Sideways" projectionValue = " (" + str.tostring(math.round(slopeForecastClamped)) + "°, " + forecastConfidence + " Confidence)" // MOMENTUM FADING DETECTION ₩₩ slopeFading = ta.change(slopePower) < 0 and not stallDetected and not reversalRisk and math.abs(slopePower) > 15 momentumFading = slopeFading and slopePower[1] > slopePower[2] and slopePower > 10 // SMART ENTRY WINDOW DETECTION ₩₩ impulseActive = isImpulse and slopePower > 20 and confidenceScore >= 60 pulledBack = close[1] < emaFast[1] and close > emaFast and low < emaFast smartEntryWindow = impulseActive and pulledBack plotshape(smartEntryWindow, title="Smart Entry", location=location.belowbar, style=shape.triangleup, size=size.small, color=color.teal) // COMMENTARY GENERATOR ₩₩ aiCommentary = phaseChanged ? "&#128260; Phase Shift: " + prevPhase + " → " + phaseText : recoveryBounce ? "&#128257; Recovery rally &#8212; bounce reclaiming trend structure. (" + sessionPhase + ")" : smartEntryWindow ? "&#127919; Smart entry window &#8212; impulse pullback with reclaim. (" + sessionPhase + ")" : momentumFading ? "&#129707; Momentum weakening &#8212; trend may lose steam soon. (" + sessionPhase + ")" : isImpulse and confidenceScore >= 75 and not reversalRisk ? "&#128200; Strong trend forming &#8212; consider riding momentum. (" + sessionPhase + ")" : isCooling and confidenceScore >= 50 ? "&#127744; Trend slowing &#8212; caution if already in position. (" + sessionPhase + ")" : stallDetected and not isImpulse ? "&#9208;&#65039; Price stalling &#8212; this is not the time to enter. (" + sessionPhase + ")" : isBullishReversal ? "&#128640; Bullish reversal confirmed &#8212; breakout in progress. (" + sessionPhase + ")" : isBearishReversal ? "&#128680; Bearish reversal confirmed &#8212; breakdown in progress. (" + sessionPhase + ")" : reversalRisk and confidenceScore < 50 ? "&#9888;&#65039; Reversal threat building &#8212; watch for breakdown or bounce. (" + sessionPhase + ")" : confidenceScore < 30 ? "&#129514; Low conviction trend &#8212; better to wait for clarity. (" + sessionPhase + ")" : "&#10134; Trend steady &#8212; no action required right now. (" + sessionPhase + ")" var label commentaryLabel = na if showCommentary and not na(high) if not na(commentaryLabel) label.delete(commentaryLabel) commentaryLabel := showCommentary and not na(high) ? label.new(bar_index, math.max(high, high[1], high[2]) + atr * 1.5, aiCommentary, xloc.bar_index, yloc.price, style=label.style_label_center, size=size.normal, textcolor=commentaryTextColor, color=color.new(#eece89, 85), textalign=text.align_center, tooltip="NeuroTrend Commentary") : commentaryLabel // DASHBOARD RENDERING ₩₩ var table dashboard = table.new(pos, 7, 2, border_width=1, frame_color=color.new(color.white, 90), bgcolor=color.new(color.navy, 95)) if bar_index % 5 == 0 table.cell(dashboard, 0, 0, "&#129504; Phase", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 0, 1, phaseText, text_color=tableTextColor, bgcolor=color.new(trendColor, 20), text_size=size.small) table.cell(dashboard, 1, 0, "&#128200; Direction", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 1, 1, trendDir, text_color=tableTextColor, bgcolor=color.new(trendColor, 10), text_size=size.small) table.cell(dashboard, 2, 0, "&#128267; Slope Power", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 2, 1, str.tostring(slopeScore) + " / 100", text_color=tableTextColor, bgcolor=color.new(trendColor, 85), text_size=size.small) if showConfidence table.cell(dashboard, 3, 0, "&#129504; Confidence", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 3, 1, confidenceLabel + " (" + str.tostring(confidenceScore) + ")", text_color=tableTextColor, bgcolor=color.new(trendColor, 80), text_size=size.small) if showReversal table.cell(dashboard, 4, 0, "&#128680; Reversal Risk", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 4, 1, reversalLabel, text_color=tableTextColor, bgcolor=reversalRisk ? color.new(color.red, 60) : color.new(color.green, 80), text_size=size.small) if showStall table.cell(dashboard, 5, 0, "&#9208;&#65039; Momentum", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 5, 1, stallLabel, text_color=tableTextColor, bgcolor=stallDetected ? color.new(color.orange, 60) : color.new(color.green, 80), text_size=size.small) if showProjection table.cell(dashboard, 6, 0, "&#128225; Projection", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 6, 1, projectionLabel + projectionValue, text_color=tableTextColor, bgcolor=color.new(trendColor, 70), text_size=size.small) // SMART ALERT CONDITION ₩₩ customAlertCondition = customEnableAlerts and confidenceScore >= customMinConfidence and (not customRequireImpulse or isImpulse) and (not customRequireBullish or slopePower > 0) and (not customRequireBearish or slopePower < 0) and (not customBlockReversal or not reversalRisk) and (not customBlockStall or not stallDetected) alertcondition(customAlertCondition, title="Custom NeuroTrend Alert", message="&#128276; NeuroTrend: Your custom alert conditions have been met.") // BUY / SELL SIGNAL LABELS ₩₩ showBuySellLabels = input.bool(true, "Show Buy/Sell Labels", group="Neuro Settings") buySignal = ta.crossover(slopeDeg, 0) and slopePower > 0 sellSignal = ta.crossunder(slopeDeg, 0) and slopePower < 0 if showBuySellLabels if buySignal label.new(bar_index, low, "BUY", style=label.style_label_up, color=color.green, textcolor=color.white, yloc=yloc.belowbar) if sellSignal label.new(bar_index, high, "SELL", style=label.style_label_down, color=color.red, textcolor=color.white, yloc=yloc.abovebar)
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-05-16 13:49:20

안녕하세요 예스스탁입니다. 지표만 표시되게 작성해 드립니다. input : enableReflex(false); input : baseFast(10); input : baseSlow(21); input : showConfidence(true); input : showReversal(true); input : showStall(true); input : showProjection(true); input : enableAlerts(true); input : customEnableAlerts(false); input : customMinConfidence(60); input : customRequireImpulse(true); input : customRequireBullish(false); input : customRequireBearish(false); input : customBlockReversal(true); input : customBlockStall(false); var : alpha(0),A(0),R(0),volFactor(0),momentumFactor(0); var : fastLen(0),slowLen(0),alphaFast(0),alphaSlow(0),emaFast(0),emaSlow(0); var : slopeDeg(0),slopePower(0),glowIntensity(0),baseColor(0); var : glowBase(0),coreColor(0),glow1(0),glow2(0),shadowTrail(0); alpha = 1 / 14; A = IFf(IsNan(A[1]) == true, ma(TrueRange,14) , alpha * TrueRange + (1 - alpha) * IFf(isnan(A[1])==true,0,A[1])); R = rsi(14); volFactor = A / close; momentumFactor = (R - 50) / 100; fastLen = iff(enableReflex , baseFast * 0.75 , baseFast - volFactor * 5 + momentumFactor * 5); slowLen = iff(enableReflex , baseSlow * 0.85 , baseSlow + volFactor * 5 - momentumFactor * 5); alphaFast = 2.0 / (fastLen + 1.0); alphaSlow = 2.0 / (slowLen + 1.0); emaFast = iff(IsNan(emaFast[1]) == true , close , alphaFast * close + (1 - alphaFast) * emaFast[1]); emaSlow = iff(IsNan(emaSlow[1]) == true , close , alphaSlow * close + (1 - alphaSlow) * emaSlow[1]); slopeDeg = atan(emaFast - emaSlow) * 180 / pie; slopePower = iff(enableReflex , slopeDeg * (1 + volFactor * 0.5 + momentumFactor * 1.5) , slopeDeg * (1 + volFactor + momentumFactor)); glowIntensity = min(abs(slopePower), 50); baseColor = iff(slopePower > 0 , rgb(38, 230, 0) , rgb(168, 45, 36)); glowBase = iff(slopePower > 0 , rgb(80, 255, 100) , rgb(255, 70, 70)); coreColor = glowBase; glow1 = glowBase; glow2 = glowBase; shadowTrail = glowBase; plot1(emaFast, "Fast EMA Core", coreColor); plot2(emaSlow, "Slow EMA", glowBase); plot3(emaFast[5], "Shadow Trail", shadowTrail); input : showBuySellLabels(true); var : buySignal(False),sellSignal(False),tx(0); buySignal = crossup(slopeDeg, 0) and slopePower > 0; sellSignal = CrossDown(slopeDeg, 0) and slopePower < 0; if showBuySellLabels Then { if buySignal then { tx = text_new(sdate,sTime,Low,"▲"); Text_SetStyle(tx,2,0); Text_SetColor(tx,Green); Text_SetSize(tx,20); } if sellSignal Then { tx = text_new(sdate,sTime,Low,"▼"); Text_SetStyle(tx,2,1); Text_SetColor(tx,Red); Text_SetSize(tx,20); } } 즐거운 하루되세요 > 삼손감자 님이 쓴 글입니다. > 제목 : 지표 변환 부탁드립니다. > //@version=6 //----------------------------------------------------------------------------- // NeuroTrend &#8211; Adaptive AI Trend Engine // //: // NeuroTrend is an adaptive, AI-assisted trend indicator designed for momentum // and swing trading. It uses dynamic EMAs, slope forecasting, neural memory, // and a trend classification engine to deliver real-time insights. The system // includes confidence scoring, reversal detection, and a premium visual dashboard. // // Key Features: // &#8226; Adaptive EMA smoothing based on volatility and momentum conditions // &#8226; Real-time slope angle, power, and projected trend forecasts // &#8226; Neural memory system for volatility-aware threshold calibration // &#8226; Classification of trend phases: Impulse, Cooling, Reversal, Stall, Neutral // &#8226; Confidence score derived from DMI, slope, and volatility ratio // &#8226; Reversal and stall zone detection with alert labeling // &#8226; AI-style commentary with smart coaching logic // &#8226; Compact dashboard with all trend diagnostics in one view // // Usage: // Best used to time entries // into strong trend conditions, confirm trend continuation, or detect exhaustion // before reversals. // // Author: AresIQ // License: Mozilla Public License 2.0 // Terms: This open-source 스크립트 may be modified and reused with attribution. // // Link to License: https://www.mozilla.org/en-US/MPL/2.0/ //----------------------------------------------------------------------------- indicator("NeuroTrend", overlay=true) // USER INPUTS ₩₩ enableReflex = input.bool(false, "Enable Reflex Mode", inline="reflex", group="Turbo Mode") showCommentary = input.bool(true, "Show AI Commentary", inline="ai", group="Neuro Settings") tablePosition = input.string("Top Right", "Dashboard Position", options=["Top Left", "Top Middle", "Top Right", "Bottom Left", "Bottom Middle", "Bottom Right"], group="Neuro Settings") pos = tablePosition == "Top Left" ? position.top_left : tablePosition == "Top Middle" ? position.top_center : tablePosition == "Top Right" ? position.top_right : tablePosition == "Bottom Left" ? position.bottom_left : tablePosition == "Bottom Middle" ? position.bottom_center : position.bottom_right commentaryTextColor = input.color(color.white, "Commentary Text Color", inline="commentaryColor", group="Neuro Settings") tableTextColor = input.color(color.white, "Dashboard Text Color", group="Neuro Settings") baseFast = input.int(10, "Base Fast EMA") baseSlow = input.int(21, "Base Slow EMA") showConfidence = input.bool(true, "Show Confidence Score", inline="conf", group="Neuro Settings") showReversal = input.bool(true, "Show Reversal Warnings", inline="rev", group="Neuro Settings") showStall = input.bool(true, "Show Stall Alerts", inline="stall", group="Neuro Settings") showProjection = input.bool(true, "Show Slope Projection", inline="proj", group="Neuro Settings") enableAlerts = input.bool(true, "Enable Smart Alerts", inline="alerts", group="Alerts") // CUSTOM ALERT BUILDER ₩₩ customEnableAlerts = input.bool(false, "Enable Custom Alerts", group="Alerts") customMinConfidence = input.int(60, "Min Confidence", minval=0, maxval=100, group="Alerts") customRequireImpulse = input.bool(true, "Require Impulse", group="Alerts") customRequireBullish = input.bool(false, "Only Bullish Trends", group="Alerts") customRequireBearish = input.bool(false, "Only Bearish Trends", group="Alerts") customBlockReversal = input.bool(true, "Ignore Reversal Risk", group="Alerts") customBlockStall = input.bool(false, "Ignore Stall", group="Alerts") // SESSION PHASE DETECTION ₩₩ hourNow = hour(time) minuteNow = minute(time) sessionMinute = (hourNow - 9) * 60 + minuteNow - 30 // 0 at 9:30 AM sessionPhase = sessionMinute < 90 ? "&#9200; Morning Drive" : sessionMinute < 270 ? "&#128564; Midday Drift" : sessionMinute <= 390 ? "&#9889; Power Hour" : "&#9203; After Hours" // CONTEXT ₩₩ atr = ta.atr(14) rsi = ta.rsi(close, 14) volFactor = atr / close momentumFactor = (rsi - 50) / 100 // ADAPTIVE LENGTHS ₩₩ fastLen = enableReflex ? baseFast * 0.75 : baseFast - volFactor * 5 + momentumFactor * 5 slowLen = enableReflex ? baseSlow * 0.85 : baseSlow + volFactor * 5 - momentumFactor * 5 alphaFast = 2.0 / (fastLen + 1.0) alphaSlow = 2.0 / (slowLen + 1.0) // ADAPTIVE EMA FUNCTION ₩₩ adaptiveEMA(src, alpha) => var float result = na result := na(result[1]) ? src : alpha * src + (1 - alpha) * result[1] // EMAS ₩₩ emaFast = adaptiveEMA(close, alphaFast) emaSlow = adaptiveEMA(close, alphaSlow) // SLOPE METRICS ₩₩ slopeDeg = math.atan(emaFast - emaSlow) * 180 / math.pi slopePower = enableReflex ? slopeDeg * (1 + volFactor * 0.5 + momentumFactor * 1.5) : slopeDeg * (1 + volFactor + momentumFactor) glowIntensity = math.min(math.abs(slopePower), 50) // COLOR ENGINE ₩₩ baseColor = slopePower > 0 ? color.rgb(38, 230, 0) : color.rgb(168, 45, 36) // RENDER LAYERS ₩₩ glowBase = slopePower > 0 ? color.rgb(80, 255, 100) : color.rgb(255, 70, 70) coreColor = color.new(glowBase, 0) glow1 = color.new(glowBase, 75) glow2 = color.new(glowBase, 85) shadowTrail = color.new(glowBase, 92) plot(emaFast, title="Fast EMA Core", color=coreColor, linewidth=3) plot(emaFast, title="Glow Layer 1", color=glow1, linewidth=6) plot(emaFast, title="Glow Layer 2", color=glow2, linewidth=9) plot(emaSlow, title="Slow EMA", color=color.new(glowBase, 80), linewidth=2) plot(emaFast[5], title="Shadow Trail", color=shadowTrail, linewidth=1, style=plot.style_line) // FILLS ₩₩ fill(plot(emaFast), plot(emaSlow), color=color.new(glowBase, 90), title="Trend Ribbon Fill") // NEURAL MEMORY ENGINE ₩₩ atrMemory = ta.sma(atr, enableReflex ? 20 : 50) slopeStdDev = ta.stdev(slopePower, enableReflex ? 20 : 50) volatilityState = (atr / atrMemory + slopeStdDev / 30) / 2 volatilityFactor = math.min(math.max(volatilityState, 0.5), 1.5) // Auto-calibrated thresholds impulseThreshold = 40 * volatilityFactor coolingThreshold = 20 * volatilityFactor stallSlopeLimit = 10 * volatilityFactor rsiFlatMin = 48 - (5 * (volatilityFactor - 1)) rsiFlatMax = 52 + (5 * (volatilityFactor - 1)) // TREND STATE CLASSIFIER ₩₩ isImpulse = math.abs(slopePower) > impulseThreshold isCooling = math.abs(slopePower) > coolingThreshold and math.abs(slopePower) <= impulseThreshold isNeutral = math.abs(slopePower) <= 20 isReversal = ta.change(slopeDeg, 1) < -30 or ta.rsi(close, 14) < 40 trendDir = slopePower > 0 ? "Bullish" : "Bearish" // TREND AGE & DECAY ₩₩ var int trendAge = 0 trendAge := trendDir == trendDir[1] ? trendAge + 1 : 1 decayFactor = math.max(1.0 - trendAge / 100, 0.5) // Caps decay at 50% trendColor = slopePower > 0 ? color.lime : color.red phaseText = isImpulse ? "&#128293; Impulse" : isCooling ? "&#127744; Cooling" : isReversal ? "&#9888;&#65039; Reversal Risk" : "&#9940; Neutral" // PHASE MEMORY ENGINE ₩₩ var string prevPhase = na phaseChanged = not na(prevPhase) and phaseText != prevPhase prevPhase := phaseText slopeScore = math.round(math.abs(slopePower) * 2) // CONFIDENCE SCORING ENGINE ₩₩ [plusDI, minusDI, adx] = ta.dmi(14, 14) trendStrength = math.min(adx, 50) / 50 directionBias = math.abs(plusDI - minusDI) / 100 volatilityRatio = math.min(atr / math.abs(emaFast - emaSlow), 3.0) / 3.0 slopeNorm = math.min(math.abs(slopePower), 50) / 50 // CONFIDENCE SCORE ₩₩ confidenceRaw = (trendStrength + directionBias + slopeNorm + (1 - volatilityRatio)) / 4 confidenceScore = math.round(confidenceRaw * 100 * decayFactor) confidenceLabel = confidenceScore >= 75 ? "High" : confidenceScore >= 50 ? "Medium" : "Low" // REVERSAL SENSOR ENGINE ₩₩ slopeFlipping = ta.change(math.sign(slopePower)) != 0 slopeCollapsing = math.abs(slopePower) < 10 rsiDro*pping = rsi < 45 reversalRisk = (slopeFlipping and slopeCollapsing) or (rsiDro*pping and slopePower < 0) // REVERSE SYMMETRY ₩₩ isBullishReversal = reversalRisk and slopePower > 30 and close > emaFast and close > emaSlow isBearishReversal = reversalRisk and slopePower < -30 and close < emaFast and close < emaSlow isReversingNow = isBullishReversal or isBearishReversal reversalLabel = isBullishReversal ? "&#128640; Bullish Reversal" : isBearishReversal ? "&#128680; Bearish Reversal" : reversalRisk ? "&#9888;&#65039; Reversal Threat" : "&#9989; Stable" // RECOVERY DETECTION ENGINE ₩₩ wasBearish = trendDir[1] == "Bearish" emaCrossover = close > emaFast and close[1] < emaFast[1] and close > emaSlow recoveryBounce = isBullishReversal and wasBearish and emaCrossover // STALL DETECTOR ENGINE ₩₩ slopeLow = math.abs(slopePower) < stallSlopeLimit rsiFlat = rsi > rsiFlatMin and rsi < rsiFlatMax atrCompression = atr < ta.sma(atr, 20) stallDetected = rsiFlat and slopeLow and atrCompression stallLabel = stallDetected ? "&#128721; Dead Zone" : "&#9989; Active" // SLOPE PROJECTION ENGINE ₩₩ slopeNow = slopeDeg slopePrev = math.atan(emaFast[1] - emaSlow[1]) * 180 / math.pi slopeDelta = slopeNow - slopePrev slopeAccel = slopeDelta - (slopePrev - math.atan(emaFast[2] - emaSlow[2]) * 180 / math.pi) slopeForecast = slopeNow + slopeDelta + slopeAccel // ADAPTIVE SLOPE CLAMPING ENGINE ₩₩ baseClamp = 45.0 dynamicRange = 15.0 forecastVolatilityFactor = math.min(math.max((atr / ta.sma(atr, 50) + ta.stdev(slopePower, 50) / 30) / 2, 0.5), 1.5) adaptiveClamp = baseClamp + (forecastVolatilityFactor - 1.0) * dynamicRange slopeForecastClamped = math.max(math.min(slopeForecast, adaptiveClamp), -adaptiveClamp) // SLOPE PROJECTION CONFIDENCE ₩₩ slopeMomentum = math.abs(slopeAccel) forecastConfidence = slopeMomentum > 2.5 ? "High" : slopeMomentum > 1.0 ? "Medium" : "Low" projectionLabel = slopeForecastClamped > 15 ? "&#128200; Rising" : slopeForecastClamped < -15 ? "&#128201; Falling" : "&#10134; Sideways" projectionValue = " (" + str.tostring(math.round(slopeForecastClamped)) + "°, " + forecastConfidence + " Confidence)" // MOMENTUM FADING DETECTION ₩₩ slopeFading = ta.change(slopePower) < 0 and not stallDetected and not reversalRisk and math.abs(slopePower) > 15 momentumFading = slopeFading and slopePower[1] > slopePower[2] and slopePower > 10 // SMART ENTRY WINDOW DETECTION ₩₩ impulseActive = isImpulse and slopePower > 20 and confidenceScore >= 60 pulledBack = close[1] < emaFast[1] and close > emaFast and low < emaFast smartEntryWindow = impulseActive and pulledBack plotshape(smartEntryWindow, title="Smart Entry", location=location.belowbar, style=shape.triangleup, size=size.small, color=color.teal) // COMMENTARY GENERATOR ₩₩ aiCommentary = phaseChanged ? "&#128260; Phase Shift: " + prevPhase + " → " + phaseText : recoveryBounce ? "&#128257; Recovery rally &#8212; bounce reclaiming trend structure. (" + sessionPhase + ")" : smartEntryWindow ? "&#127919; Smart entry window &#8212; impulse pullback with reclaim. (" + sessionPhase + ")" : momentumFading ? "&#129707; Momentum weakening &#8212; trend may lose steam soon. (" + sessionPhase + ")" : isImpulse and confidenceScore >= 75 and not reversalRisk ? "&#128200; Strong trend forming &#8212; consider riding momentum. (" + sessionPhase + ")" : isCooling and confidenceScore >= 50 ? "&#127744; Trend slowing &#8212; caution if already in position. (" + sessionPhase + ")" : stallDetected and not isImpulse ? "&#9208;&#65039; Price stalling &#8212; this is not the time to enter. (" + sessionPhase + ")" : isBullishReversal ? "&#128640; Bullish reversal confirmed &#8212; breakout in progress. (" + sessionPhase + ")" : isBearishReversal ? "&#128680; Bearish reversal confirmed &#8212; breakdown in progress. (" + sessionPhase + ")" : reversalRisk and confidenceScore < 50 ? "&#9888;&#65039; Reversal threat building &#8212; watch for breakdown or bounce. (" + sessionPhase + ")" : confidenceScore < 30 ? "&#129514; Low conviction trend &#8212; better to wait for clarity. (" + sessionPhase + ")" : "&#10134; Trend steady &#8212; no action required right now. (" + sessionPhase + ")" var label commentaryLabel = na if showCommentary and not na(high) if not na(commentaryLabel) label.delete(commentaryLabel) commentaryLabel := showCommentary and not na(high) ? label.new(bar_index, math.max(high, high[1], high[2]) + atr * 1.5, aiCommentary, xloc.bar_index, yloc.price, style=label.style_label_center, size=size.normal, textcolor=commentaryTextColor, color=color.new(#eece89, 85), textalign=text.align_center, tooltip="NeuroTrend Commentary") : commentaryLabel // DASHBOARD RENDERING ₩₩ var table dashboard = table.new(pos, 7, 2, border_width=1, frame_color=color.new(color.white, 90), bgcolor=color.new(color.navy, 95)) if bar_index % 5 == 0 table.cell(dashboard, 0, 0, "&#129504; Phase", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 0, 1, phaseText, text_color=tableTextColor, bgcolor=color.new(trendColor, 20), text_size=size.small) table.cell(dashboard, 1, 0, "&#128200; Direction", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 1, 1, trendDir, text_color=tableTextColor, bgcolor=color.new(trendColor, 10), text_size=size.small) table.cell(dashboard, 2, 0, "&#128267; Slope Power", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 2, 1, str.tostring(slopeScore) + " / 100", text_color=tableTextColor, bgcolor=color.new(trendColor, 85), text_size=size.small) if showConfidence table.cell(dashboard, 3, 0, "&#129504; Confidence", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 3, 1, confidenceLabel + " (" + str.tostring(confidenceScore) + ")", text_color=tableTextColor, bgcolor=color.new(trendColor, 80), text_size=size.small) if showReversal table.cell(dashboard, 4, 0, "&#128680; Reversal Risk", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 4, 1, reversalLabel, text_color=tableTextColor, bgcolor=reversalRisk ? color.new(color.red, 60) : color.new(color.green, 80), text_size=size.small) if showStall table.cell(dashboard, 5, 0, "&#9208;&#65039; Momentum", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 5, 1, stallLabel, text_color=tableTextColor, bgcolor=stallDetected ? color.new(color.orange, 60) : color.new(color.green, 80), text_size=size.small) if showProjection table.cell(dashboard, 6, 0, "&#128225; Projection", text_color=tableTextColor, bgcolor=color.new(color.black, 85), text_size=size.small) table.cell(dashboard, 6, 1, projectionLabel + projectionValue, text_color=tableTextColor, bgcolor=color.new(trendColor, 70), text_size=size.small) // SMART ALERT CONDITION ₩₩ customAlertCondition = customEnableAlerts and confidenceScore >= customMinConfidence and (not customRequireImpulse or isImpulse) and (not customRequireBullish or slopePower > 0) and (not customRequireBearish or slopePower < 0) and (not customBlockReversal or not reversalRisk) and (not customBlockStall or not stallDetected) alertcondition(customAlertCondition, title="Custom NeuroTrend Alert", message="&#128276; NeuroTrend: Your custom alert conditions have been met.") // BUY / SELL SIGNAL LABELS ₩₩ showBuySellLabels = input.bool(true, "Show Buy/Sell Labels", group="Neuro Settings") buySignal = ta.crossover(slopeDeg, 0) and slopePower > 0 sellSignal = ta.crossunder(slopeDeg, 0) and slopePower < 0 if showBuySellLabels if buySignal label.new(bar_index, low, "BUY", style=label.style_label_up, color=color.green, textcolor=color.white, yloc=yloc.belowbar) if sellSignal label.new(bar_index, high, "SELL", style=label.style_label_down, color=color.red, textcolor=color.white, yloc=yloc.abovebar)