Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=6
- indicator(
- title = "Ash ICT CRT — Protocol Engine v20.9.1 Plot Fix",
- shorttitle = "Ash CRT Protocol v20.9.1",
- overlay = true,
- dynamic_requests = true,
- max_lines_count = 500,
- max_labels_count = 500
- )
- //======================================================================
- // 1. CORE CRT SETTINGS
- //======================================================================
- groupCore = "1. Core CRT Detection"
- useSelectedHours = input.bool(
- true,
- "Use Market-Specific CRT Time Protocol",
- group = groupCore,
- tooltip = "The time model is a quality protocol, not a mandatory trade signal. Daily, Weekly and Monthly candles automatically pass the time protocol."
- )
- marketTimeProfile = input.string(
- "Auto",
- "Market Time Profile",
- options = ["Auto", "Forex", "Indices", "Futures", "Crypto", "Commodities", "Manual"],
- group = groupCore,
- tooltip = "Auto uses TradingView symbol metadata and ticker keywords. Use a manual profile when a broker classifies the symbol differently."
- )
- timezoneInput = input.string(
- "America/New_York",
- "CRT Model Timezone",
- options = [
- "America/New_York",
- "Etc/UTC",
- "Europe/London",
- "Asia/Dubai",
- "Asia/Kolkata"
- ],
- group = groupCore
- )
- timeMatchToleranceHours = input.int(
- 0,
- "Time Match Tolerance (Hours)",
- minval = 0,
- maxval = 2,
- group = groupCore,
- tooltip = "0 requires an exact model-hour open. Increase to 1 for brokers whose 2H/3H candle alignment is shifted by one hour."
- )
- forexHour1 = input.int(1, "Forex Hour 1", minval = 0, maxval = 23, group = groupCore)
- forexHour2 = input.int(5, "Forex Hour 2", minval = 0, maxval = 23, group = groupCore)
- forexHour3 = input.int(9, "Forex Hour 3", minval = 0, maxval = 23, group = groupCore)
- indicesHour1 = input.int(2, "Indices Hour 1", minval = 0, maxval = 23, group = groupCore)
- indicesHour2 = input.int(6, "Indices Hour 2", minval = 0, maxval = 23, group = groupCore)
- indicesHour3 = input.int(10, "Indices Hour 3", minval = 0, maxval = 23, group = groupCore)
- futuresHour1 = input.int(2, "Futures Hour 1", minval = 0, maxval = 23, group = groupCore)
- futuresHour2 = input.int(6, "Futures Hour 2", minval = 0, maxval = 23, group = groupCore)
- futuresHour3 = input.int(10, "Futures Hour 3", minval = 0, maxval = 23, group = groupCore)
- cryptoHour1 = input.int(1, "Crypto Hour 1", minval = 0, maxval = 23, group = groupCore)
- cryptoHour2 = input.int(5, "Crypto Hour 2", minval = 0, maxval = 23, group = groupCore)
- cryptoHour3 = input.int(9, "Crypto Hour 3", minval = 0, maxval = 23, group = groupCore)
- commoditiesHour1 = input.int(1, "Commodities Hour 1", minval = 0, maxval = 23, group = groupCore)
- commoditiesHour2 = input.int(5, "Commodities Hour 2", minval = 0, maxval = 23, group = groupCore)
- commoditiesHour3 = input.int(9, "Commodities Hour 3", minval = 0, maxval = 23, group = groupCore)
- manualHour1 = input.int(1, "Manual Hour 1", minval = 0, maxval = 23, group = groupCore)
- manualHour2 = input.int(5, "Manual Hour 2", minval = 0, maxval = 23, group = groupCore)
- manualHour3 = input.int(9, "Manual Hour 3", minval = 0, maxval = 23, group = groupCore)
- requireCloseInside = input.bool(
- true,
- "Manipulation Must Close Back Inside Range",
- group = groupCore
- )
- rejectDoubleSweep = input.bool(
- true,
- "Reject Manipulation Sweeping Both Sides",
- group = groupCore
- )
- requireDirectionalClose = input.bool(
- false,
- "Require Directional Manipulation Close",
- group = groupCore,
- tooltip = "Bullish setup: manipulation candle must close bullish. Bearish setup: manipulation candle must close bearish."
- )
- //======================================================================
- // 2. PROTOCOL ENGINE
- //======================================================================
- groupProtocol = "2. Protocol Engine"
- minimumProtocols = input.int(
- 3,
- "Minimum Protocols Required",
- minval = 1,
- maxval = 9,
- group = groupProtocol,
- tooltip = "The blue/yellow sequence appears only when the setup passes at least this many enabled quality protocols."
- )
- useTimeProtocol = input.bool(true, "Protocol 1 — Valid CRT Time", group = groupProtocol)
- useKeyLevelProtocol = input.bool(true, "Protocol 2 — HTF Key-Level Interaction", group = groupProtocol)
- useRejectionProtocol = input.bool(true, "Protocol 3 — Strong Rejection Wick", group = groupProtocol)
- useMidpointProtocol = input.bool(true, "Protocol 4 — Midpoint Reclaim", group = groupProtocol)
- useRangeSizeProtocol = input.bool(true, "Protocol 5 — Controlled Range Size", group = groupProtocol)
- useBodyProtocol = input.bool(true, "Protocol 6 — Healthy Range Body", group = groupProtocol)
- usePOIProtocol = input.bool(true, "Protocol 7 — Directional HTF POI Confluence", group = groupProtocol, tooltip = "Requires POI direction to agree with the CRT purge direction. Bullish CRTs seek bullish POIs after sell-side purge; bearish CRTs seek bearish POIs after buy-side purge.")
- useHierarchyProtocol = input.bool(
- true,
- "Protocol 8 — Higher-Timeframe CRT Alignment",
- group = groupProtocol,
- tooltip = "Compares the candidate CRT direction with the latest confirmed structural CRT direction on its parent timeframe."
- )
- neutralHierarchyPass = input.bool(
- true,
- "Allow CRT When Parent Direction Is Neutral",
- group = groupProtocol
- )
- rejectOpposingHierarchy = input.bool(
- true,
- "Reject Opposing Parent CRT Direction",
- group = groupProtocol,
- tooltip = "Example: a bearish H1 CRT is rejected while the latest H4 CRT context remains bullish."
- )
- string groupLifecycle = "CRT Lifecycle Engine"
- lifecycleExpiryBars = input.int(
- 12,
- "Expire CRT After Bars",
- minval = 1,
- maxval = 100,
- group = groupLifecycle,
- tooltip = "An active CRT stops influencing hierarchy when its opposite-side target has not been reached within this many source-timeframe candles."
- )
- targetRequiresClose = input.bool(
- false,
- "Target Requires Candle Close",
- group = groupLifecycle,
- tooltip = "Off: touching the opposite side completes the CRT. On: price must close through the opposite side."
- )
- invalidationRequiresClose = input.bool(
- true,
- "Invalidation Requires Candle Close",
- group = groupLifecycle,
- tooltip = "Bullish CRT invalidates below the Range low; bearish CRT invalidates above the Range high. Keeping this enabled avoids wick-only invalidations."
- )
- replaceWithNewestCRT = input.bool(
- true,
- "Newest CRT Replaces Previous CRT",
- group = groupLifecycle,
- tooltip = "A newer qualified CRT on the same timeframe becomes the active lifecycle context."
- )
- // v19.8 Narrative Reset / Re-Arm controls
- enableNarrativeRearmEngine = input.bool(
- true,
- "Enable Narrative Reset / Re-Arm Engine",
- group = groupLifecycle,
- tooltip = "After a parent objective is completed, invalidated, or expired, execution remains stood down until a genuinely newer qualified parent CRT creates a fresh narrative."
- )
- rearmDisplayParentBars = input.int(
- 2,
- "Show RE-ARMED State for Parent Bars",
- minval = 1,
- maxval = 10,
- group = groupLifecycle,
- tooltip = "Controls how long the dashboard highlights the newly re-armed parent narrative after the fresh qualified parent CRT."
- )
- // v19.9 Narrative Transition Memory / Freshness controls
- enableNarrativeFreshnessEngine = input.bool(
- true,
- "Enable Narrative Transition Memory / Freshness Engine",
- group = groupLifecycle,
- tooltip = "Assigns a unique sequential identity to each qualified source-timeframe CRT. After a terminal story, only a later narrative identity can be treated as fresh and re-arm execution."
- )
- freshNarrativeDisplayBars = input.int(
- 4,
- "Fresh Narrative Highlight (Parent Bars)",
- minval = 1,
- maxval = 20,
- group = groupLifecycle,
- tooltip = "Number of parent-timeframe bars during which a newly created narrative is labelled FRESH. The narrative remains active afterward, but the freshness highlight ends."
- )
- // v20.0 Fresh Narrative Validation Engine
- enableFreshNarrativeValidation = input.bool(
- true,
- "Enable Fresh Narrative Validation Engine",
- group = groupLifecycle,
- tooltip = "A post-reset parent CRT must validate direction, HTF context, delivery, and an undelivered objective before execution can re-arm."
- )
- freshValidationWindowBars = input.int(
- 4,
- "Fresh Narrative Validation Window (Parent Bars)",
- minval = 1,
- maxval = 20,
- group = groupLifecycle,
- tooltip = "Maximum number of parent bars allowed for delivery confirmation. A fresh narrative that does not begin directional delivery inside this window is rejected."
- )
- requireFreshHierarchyAlignment = input.bool(
- true,
- "Require HTF Context Alignment",
- group = groupLifecycle,
- tooltip = "Rejects a fresh parent CRT when it opposes the active higher-timeframe structural CRT. Neutral higher-timeframe context is allowed."
- )
- requireFreshDeliveryConfirmation = input.bool(
- true,
- "Require Delivery Confirmation",
- group = groupLifecycle,
- tooltip = "Requires the existing displacement/delivery engine to confirm movement away from the manipulated side before execution re-arms."
- )
- // v20.3 Narrative Delivery & Objective Tracker
- enableNarrativeObjectiveTracker = input.bool(
- true,
- "Enable Narrative Delivery & Objective Tracker",
- group = groupLifecycle,
- tooltip = "Tracks whether the active fresh narrative is validating, delivering, approaching its objective, completed, invalidated, expired, or permanently rejected."
- )
- objectiveNearThresholdATR = input.float(
- 0.25,
- "Objective Near Threshold (ATR)",
- minval = 0.0,
- step = 0.05,
- group = groupLifecycle,
- tooltip = "The objective is labelled NEAR when price is within this ATR distance of the selected draw-on-liquidity target."
- )
- // Directional POI context controls
- poiLookback = input.int(
- 80,
- "POI Detection Lookback",
- minval = 10,
- maxval = 300,
- group = groupProtocol
- )
- poiToleranceATR = input.float(
- 0.05,
- "POI Touch Tolerance (ATR)",
- minval = 0.0,
- step = 0.01,
- group = groupProtocol
- )
- minimumPOITypes = input.int(
- 1,
- "Minimum Aligned POI Types Required",
- minval = 1,
- maxval = 5,
- group = groupProtocol
- )
- minimumDirectionalPOIScore = input.int(
- 2,
- "Minimum Directional POI Score",
- minval = 1,
- maxval = 10,
- group = groupProtocol,
- tooltip = "FVG/Order Block = 2 points. IFVG/Breaker/Rejection Block = 3 points."
- )
- rejectOpposingPOIDominance = input.bool(
- true,
- "Reject Opposing POI Dominance",
- group = groupProtocol
- )
- useFVGPOI = input.bool(true, "Include Fair Value Gaps", group = groupProtocol)
- useIFVGPOI = input.bool(true, "Include Inverse FVGs", group = groupProtocol)
- useOrderBlockPOI = input.bool(true, "Include Order Blocks", group = groupProtocol)
- useBreakerPOI = input.bool(true, "Include Breaker Blocks", group = groupProtocol)
- useRejectionBlockPOI = input.bool(true, "Include Rejection Blocks", group = groupProtocol)
- keyLevelToleranceATR = input.float(
- 0.10,
- "Key-Level Touch Tolerance (ATR)",
- minval = 0.0,
- step = 0.01,
- group = groupProtocol
- )
- minimumRejectionPercent = input.float(
- 35.0,
- "Minimum Manipulation Rejection Wick %",
- minval = 0.0,
- maxval = 100.0,
- step = 1.0,
- group = groupProtocol
- )
- requireMidpointReclaim = input.bool(
- true,
- "Require Range Midpoint Reclaim",
- group = groupProtocol
- )
- atrLength = input.int(
- 20,
- "ATR Length",
- minval = 1,
- group = groupProtocol
- )
- minimumRangeATR = input.float(
- 0.4,
- "Minimum Range Size (ATR)",
- minval = 0.0,
- step = 0.1,
- group = groupProtocol
- )
- maximumRangeATR = input.float(
- 2.0,
- "Maximum Range Size (ATR)",
- minval = 0.1,
- step = 0.1,
- group = groupProtocol
- )
- minimumRangeBodyPercent = input.float(
- 20.0,
- "Minimum Range Body %",
- minval = 0.0,
- maxval = 100.0,
- step = 1.0,
- group = groupProtocol
- )
- maximumRangeBodyPercent = input.float(
- 80.0,
- "Maximum Range Body %",
- minval = 0.0,
- maxval = 100.0,
- step = 1.0,
- group = groupProtocol
- )
- string groupLiquidity = "Liquidity Purge Context"
- useLiquidityPurgeContext = input.bool(
- true,
- "Protocol 10 — Meaningful Liquidity Purge Context",
- group = groupLiquidity,
- tooltip = "Bonus context only. It does not reject or hide any CRT that qualified under the stable v16.7 engine."
- )
- liquiditySwingLookback = input.int(
- 20,
- "Swing Liquidity Lookback",
- minval = 3,
- maxval = 200,
- group = groupLiquidity
- )
- liquidityToleranceATR = input.float(
- 0.05,
- "Liquidity Equality Tolerance (ATR)",
- minval = 0.0,
- step = 0.01,
- group = groupLiquidity
- )
- minimumLiquidityPurgeScore = input.int(
- 1,
- "Meaningful Purge Score Threshold",
- minval = 1,
- maxval = 6,
- group = groupLiquidity,
- tooltip = "Previous day = 1, previous week = 2, previous month = 3, established swing liquidity = 1."
- )
- string groupNested = "CRT Sequence / Nested HTF Context"
- useNestedCRTContext = input.bool(
- true,
- "Protocol 11 — Nested HTF CRT Context",
- group = groupNested,
- tooltip = "Bonus context only. Detects when the current CRT is nested inside, overlaps, or directionally aligns with an active parent-timeframe CRT. It cannot reject or hide stable v16.9 CRTs."
- )
- requireFullParentContainment = input.bool(
- false,
- "Require Full Containment for Nested State",
- group = groupNested,
- tooltip = "Off: overlap with the active parent CRT range qualifies. On: the complete local Range candle must sit inside the parent CRT range."
- )
- useParentPremiumDiscount = input.bool(
- true,
- "Score Parent Premium / Discount Location",
- group = groupNested,
- tooltip = "Bullish nested CRTs score when formed in the lower half of the parent range. Bearish nested CRTs score in the upper half."
- )
- minimumNestedContextScore = input.int(
- 2,
- "Meaningful Nested Context Score",
- minval = 1,
- maxval = 3,
- group = groupNested,
- tooltip = "Inside/overlap = 1, direction aligned = 1, correct premium/discount location = 1."
- )
- string groupDelivery = "Displacement / Delivery Confirmation"
- useDeliveryContext = input.bool(
- true,
- "Protocol 12 — Displacement and Delivery Confirmation",
- group = groupDelivery,
- tooltip = "Bonus confirmation only. Evaluates post-manipulation delivery without hiding CRTs qualified by the stable v17.1 engine."
- )
- deliveryWindowBars = input.int(
- 3,
- "Delivery Confirmation Window (Bars)",
- minval = 1,
- maxval = 6,
- group = groupDelivery
- )
- minimumDeliveryBodyATR = input.float(
- 0.50,
- "Minimum Displacement Body (ATR)",
- minval = 0.0,
- step = 0.05,
- group = groupDelivery
- )
- requireDeliveryFVG = input.bool(
- false,
- "Require FVG Creation for Delivery Bonus",
- group = groupDelivery
- )
- minimumDeliveryScore = input.int(
- 2,
- "Meaningful Delivery Score",
- minval = 1,
- maxval = 4,
- group = groupDelivery,
- tooltip = "Directional close = 1, strong ATR body = 1, range-mid delivery = 1, FVG creation = 1."
- )
- string groupFailure = "Failed CRT / Reversal Context"
- useFailedCRTContext = input.bool(
- true,
- "Protocol 13 — Failed CRT / Reversal Context",
- group = groupFailure,
- tooltip = "Context only. Tracks a qualified CRT that fails through its manipulated-side boundary and treats that failure as potential opposite-direction information. It does not hide stable v17.4 CRTs."
- )
- failureRequiresClose = input.bool(
- true,
- "Failure Requires Close Through Boundary",
- group = groupFailure
- )
- failureWindowBars = input.int(
- 6,
- "Failure Detection Window (Bars)",
- minval = 1,
- maxval = 30,
- group = groupFailure
- )
- requireFailureDirectionalClose = input.bool(
- true,
- "Require Failure Candle Direction",
- group = groupFailure,
- tooltip = "Bullish CRT failure candle must close bearish; bearish CRT failure candle must close bullish."
- )
- minimumFailureBodyATR = input.float(
- 0.25,
- "Minimum Failure Body (ATR)",
- minval = 0.0,
- step = 0.05,
- group = groupFailure
- )
- string groupTarget = "CRT Target Delivery / Draw on Liquidity"
- useTargetDeliveryContext = input.bool(
- true,
- "Protocol 14 — Target Delivery / Draw on Liquidity",
- group = groupTarget,
- tooltip = "Context only. Selects the nearest valid opposite-side liquidity objective for each qualified CRT. It does not alter stable v17.5 CRT qualification or candle colors."
- )
- includeOppositeCRTRangeBoundary = input.bool(
- true,
- "Include Opposite CRT Range Boundary",
- group = groupTarget
- )
- includePreviousDayTarget = input.bool(
- true,
- "Include Previous Day Liquidity",
- group = groupTarget
- )
- includePreviousWeekTarget = input.bool(
- true,
- "Include Previous Week Liquidity",
- group = groupTarget
- )
- includePreviousMonthTarget = input.bool(
- true,
- "Include Previous Month Liquidity",
- group = groupTarget
- )
- includeSwingLiquidityTarget = input.bool(
- true,
- "Include Swing Liquidity",
- group = groupTarget
- )
- targetSwingLookback = input.int(
- 20,
- "Target Swing Lookback",
- minval = 3,
- maxval = 200,
- group = groupTarget
- )
- targetReachToleranceATR = input.float(
- 0.05,
- "Target Reach Tolerance (ATR)",
- minval = 0.0,
- step = 0.01,
- group = groupTarget
- )
- string groupGrade = "CRT Intelligence Grade Engine"
- useIntelligenceGrade = input.bool(
- true,
- "CRT Intelligence Grade Engine",
- group = groupGrade,
- tooltip = "Grades qualified CRTs from C to A+ using the protocol intelligence already built. Grading is informational and does not alter stable v17.6 CRT qualification."
- )
- gradeAPlusThreshold = input.int(
- 8,
- "A+ Minimum Intelligence Score",
- minval = 1,
- maxval = 10,
- group = groupGrade
- )
- gradeAThreshold = input.int(
- 6,
- "A Minimum Intelligence Score",
- minval = 1,
- maxval = 10,
- group = groupGrade
- )
- gradeBThreshold = input.int(
- 4,
- "B Minimum Intelligence Score",
- minval = 1,
- maxval = 10,
- group = groupGrade
- )
- string groupDashboard = "CRT Intelligence Dashboard"
- showIntelligenceDashboard = input.bool(
- true,
- "Show CRT Intelligence Dashboard",
- group = groupDashboard
- )
- dashboardPosition = input.string(
- "Top Right",
- "Dashboard Position",
- options = ["Top Right", "Top Left", "Bottom Right", "Bottom Left"],
- group = groupDashboard
- )
- dashboardTextSize = input.string(
- "Small",
- "Dashboard Text Size",
- options = ["Tiny", "Small", "Normal"],
- group = groupDashboard
- )
- string groupKeyLevel = "Dedicated ICT Key Level Engine"
- useDedicatedKeyLevelEngine = input.bool(
- true,
- "Enable Dedicated ICT Key Level Engine",
- group = groupKeyLevel,
- tooltip = "Detects the dominant FVG, IFVG, Order Block, Breaker, or Rejection Block interacting with the latest CRT Range on the selected source timeframe."
- )
- keyLevelLookback = input.int(
- 80,
- "Key Level Detection Lookback",
- minval = 10,
- maxval = 300,
- group = groupKeyLevel
- )
- keyLevelTypeToleranceATR = input.float(
- 0.05,
- "Key Level Zone Tolerance (ATR)",
- minval = 0.0,
- step = 0.01,
- group = groupKeyLevel
- )
- string groupSMT = "SMT / Multi-Asset Matrix"
- useSMTProtocol = input.bool(
- true,
- "Protocol 9 — Multi-Asset SMT Matrix",
- group = groupSMT,
- tooltip = "Checks the candidate CRT against up to two correlated or inversely correlated comparison markets."
- )
- smtMode = input.string(
- "Auto Matrix",
- "SMT Comparison Mode",
- options = ["Auto Matrix", "Manual"],
- group = groupSMT
- )
- manualSMTSymbol1 = input.symbol(
- "CME_MINI:NQ1!",
- "Manual Comparison Symbol 1",
- group = groupSMT
- )
- manualSMTRelation1 = input.string(
- "Direct",
- "Manual Symbol 1 Relation",
- options = ["Direct", "Inverse"],
- group = groupSMT
- )
- manualSMTSymbol2 = input.symbol(
- "CBOT_MINI:YM1!",
- "Manual Comparison Symbol 2",
- group = groupSMT
- )
- manualSMTRelation2 = input.string(
- "Direct",
- "Manual Symbol 2 Relation",
- options = ["Direct", "Inverse"],
- group = groupSMT
- )
- useSecondSMTMarket = input.bool(
- true,
- "Use Second SMT Market",
- group = groupSMT
- )
- smtLookback = input.int(
- 20,
- "SMT Swing Lookback",
- minval = 2,
- maxval = 200,
- group = groupSMT
- )
- smtToleranceATR = input.float(
- 0.05,
- "SMT Equality Tolerance (ATR)",
- minval = 0.0,
- step = 0.01,
- group = groupSMT
- )
- minimumSMTConfirmations = input.int(
- 1,
- "Minimum Aligned SMT Confirmations",
- minval = 1,
- maxval = 2,
- group = groupSMT,
- tooltip = "One aligned comparison is enough by default. Set to 2 for stricter multi-market confirmation."
- )
- allowNeutralSMT = input.bool(
- true,
- "Allow Neutral SMT",
- group = groupSMT
- )
- rejectOpposingSMT = input.bool(
- false,
- "Reject Strong Opposing SMT",
- group = groupSMT,
- tooltip = "Rejects a CRT when opposing SMT confirmations outnumber aligned SMT confirmations."
- )
- //======================================================================
- // 3. VISUAL SETTINGS
- //======================================================================
- groupVisual = "3. Visual Settings"
- colorCandles = input.bool(true, "Color Qualified CRT Candles on Source Timeframe", group = groupVisual)
- rangeColor = input.color(color.rgb(35, 125, 225), "Range Candle Color", group = groupVisual)
- manipulationColor = input.color(color.rgb(255, 195, 0), "Manipulation Candle Color", group = groupVisual)
- //======================================================================
- // 4. MULTI-HTF HIERARCHY + AUTO AMD WINDOWS
- //======================================================================
- groupProjection = "4. Multi-HTF Hierarchy + AMD Windows"
- enableHTFProjection = input.bool(
- true,
- "Show Selected HTF AMD Windows on Lower Timeframes",
- group = groupProjection
- )
- hierarchyContext = input.string(
- "Auto",
- "HTF Context Mode",
- options = ["Auto", "Monthly", "Weekly", "Daily", "H4", "H3", "H2", "H1", "30m"],
- group = groupProjection,
- tooltip = "Auto uses the chart timeframe on Monthly, Weekly, Daily, H4, H3, H2, H1 and 30m charts. On charts below 30m it uses the Lower-TF Projection Context selected below."
- )
- lowerTFProjectionContext = input.string(
- "H4",
- "Lower-TF Projection Context",
- options = ["Monthly", "Weekly", "Daily", "H4", "H3", "H2", "H1", "30m"],
- group = groupProjection,
- tooltip = "Used only when HTF Context Mode is Auto and the chart timeframe is below 30 minutes."
- )
- f_contextToTF(string context) =>
- context == "Monthly" ? "M" :
- context == "Weekly" ? "W" :
- context == "Daily" ? "D" :
- context == "H3" ? "180" :
- context == "H2" ? "120" :
- context == "H1" ? "60" :
- context == "30m" ? "30" : "240"
- int currentChartSeconds = timeframe.in_seconds(timeframe.period)
- string autoSelectedHTF =
- timeframe.ismonthly ? "M" :
- timeframe.isweekly ? "W" :
- timeframe.isdaily ? "D" :
- not na(currentChartSeconds) and currentChartSeconds >= 14400 ? "240" :
- not na(currentChartSeconds) and currentChartSeconds >= 10800 ? "180" :
- not na(currentChartSeconds) and currentChartSeconds >= 7200 ? "120" :
- not na(currentChartSeconds) and currentChartSeconds >= 3600 ? "60" :
- not na(currentChartSeconds) and currentChartSeconds >= 1800 ? "30" :
- f_contextToTF(lowerTFProjectionContext)
- string selectedHTF = hierarchyContext == "Auto" ? autoSelectedHTF : f_contextToTF(hierarchyContext)
- // Clean-chart mode: no automatic AMD vertical separators or phase labels.
- // The selected HTF structure is still tracked internally for LTF unlock logic.
- //======================================================================
- // 5. EXECUTION UNLOCK ENGINE
- //======================================================================
- groupExecution = "5. Execution Unlock Engine"
- enableExecutionEngine = input.bool(
- true,
- "Enable LTF Execution Scanner",
- group = groupExecution,
- tooltip = "After the selected HTF manipulation closes, scan only its Distribution window for aligned lower-timeframe CRT structure."
- )
- maximumExecutionMinutes = input.int(
- 15,
- "Maximum Execution Chart Timeframe (Minutes)",
- minval = 1,
- maxval = 60,
- group = groupExecution,
- tooltip = "Example: 15 allows the scanner on 15m, 5m, 3m, 2m and 1m charts."
- )
- firstExecutionOnly = input.bool(
- true,
- "Show First Entry Only per HTF Setup",
- group = groupExecution
- )
- colorUnlockedLTFStructure = input.bool(
- true,
- "Color Unlocked LTF Range + Manipulation",
- group = groupExecution,
- tooltip = "Inside the confirmed HTF Distribution window, color only aligned lower-timeframe CRT structure: blue Range candle and yellow Manipulation candle."
- )
- showRawCRTForTesting = input.bool(
- false,
- "TEST — Show Raw CRT Without Protocol Filters",
- group = groupExecution,
- tooltip = "Diagnostic only. Shows every valid close-back-inside CRT before protocol filtering."
- )
- localRequireCloseInside = input.bool(
- true,
- "LTF Manipulation Must Close Inside Local Range",
- group = groupExecution
- )
- localRequireMidpoint = input.bool(
- true,
- "LTF Manipulation Must Reclaim Local Midpoint",
- group = groupExecution
- )
- localMinimumRejection = input.float(
- 25.0,
- "Minimum LTF Rejection Wick %",
- minval = 0.0,
- maxval = 100.0,
- step = 1.0,
- group = groupExecution
- )
- ltfRangeColor = input.color(color.rgb(35, 125, 225), "Unlocked LTF Range Color", group = groupExecution)
- ltfManipulationColor = input.color(color.rgb(255, 195, 0), "Unlocked LTF Manipulation Color", group = groupExecution)
- // v20.7 Execution Authorization Engine (core logic retained unchanged in v20.9.1)
- enableExecutionAuthorizationEngine = input.bool(
- true,
- "Enable One-Shot Execution Authorization",
- group = groupExecution,
- tooltip = "After a parent narrative is active, authorizes one aligned qualified LTF CRT per parent narrative ID. This is permission guidance only; it does not place orders."
- )
- authorizationRequireLiquidityOrPOI = input.bool(
- true,
- "Authorization Requires Liquidity Purge or Key-Level Reaction",
- group = groupExecution,
- tooltip = "The aligned LTF CRT must also confirm a meaningful liquidity purge or a directional FVG/IFVG, order block, breaker, rejection block, or tracked external level."
- )
- authorizationRequireObjectiveRoom = input.bool(
- true,
- "Authorization Requires Room to Parent Objective",
- group = groupExecution,
- tooltip = "Blocks authorization when the parent objective is already behind price, unavailable, completed, or too close to justify chasing."
- )
- authorizationMinimumRoomATR = input.float(
- 0.50,
- "Minimum Room to Parent Objective (LTF ATR)",
- minval = 0.0,
- maxval = 10.0,
- step = 0.05,
- group = groupExecution,
- tooltip = "Minimum remaining distance from current price to the parent objective, measured with the execution-chart ATR."
- )
- authorizationRequireDistributionWindow = input.bool(
- false,
- "Authorization Requires Active HTF Distribution Window",
- group = groupExecution,
- tooltip = "Optional strict mode. When enabled, authorization is allowed only inside the existing projected HTF Distribution window."
- )
- //======================================================================
- // 6. FORWARD-TEST ALERT ENGINE
- //======================================================================
- string groupForwardAlerts = "6. Forward-Test Alert Engine"
- enableForwardTestAlerts = input.bool(
- true,
- "Enable Forward-Test Runtime Alerts",
- group = groupForwardAlerts,
- tooltip = "Uses Pine alert() calls so the execution milestones can be monitored without consuming additional plot slots. Create one TradingView alert using: Any alert() function call."
- )
- alertParentConfirmed = input.bool(true, "Alert — Parent Narrative Confirmed 4/4", group = groupForwardAlerts)
- alertExecutionArmed = input.bool(true, "Alert — Execution Armed", group = groupForwardAlerts)
- alertEntryConfirmed = input.bool(true, "Alert — Entry Confirmed", group = groupForwardAlerts)
- alertDeliveryNoReentry = input.bool(true, "Alert — Delivery / No Re-Entry", group = groupForwardAlerts)
- alertParentObjectiveCompleted = input.bool(true, "Alert — Parent Objective Completed", group = groupForwardAlerts)
- alertParentRejectedInvalidated = input.bool(true, "Alert — Parent Rejected / Invalidated / Expired", group = groupForwardAlerts)
- alertNoChase = input.bool(true, "Alert — No Chase / Objective Too Near", group = groupForwardAlerts)
- //======================================================================
- // 7. ASH ICT FRACTAL
- //======================================================================
- string groupFractal = "7. Ash ICT Fractal"
- showAshICTFractal = input.bool(
- true,
- "Show Ash ICT Fractal",
- group = groupFractal,
- tooltip = "Displays the original clean Ash ICT Fractal markers on every chart timeframe. Signals are confirmed only after the required right-side candles close."
- )
- ashICTFractalPeriods = input.int(
- 2,
- "Fractal Period",
- minval = 1,
- maxval = 10,
- group = groupFractal,
- tooltip = "Original default is 2 candles on each side of the centre candle."
- )
- ashICTFractalUseHighLow = input.bool(
- true,
- "Use High/Low",
- group = groupFractal,
- tooltip = "On: fractals use candle wicks. Off: fractals use candle body highs and lows."
- )
- showAshICTFractalHigh = input.bool(true, "Show Fractal High", group = groupFractal)
- showAshICTFractalLow = input.bool(true, "Show Fractal Low", group = groupFractal)
- ashICTFractalHighColor = input.color(color.rgb(170, 170, 0), "Fractal High Color", group = groupFractal)
- ashICTFractalLowColor = input.color(color.rgb(180, 0, 120), "Fractal Low Color", group = groupFractal)
- //======================================================================
- // 8. HELPERS — AUTO MARKET TIME PROTOCOL
- //======================================================================
- f_hourDistance(int a, int b) =>
- int directDistance = math.abs(a - b)
- math.min(directDistance, 24 - directDistance)
- f_hourMatches(int candleHour, int modelHour) =>
- f_hourDistance(candleHour, modelHour) <= timeMatchToleranceHours
- f_autoMarketProfile() =>
- string tickerUpper = str.upper(syminfo.ticker)
- string rootUpper = str.upper(syminfo.root)
- bool indexKeyword =
- str.contains(tickerUpper, "US100") or
- str.contains(tickerUpper, "NAS") or
- str.contains(tickerUpper, "SPX") or
- str.contains(tickerUpper, "US500") or
- str.contains(tickerUpper, "DJI") or
- str.contains(tickerUpper, "DAX") or
- str.contains(tickerUpper, "FTSE")
- bool commodityKeyword =
- str.contains(tickerUpper, "XAU") or
- str.contains(tickerUpper, "XAG") or
- str.contains(rootUpper, "CL") or
- str.contains(rootUpper, "MCL") or
- str.contains(rootUpper, "GC") or
- str.contains(rootUpper, "SI") or
- str.contains(tickerUpper, "OIL")
- syminfo.type == "forex" ? "Forex" :
- syminfo.type == "crypto" ? "Crypto" :
- commodityKeyword ? "Commodities" :
- syminfo.type == "futures" ? (indexKeyword or str.contains(rootUpper, "ES") or str.contains(rootUpper, "NQ") or str.contains(rootUpper, "YM") or str.contains(rootUpper, "RTY") ? "Indices" : "Futures") :
- syminfo.type == "index" or indexKeyword ? "Indices" :
- "Manual"
- f_selectedMarketProfile() =>
- marketTimeProfile == "Auto" ? f_autoMarketProfile() : marketTimeProfile
- f_profileHours(string profile) =>
- int h1 =
- profile == "Forex" ? forexHour1 :
- profile == "Indices" ? indicesHour1 :
- profile == "Futures" ? futuresHour1 :
- profile == "Crypto" ? cryptoHour1 :
- profile == "Commodities" ? commoditiesHour1 : manualHour1
- int h2 =
- profile == "Forex" ? forexHour2 :
- profile == "Indices" ? indicesHour2 :
- profile == "Futures" ? futuresHour2 :
- profile == "Crypto" ? cryptoHour2 :
- profile == "Commodities" ? commoditiesHour2 : manualHour2
- int h3 =
- profile == "Forex" ? forexHour3 :
- profile == "Indices" ? indicesHour3 :
- profile == "Futures" ? futuresHour3 :
- profile == "Crypto" ? cryptoHour3 :
- profile == "Commodities" ? commoditiesHour3 : manualHour3
- [h1, h2, h3]
- isAllowedRangeHour(int candleTime) =>
- bool higherCalendarTF = timeframe.isdaily or timeframe.isweekly or timeframe.ismonthly
- string activeProfile = f_selectedMarketProfile()
- [modelHour1, modelHour2, modelHour3] = f_profileHours(activeProfile)
- int candleHour = hour(candleTime, timezoneInput)
- not useSelectedHours or higherCalendarTF or
- f_hourMatches(candleHour, modelHour1) or
- f_hourMatches(candleHour, modelHour2) or
- f_hourMatches(candleHour, modelHour3)
- isNearLevel(float candleHigh, float candleLow, float level, float tolerance) =>
- not na(level) and candleHigh >= level - tolerance and candleLow <= level + tolerance
- rangeOverlapsZone(float candleHigh, float candleLow, float zoneHigh, float zoneLow, float tolerance) =>
- not na(zoneHigh) and not na(zoneLow) and candleHigh >= zoneLow - tolerance and candleLow <= zoneHigh + tolerance
- // Directional POI Confluence Engine v2. No zones are drawn.
- // Scores are weighted by POI quality and kept directional.
- f_detectDirectionalPOIs(float testHigh, float testLow, float tolerance) =>
- bool bullFVGTouch = false
- bool bearFVGTouch = false
- bool bullIFVGTouch = false
- bool bearIFVGTouch = false
- bool bullOBTouch = false
- bool bearOBTouch = false
- bool bullBreakerTouch = false
- bool bearBreakerTouch = false
- bool bullRBTouch = false
- bool bearRBTouch = false
- int maxBack = math.min(poiLookback, bar_index > 10 ? bar_index - 5 : 0)
- if maxBack >= 4
- for k = 2 to maxBack
- bool bullFVG = low[k] > high[k + 2]
- bool bearFVG = high[k] < low[k + 2]
- float bullFVGHigh = low[k]
- float bullFVGLow = high[k + 2]
- float bearFVGHigh = low[k + 2]
- float bearFVGLow = high[k]
- bullFVGTouch := bullFVGTouch or (bullFVG and rangeOverlapsZone(testHigh, testLow, bullFVGHigh, bullFVGLow, tolerance))
- bearFVGTouch := bearFVGTouch or (bearFVG and rangeOverlapsZone(testHigh, testLow, bearFVGHigh, bearFVGLow, tolerance))
- // An invalidated bearish FVG reclaimed upward acts as bullish IFVG.
- // An invalidated bullish FVG reclaimed downward acts as bearish IFVG.
- bool bullishIFVG = bearFVG and close[k - 1] > bearFVGHigh
- bool bearishIFVG = bullFVG and close[k - 1] < bullFVGLow
- bullIFVGTouch := bullIFVGTouch or (bullishIFVG and rangeOverlapsZone(testHigh, testLow, bearFVGHigh, bearFVGLow, tolerance))
- bearIFVGTouch := bearIFVGTouch or (bearishIFVG and rangeOverlapsZone(testHigh, testLow, bullFVGHigh, bullFVGLow, tolerance))
- bool bullishDisplacement = close[k] > high[k + 1] and close[k] > open[k]
- bool bearishDisplacement = close[k] < low[k + 1] and close[k] < open[k]
- bool bullishOB = bullishDisplacement and close[k + 1] < open[k + 1]
- bool bearishOB = bearishDisplacement and close[k + 1] > open[k + 1]
- bullOBTouch := bullOBTouch or (bullishOB and rangeOverlapsZone(testHigh, testLow, high[k + 1], low[k + 1], tolerance))
- bearOBTouch := bearOBTouch or (bearishOB and rangeOverlapsZone(testHigh, testLow, high[k + 1], low[k + 1], tolerance))
- bool bullishBreaker = close[k + 1] < open[k + 1] and close[k] > high[k + 1]
- bool bearishBreaker = close[k + 1] > open[k + 1] and close[k] < low[k + 1]
- bullBreakerTouch := bullBreakerTouch or (bullishBreaker and rangeOverlapsZone(testHigh, testLow, high[k + 1], low[k + 1], tolerance))
- bearBreakerTouch := bearBreakerTouch or (bearishBreaker and rangeOverlapsZone(testHigh, testLow, high[k + 1], low[k + 1], tolerance))
- float candleRangeK = math.max(high[k] - low[k], syminfo.mintick)
- float lowerWickPctK = (math.min(open[k], close[k]) - low[k]) / candleRangeK * 100.0
- float upperWickPctK = (high[k] - math.max(open[k], close[k])) / candleRangeK * 100.0
- bool bullishRB = lowerWickPctK >= 50.0
- bool bearishRB = upperWickPctK >= 50.0
- float bullRBHigh = math.min(open[k], close[k])
- float bullRBLow = low[k]
- float bearRBHigh = high[k]
- float bearRBLow = math.max(open[k], close[k])
- bullRBTouch := bullRBTouch or (bullishRB and rangeOverlapsZone(testHigh, testLow, bullRBHigh, bullRBLow, tolerance))
- bearRBTouch := bearRBTouch or (bearishRB and rangeOverlapsZone(testHigh, testLow, bearRBHigh, bearRBLow, tolerance))
- int bullTypes =
- (useFVGPOI and bullFVGTouch ? 1 : 0) +
- (useIFVGPOI and bullIFVGTouch ? 1 : 0) +
- (useOrderBlockPOI and bullOBTouch ? 1 : 0) +
- (useBreakerPOI and bullBreakerTouch ? 1 : 0) +
- (useRejectionBlockPOI and bullRBTouch ? 1 : 0)
- int bearTypes =
- (useFVGPOI and bearFVGTouch ? 1 : 0) +
- (useIFVGPOI and bearIFVGTouch ? 1 : 0) +
- (useOrderBlockPOI and bearOBTouch ? 1 : 0) +
- (useBreakerPOI and bearBreakerTouch ? 1 : 0) +
- (useRejectionBlockPOI and bearRBTouch ? 1 : 0)
- int bullScore =
- (useFVGPOI and bullFVGTouch ? 2 : 0) +
- (useIFVGPOI and bullIFVGTouch ? 3 : 0) +
- (useOrderBlockPOI and bullOBTouch ? 2 : 0) +
- (useBreakerPOI and bullBreakerTouch ? 3 : 0) +
- (useRejectionBlockPOI and bullRBTouch ? 3 : 0)
- int bearScore =
- (useFVGPOI and bearFVGTouch ? 2 : 0) +
- (useIFVGPOI and bearIFVGTouch ? 3 : 0) +
- (useOrderBlockPOI and bearOBTouch ? 2 : 0) +
- (useBreakerPOI and bearBreakerTouch ? 3 : 0) +
- (useRejectionBlockPOI and bearRBTouch ? 3 : 0)
- [bullTypes, bearTypes, bullScore, bearScore]
- //======================================================================
- // 6A. DEDICATED ICT KEY LEVEL TYPE ENGINE
- // Runs in the selected source-timeframe context.
- // Type codes: 0=None, 1=FVG, 2=IFVG, 3=Order Block,
- // 4=Breaker, 5=Rejection Block.
- //======================================================================
- f_keyLevelTypeForRange(float testHigh, float testLow, float tolerance) =>
- int bullishType = 0
- int bearishType = 0
- int bullishWeight = 0
- int bearishWeight = 0
- int maxBack = math.min(keyLevelLookback, bar_index > 10 ? bar_index - 5 : 0)
- if maxBack >= 4
- for k = 2 to maxBack
- bool bullFVG = low[k] > high[k + 2]
- bool bearFVG = high[k] < low[k + 2]
- float bullFVGHigh = low[k]
- float bullFVGLow = high[k + 2]
- float bearFVGHigh = low[k + 2]
- float bearFVGLow = high[k]
- bool bullFVGTouch = bullFVG and rangeOverlapsZone(testHigh, testLow, bullFVGHigh, bullFVGLow, tolerance)
- bool bearFVGTouch = bearFVG and rangeOverlapsZone(testHigh, testLow, bearFVGHigh, bearFVGLow, tolerance)
- bool bullishIFVG = bearFVG and close[k - 1] > bearFVGHigh
- bool bearishIFVG = bullFVG and close[k - 1] < bullFVGLow
- bool bullIFVGTouch = bullishIFVG and rangeOverlapsZone(testHigh, testLow, bearFVGHigh, bearFVGLow, tolerance)
- bool bearIFVGTouch = bearishIFVG and rangeOverlapsZone(testHigh, testLow, bullFVGHigh, bullFVGLow, tolerance)
- bool bullishDisplacement = close[k] > high[k + 1] and close[k] > open[k]
- bool bearishDisplacement = close[k] < low[k + 1] and close[k] < open[k]
- bool bullishOB = bullishDisplacement and close[k + 1] < open[k + 1]
- bool bearishOB = bearishDisplacement and close[k + 1] > open[k + 1]
- bool bullOBTouch = bullishOB and rangeOverlapsZone(testHigh, testLow, high[k + 1], low[k + 1], tolerance)
- bool bearOBTouch = bearishOB and rangeOverlapsZone(testHigh, testLow, high[k + 1], low[k + 1], tolerance)
- bool bullishBreaker = close[k + 1] < open[k + 1] and close[k] > high[k + 1]
- bool bearishBreaker = close[k + 1] > open[k + 1] and close[k] < low[k + 1]
- bool bullBreakerTouch = bullishBreaker and rangeOverlapsZone(testHigh, testLow, high[k + 1], low[k + 1], tolerance)
- bool bearBreakerTouch = bearishBreaker and rangeOverlapsZone(testHigh, testLow, high[k + 1], low[k + 1], tolerance)
- float candleRangeK = math.max(high[k] - low[k], syminfo.mintick)
- float lowerWickPctK = (math.min(open[k], close[k]) - low[k]) / candleRangeK * 100.0
- float upperWickPctK = (high[k] - math.max(open[k], close[k])) / candleRangeK * 100.0
- bool bullishRB = lowerWickPctK >= 50.0
- bool bearishRB = upperWickPctK >= 50.0
- float bullRBHigh = math.min(open[k], close[k])
- float bullRBLow = low[k]
- float bearRBHigh = high[k]
- float bearRBLow = math.max(open[k], close[k])
- bool bullRBTouch = bullishRB and rangeOverlapsZone(testHigh, testLow, bullRBHigh, bullRBLow, tolerance)
- bool bearRBTouch = bearishRB and rangeOverlapsZone(testHigh, testLow, bearRBHigh, bearRBLow, tolerance)
- if bullFVGTouch and bullishWeight < 2
- bullishType := 1
- bullishWeight := 2
- if bearFVGTouch and bearishWeight < 2
- bearishType := 1
- bearishWeight := 2
- if bullOBTouch and bullishWeight < 2
- bullishType := 3
- bullishWeight := 2
- if bearOBTouch and bearishWeight < 2
- bearishType := 3
- bearishWeight := 2
- if bullIFVGTouch and bullishWeight < 3
- bullishType := 2
- bullishWeight := 3
- if bearIFVGTouch and bearishWeight < 3
- bearishType := 2
- bearishWeight := 3
- if bullBreakerTouch and bullishWeight < 3
- bullishType := 4
- bullishWeight := 3
- if bearBreakerTouch and bearishWeight < 3
- bearishType := 4
- bearishWeight := 3
- if bullRBTouch and bullishWeight < 3
- bullishType := 5
- bullishWeight := 3
- if bearRBTouch and bearishWeight < 3
- bearishType := 5
- bearishWeight := 3
- [bullishType, bearishType, bullishWeight, bearishWeight]
- f_sourceTFKeyLevelState() =>
- float sourceRangeHigh = high[1]
- float sourceRangeLow = low[1]
- float sourceATR = ta.atr(14)
- float sourceTolerance = sourceATR[1] * keyLevelTypeToleranceATR
- [bullType, bearType, bullWeight, bearWeight] = f_keyLevelTypeForRange(sourceRangeHigh, sourceRangeLow, sourceTolerance)
- bool sourceSweptHigh = high > sourceRangeHigh
- bool sourceSweptLow = low < sourceRangeLow
- bool sourceSingleSweep = sourceSweptHigh != sourceSweptLow
- bool sourceClosedInside = close < sourceRangeHigh and close > sourceRangeLow
- bool sourceBase =
- barstate.isconfirmed and
- sourceSingleSweep and
- (not rejectDoubleSweep or not (sourceSweptHigh and sourceSweptLow)) and
- (not requireCloseInside or sourceClosedInside)
- int sourceDirection =
- sourceBase and sourceSweptLow and not sourceSweptHigh ? 1 :
- sourceBase and sourceSweptHigh and not sourceSweptLow ? -1 : 0
- int alignedType =
- sourceDirection == 1 ? bullType :
- sourceDirection == -1 ? bearType : 0
- int opposingType =
- sourceDirection == 1 ? bearType :
- sourceDirection == -1 ? bullType : 0
- int alignedWeight =
- sourceDirection == 1 ? bullWeight :
- sourceDirection == -1 ? bearWeight : 0
- [sourceDirection, alignedType, opposingType, alignedWeight]
- [sourceKeyDirection, sourceKeyLevelType, sourceOpposingKeyLevelType, sourceKeyLevelWeight] =
- request.security(
- syminfo.tickerid,
- selectedHTF,
- f_sourceTFKeyLevelState(),
- gaps = barmerge.gaps_off,
- lookahead = barmerge.lookahead_off
- )
- //======================================================================
- // 7. MULTI-ASSET SMT MATRIX
- // CME, Forex, Crypto, Metals and Energy.
- // v16.7 uses verified exchange prefixes and spot crypto comparison feeds.
- // Relation code: 1 = direct correlation, -1 = inverse correlation.
- //======================================================================
- f_autoSMTSymbol1() =>
- string t = str.upper(syminfo.ticker)
- string r = str.upper(syminfo.root)
- bool es = r == "ES" or str.contains(t, "US500") or str.contains(t, "SPX")
- bool nq = r == "NQ" or str.contains(t, "US100") or str.contains(t, "NAS100")
- bool ym = r == "YM" or str.contains(t, "US30")
- bool rty = r == "RTY"
- bool eurusd = str.contains(t, "EURUSD")
- bool gbpusd = str.contains(t, "GBPUSD")
- bool audusd = str.contains(t, "AUDUSD")
- bool nzdusd = str.contains(t, "NZDUSD")
- bool usdchf = str.contains(t, "USDCHF")
- bool usdcad = str.contains(t, "USDCAD")
- bool usdjpy = str.contains(t, "USDJPY")
- bool eurjpy = str.contains(t, "EURJPY")
- bool gbpjpy = str.contains(t, "GBPJPY")
- bool audjpy = str.contains(t, "AUDJPY")
- bool nzdjpy = str.contains(t, "NZDJPY")
- bool btc = str.contains(t, "BTC")
- bool eth = str.contains(t, "ETH")
- bool sol = str.contains(t, "SOL")
- bool gold = str.contains(t, "XAU") or r == "GC"
- bool silver = str.contains(t, "XAG") or r == "SI"
- bool wti = r == "CL" or str.contains(t, "USOIL") or str.contains(t, "WTI")
- bool brent = r == "BRN" or str.contains(t, "UKOIL") or str.contains(t, "BRENT")
- es ? "CME_MINI:NQ1!" :
- nq ? "CME_MINI:ES1!" :
- ym ? "CME_MINI:ES1!" :
- rty ? "CME_MINI:ES1!" :
- eurusd ? "OANDA:GBPUSD" :
- gbpusd ? "OANDA:EURUSD" :
- audusd ? "OANDA:NZDUSD" :
- nzdusd ? "OANDA:AUDUSD" :
- usdchf ? "TVC:DXY" :
- usdcad ? "TVC:DXY" :
- usdjpy ? "TVC:DXY" :
- eurjpy ? "OANDA:GBPJPY" :
- gbpjpy ? "OANDA:EURJPY" :
- audjpy ? "OANDA:NZDJPY" :
- nzdjpy ? "OANDA:AUDJPY" :
- btc ? "BINANCE:ETHUSDT" :
- eth ? "BINANCE:BTCUSDT" :
- sol ? "BINANCE:BTCUSDT" :
- gold ? "COMEX:SI1!" :
- silver ? "COMEX:GC1!" :
- wti ? "TVC:UKOIL" :
- brent ? "NYMEX:CL1!" :
- manualSMTSymbol1
- f_autoSMTRelation1() =>
- string t = str.upper(syminfo.ticker)
- bool usdchf = str.contains(t, "USDCHF")
- usdchf ? -1 : 1
- f_autoSMTSymbol2() =>
- string t = str.upper(syminfo.ticker)
- string r = str.upper(syminfo.root)
- bool es = r == "ES" or str.contains(t, "US500") or str.contains(t, "SPX")
- bool nq = r == "NQ" or str.contains(t, "US100") or str.contains(t, "NAS100")
- bool ym = r == "YM" or str.contains(t, "US30")
- bool rty = r == "RTY"
- bool eurusd = str.contains(t, "EURUSD")
- bool gbpusd = str.contains(t, "GBPUSD")
- bool audusd = str.contains(t, "AUDUSD")
- bool nzdusd = str.contains(t, "NZDUSD")
- bool usdchf = str.contains(t, "USDCHF")
- bool usdcad = str.contains(t, "USDCAD")
- bool usdjpy = str.contains(t, "USDJPY")
- bool btc = str.contains(t, "BTC")
- bool eth = str.contains(t, "ETH")
- bool sol = str.contains(t, "SOL")
- es ? "CBOT_MINI:YM1!" :
- nq ? "CBOT_MINI:YM1!" :
- ym ? "CME_MINI:NQ1!" :
- rty ? "CME_MINI:NQ1!" :
- eurusd ? "TVC:DXY" :
- gbpusd ? "TVC:DXY" :
- audusd ? "TVC:DXY" :
- nzdusd ? "TVC:DXY" :
- usdchf ? "OANDA:EURUSD" :
- usdcad ? "OANDA:AUDUSD" :
- usdjpy ? "OANDA:EURJPY" :
- btc ? "BINANCE:SOLUSDT" :
- eth ? "BINANCE:SOLUSDT" :
- sol ? "BINANCE:ETHUSDT" :
- manualSMTSymbol2
- f_autoSMTRelation2() =>
- string t = str.upper(syminfo.ticker)
- bool eurusd = str.contains(t, "EURUSD")
- bool gbpusd = str.contains(t, "GBPUSD")
- bool audusd = str.contains(t, "AUDUSD")
- bool nzdusd = str.contains(t, "NZDUSD")
- bool usdchf = str.contains(t, "USDCHF")
- bool usdjpy = str.contains(t, "USDJPY")
- eurusd or gbpusd or audusd or nzdusd or usdchf or usdjpy ? -1 : 1
- string smtSymbol1 = smtMode == "Auto Matrix" ? f_autoSMTSymbol1() : manualSMTSymbol1
- string smtSymbol2 = smtMode == "Auto Matrix" ? f_autoSMTSymbol2() : manualSMTSymbol2
- int smtRelation1 = smtMode == "Auto Matrix" ? f_autoSMTRelation1() : (manualSMTRelation1 == "Direct" ? 1 : -1)
- int smtRelation2 = smtMode == "Auto Matrix" ? f_autoSMTRelation2() : (manualSMTRelation2 == "Direct" ? 1 : -1)
- float smtHigh1 = request.security(smtSymbol1, selectedHTF, high, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off, ignore_invalid_symbol = true)
- float smtLow1 = request.security(smtSymbol1, selectedHTF, low, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off, ignore_invalid_symbol = true)
- float smtATR1 = request.security(smtSymbol1, selectedHTF, ta.atr(14), gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off, ignore_invalid_symbol = true)
- float smtHigh2 = request.security(smtSymbol2, selectedHTF, high, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off, ignore_invalid_symbol = true)
- float smtLow2 = request.security(smtSymbol2, selectedHTF, low, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off, ignore_invalid_symbol = true)
- float smtATR2 = request.security(smtSymbol2, selectedHTF, ta.atr(14), gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off, ignore_invalid_symbol = true)
- float ownPriorHigh = ta.highest(high[1], smtLookback)
- float ownPriorLow = ta.lowest(low[1], smtLookback)
- float ownTolerance = ta.atr(14) * smtToleranceATR
- bool ownHH = high > ownPriorHigh + ownTolerance
- bool ownLL = low < ownPriorLow - ownTolerance
- f_smtState(float comparisonHigh, float comparisonLow, float comparisonATR, int relation) =>
- bool comparisonDataReady =
- not na(comparisonHigh) and
- not na(comparisonLow) and
- not na(comparisonATR)
- float comparisonPriorHigh = ta.highest(comparisonHigh[1], smtLookback)
- float comparisonPriorLow = ta.lowest(comparisonLow[1], smtLookback)
- float comparisonTolerance = comparisonATR * smtToleranceATR
- bool comparisonHistoryReady =
- comparisonDataReady and
- not na(comparisonPriorHigh) and
- not na(comparisonPriorLow)
- bool comparisonHH =
- comparisonHistoryReady and
- comparisonHigh > comparisonPriorHigh + comparisonTolerance
- bool comparisonLL =
- comparisonHistoryReady and
- comparisonLow < comparisonPriorLow - comparisonTolerance
- bool bullishDirect = comparisonHistoryReady and ((ownLL and not comparisonLL) or (comparisonLL and not ownLL))
- bool bearishDirect = comparisonHistoryReady and ((ownHH and not comparisonHH) or (comparisonHH and not ownHH))
- bool bullishInverse = comparisonHistoryReady and ((ownLL and not comparisonHH) or (comparisonHH and not ownLL))
- bool bearishInverse = comparisonHistoryReady and ((ownHH and not comparisonLL) or (comparisonLL and not ownHH))
- int state =
- not comparisonHistoryReady ? 0 :
- relation == 1 ?
- (bullishDirect ? 1 : bearishDirect ? -1 : 0) :
- (bullishInverse ? 1 : bearishInverse ? -1 : 0)
- state
- int smtState1 = f_smtState(smtHigh1, smtLow1, smtATR1, smtRelation1)
- int smtState2 = useSecondSMTMarket ? f_smtState(smtHigh2, smtLow2, smtATR2, smtRelation2) : 0
- int bullishSMTCount = (smtState1 == 1 ? 1 : 0) + (smtState2 == 1 ? 1 : 0)
- int bearishSMTCount = (smtState1 == -1 ? 1 : 0) + (smtState2 == -1 ? 1 : 0)
- bool bullishSMT = bullishSMTCount >= minimumSMTConfirmations
- bool bearishSMT = bearishSMTCount >= minimumSMTConfirmations
- //======================================================================
- // 8. CRT HIERARCHY ALIGNMENT
- //======================================================================
- f_parentTimeframe(string childTF) =>
- childTF == "W" ? "M" :
- childTF == "D" ? "W" :
- childTF == "240" or childTF == "180" or childTF == "120" ? "D" :
- childTF == "60" ? "240" :
- childTF == "30" ? "60" :
- ""
- f_activeStructuralCRTDirection() =>
- float parentRangeHigh = high[1]
- float parentRangeLow = low[1]
- bool parentSweptHigh = high > parentRangeHigh
- bool parentSweptLow = low < parentRangeLow
- bool parentSingleSweep = parentSweptHigh != parentSweptLow
- bool parentClosedInside = close < parentRangeHigh and close > parentRangeLow
- bool parentBase =
- barstate.isconfirmed and
- parentSingleSweep and
- (not rejectDoubleSweep or not (parentSweptHigh and parentSweptLow)) and
- (not requireCloseInside or parentClosedInside)
- int parentEventDirection =
- parentBase and parentSweptLow and not parentSweptHigh ? 1 :
- parentBase and parentSweptHigh and not parentSweptLow ? -1 : 0
- bool parentEvent = parentEventDirection != 0
- int latestParentDirection = nz(ta.valuewhen(parentEvent, parentEventDirection, 0), 0)
- float latestParentRangeHigh = ta.valuewhen(parentEvent, parentRangeHigh, 0)
- float latestParentRangeLow = ta.valuewhen(parentEvent, parentRangeLow, 0)
- int parentBarsSinceEvent = ta.barssince(parentEvent)
- bool hasParentCRT =
- latestParentDirection != 0 and
- not na(latestParentRangeHigh) and
- not na(latestParentRangeLow) and
- not na(parentBarsSinceEvent)
- bool parentTargetReached =
- hasParentCRT and parentBarsSinceEvent > 0 and (
- latestParentDirection == 1 ?
- (targetRequiresClose ? close >= latestParentRangeHigh : high >= latestParentRangeHigh) :
- (targetRequiresClose ? close <= latestParentRangeLow : low <= latestParentRangeLow)
- )
- bool parentInvalidated =
- hasParentCRT and parentBarsSinceEvent > 0 and (
- latestParentDirection == 1 ?
- (invalidationRequiresClose ? close < latestParentRangeLow : low < latestParentRangeLow) :
- (invalidationRequiresClose ? close > latestParentRangeHigh : high > latestParentRangeHigh)
- )
- bool parentExpired = hasParentCRT and parentBarsSinceEvent > lifecycleExpiryBars
- bool parentActive = hasParentCRT and not parentTargetReached and not parentInvalidated and not parentExpired
- parentActive ? latestParentDirection : 0
- f_activeStructuralCRTContext() =>
- float pRangeHigh = high[1]
- float pRangeLow = low[1]
- bool pSweptHigh = high > pRangeHigh
- bool pSweptLow = low < pRangeLow
- bool pSingleSweep = pSweptHigh != pSweptLow
- bool pClosedInside = close < pRangeHigh and close > pRangeLow
- bool pBase =
- barstate.isconfirmed and
- pSingleSweep and
- (not rejectDoubleSweep or not (pSweptHigh and pSweptLow)) and
- (not requireCloseInside or pClosedInside)
- int pEventDirection =
- pBase and pSweptLow and not pSweptHigh ? 1 :
- pBase and pSweptHigh and not pSweptLow ? -1 : 0
- bool pEvent = pEventDirection != 0
- int pLatestDirection = nz(ta.valuewhen(pEvent, pEventDirection, 0), 0)
- float pLatestHigh = ta.valuewhen(pEvent, pRangeHigh, 0)
- float pLatestLow = ta.valuewhen(pEvent, pRangeLow, 0)
- int pBarsSince = ta.barssince(pEvent)
- bool pHasCRT =
- pLatestDirection != 0 and
- not na(pLatestHigh) and
- not na(pLatestLow) and
- not na(pBarsSince)
- bool pTargetReached =
- pHasCRT and pBarsSince > 0 and (
- pLatestDirection == 1 ?
- (targetRequiresClose ? close >= pLatestHigh : high >= pLatestHigh) :
- (targetRequiresClose ? close <= pLatestLow : low <= pLatestLow)
- )
- bool pInvalidated =
- pHasCRT and pBarsSince > 0 and (
- pLatestDirection == 1 ?
- (invalidationRequiresClose ? close < pLatestLow : low < pLatestLow) :
- (invalidationRequiresClose ? close > pLatestHigh : high > pLatestHigh)
- )
- bool pExpired = pHasCRT and pBarsSince > lifecycleExpiryBars
- bool pActive = pHasCRT and not pTargetReached and not pInvalidated and not pExpired
- [pActive ? pLatestDirection : 0, pActive ? pLatestHigh : na, pActive ? pLatestLow : na]
- string parentHierarchyTF = f_parentTimeframe(selectedHTF)
- int parentCRTDirection =
- parentHierarchyTF == "" ? 0 :
- request.security(
- syminfo.tickerid,
- parentHierarchyTF,
- f_activeStructuralCRTDirection(),
- gaps = barmerge.gaps_off,
- lookahead = barmerge.lookahead_off
- )
- string parentContextRequestTF = parentHierarchyTF == "" ? selectedHTF : parentHierarchyTF
- [parentContextDirectionRaw, parentContextHighRaw, parentContextLowRaw] =
- request.security(
- syminfo.tickerid,
- parentContextRequestTF,
- f_activeStructuralCRTContext(),
- gaps = barmerge.gaps_off,
- lookahead = barmerge.lookahead_off
- )
- int parentContextDirection = parentHierarchyTF == "" ? 0 : parentContextDirectionRaw
- float parentContextHigh = parentHierarchyTF == "" ? na : parentContextHighRaw
- float parentContextLow = parentHierarchyTF == "" ? na : parentContextLowRaw
- //======================================================================
- // 9. HIGHER-TIMEFRAME KEY LEVELS
- // Previous completed day/week/month levels; non-repainting.
- //======================================================================
- float previousDayHigh = request.security(syminfo.tickerid, "D", high[1], lookahead = barmerge.lookahead_on)
- float previousDayLow = request.security(syminfo.tickerid, "D", low[1], lookahead = barmerge.lookahead_on)
- float previousWeekHigh = request.security(syminfo.tickerid, "W", high[1], lookahead = barmerge.lookahead_on)
- float previousWeekLow = request.security(syminfo.tickerid, "W", low[1], lookahead = barmerge.lookahead_on)
- float previousMonthHigh = request.security(syminfo.tickerid, "M", high[1], lookahead = barmerge.lookahead_on)
- float previousMonthLow = request.security(syminfo.tickerid, "M", low[1], lookahead = barmerge.lookahead_on)
- //======================================================================
- // 8. RANGE + MANIPULATION STRUCTURE
- // Candle [1] = potential Range candle
- // Candle [0] = potential Manipulation candle
- //======================================================================
- float rangeHigh = high[1]
- float rangeLow = low[1]
- float rangeOpen = open[1]
- float rangeClose = close[1]
- float rangeSize = math.max(rangeHigh - rangeLow, syminfo.mintick)
- float rangeMidpoint = (rangeHigh + rangeLow) * 0.5
- float rangeBodyPercent = math.abs(rangeClose - rangeOpen) / rangeSize * 100.0
- bool sweptHigh = high > rangeHigh
- bool sweptLow = low < rangeLow
- bool sweptBoth = sweptHigh and sweptLow
- bool singleSweep = sweptHigh != sweptLow
- bool closedInside = close < rangeHigh and close > rangeLow
- bool bullishDirectionOK = not requireDirectionalClose or close > open
- bool bearishDirectionOK = not requireDirectionalClose or close < open
- bool baseRules =
- barstate.isconfirmed and
- singleSweep and
- (not rejectDoubleSweep or not sweptBoth) and
- (not requireCloseInside or closedInside)
- bool bullishCandidate = baseRules and sweptLow and not sweptHigh and bullishDirectionOK
- bool bearishCandidate = baseRules and sweptHigh and not sweptLow and bearishDirectionOK
- //======================================================================
- // 8A. PROTOCOL 11 — CRT SEQUENCE / NESTED ACTIVE PARENT RANGE
- // Informational bonus only. Stable v16.9 qualification remains unchanged.
- //======================================================================
- bool parentContextActive =
- useNestedCRTContext and
- parentContextDirection != 0 and
- not na(parentContextHigh) and
- not na(parentContextLow)
- bool localRangeContainedInParent =
- parentContextActive and
- rangeHigh <= parentContextHigh and
- rangeLow >= parentContextLow
- bool localRangeOverlapsParent =
- parentContextActive and
- rangeHigh >= parentContextLow and
- rangeLow <= parentContextHigh
- bool nestedInsideParent =
- requireFullParentContainment ?
- localRangeContainedInParent :
- localRangeOverlapsParent
- bool nestedDirectionAligned =
- parentContextActive and (
- (bullishCandidate and parentContextDirection == 1) or
- (bearishCandidate and parentContextDirection == -1)
- )
- float parentContextMidpoint =
- parentContextActive ? (parentContextHigh + parentContextLow) * 0.5 : na
- bool nestedLocationAligned =
- parentContextActive and
- useParentPremiumDiscount and (
- (bullishCandidate and rangeMidpoint <= parentContextMidpoint) or
- (bearishCandidate and rangeMidpoint >= parentContextMidpoint)
- )
- int nestedContextScore =
- (nestedInsideParent ? 1 : 0) +
- (nestedDirectionAligned ? 1 : 0) +
- (nestedLocationAligned ? 1 : 0)
- bool meaningfulNestedContext =
- useNestedCRTContext and
- nestedContextScore >= minimumNestedContextScore
- //======================================================================
- // 9. SILENT PROTOCOL TESTS
- //======================================================================
- float atr = ta.atr(14)
- //======================================================================
- // 9A. PROTOCOL 10 — MEANINGFUL LIQUIDITY PURGE BONUS CONTEXT
- // This module is informational only and cannot reject a v16.7 CRT.
- //======================================================================
- float liquidityTolerance = atr[1] * liquidityToleranceATR
- float priorSwingHigh = ta.highest(high[2], liquiditySwingLookback)
- float priorSwingLow = ta.lowest(low[2], liquiditySwingLookback)
- bool purgedPDH = bearishCandidate and not na(previousDayHigh[1]) and high > previousDayHigh[1] + liquidityTolerance
- bool purgedPDL = bullishCandidate and not na(previousDayLow[1]) and low < previousDayLow[1] - liquidityTolerance
- bool purgedPWH = bearishCandidate and not na(previousWeekHigh[1]) and high > previousWeekHigh[1] + liquidityTolerance
- bool purgedPWL = bullishCandidate and not na(previousWeekLow[1]) and low < previousWeekLow[1] - liquidityTolerance
- bool purgedPMH = bearishCandidate and not na(previousMonthHigh[1]) and high > previousMonthHigh[1] + liquidityTolerance
- bool purgedPML = bullishCandidate and not na(previousMonthLow[1]) and low < previousMonthLow[1] - liquidityTolerance
- bool purgedSwingHigh = bearishCandidate and not na(priorSwingHigh) and high > priorSwingHigh + liquidityTolerance
- bool purgedSwingLow = bullishCandidate and not na(priorSwingLow) and low < priorSwingLow - liquidityTolerance
- int liquidityPurgeScore =
- (purgedPDH or purgedPDL ? 1 : 0) +
- (purgedPWH or purgedPWL ? 2 : 0) +
- (purgedPMH or purgedPML ? 3 : 0) +
- (purgedSwingHigh or purgedSwingLow ? 1 : 0)
- bool meaningfulLiquidityPurge =
- useLiquidityPurgeContext and
- liquidityPurgeScore >= minimumLiquidityPurgeScore
- float keyTolerance = atr[1] * keyLevelToleranceATR
- bool timeProtocol = isAllowedRangeHour(time[1])
- bool keyLevelProtocol =
- isNearLevel(rangeHigh, rangeLow, previousDayHigh[1], keyTolerance) or
- isNearLevel(rangeHigh, rangeLow, previousDayLow[1], keyTolerance) or
- isNearLevel(rangeHigh, rangeLow, previousWeekHigh[1], keyTolerance) or
- isNearLevel(rangeHigh, rangeLow, previousWeekLow[1], keyTolerance) or
- isNearLevel(rangeHigh, rangeLow, previousMonthHigh[1], keyTolerance) or
- isNearLevel(rangeHigh, rangeLow, previousMonthLow[1], keyTolerance)
- float manipulationRange = math.max(high - low, syminfo.mintick)
- float lowerRejectionPercent = (math.min(open, close) - low) / manipulationRange * 100.0
- float upperRejectionPercent = (high - math.max(open, close)) / manipulationRange * 100.0
- bool rejectionProtocol =
- (bullishCandidate and lowerRejectionPercent >= minimumRejectionPercent) or
- (bearishCandidate and upperRejectionPercent >= minimumRejectionPercent)
- bool midpointProtocol =
- (bullishCandidate and close > rangeMidpoint) or
- (bearishCandidate and close < rangeMidpoint)
- float rangeATRRatio = atr[1] > 0.0 ? rangeSize / atr[1] : 0.0
- bool rangeSizeProtocol = rangeATRRatio >= minimumRangeATR and rangeATRRatio <= maximumRangeATR
- bool bodyProtocol =
- rangeBodyPercent >= minimumRangeBodyPercent and
- rangeBodyPercent <= maximumRangeBodyPercent
- float poiTolerance = atr[1] * poiToleranceATR
- [bullPOITypes, bearPOITypes, bullPOIScore, bearPOIScore] = f_detectDirectionalPOIs(rangeHigh, rangeLow, poiTolerance)
- bool bullishPOIAligned = bullPOITypes >= minimumPOITypes and bullPOIScore >= minimumDirectionalPOIScore and (not rejectOpposingPOIDominance or bullPOIScore >= bearPOIScore)
- bool bearishPOIAligned = bearPOITypes >= minimumPOITypes and bearPOIScore >= minimumDirectionalPOIScore and (not rejectOpposingPOIDominance or bearPOIScore >= bullPOIScore)
- bool poiProtocol = (bullishCandidate and bullishPOIAligned) or (bearishCandidate and bearishPOIAligned)
- int poiTypeScore = bullishCandidate ? bullPOITypes : bearishCandidate ? bearPOITypes : 0
- int directionalPOIScore = bullishCandidate ? bullPOIScore : bearishCandidate ? bearPOIScore : 0
- bool hierarchyAligned =
- (bullishCandidate and parentCRTDirection == 1) or
- (bearishCandidate and parentCRTDirection == -1)
- bool hierarchyNeutral = parentCRTDirection == 0
- bool hierarchyOpposing =
- (bullishCandidate and parentCRTDirection == -1) or
- (bearishCandidate and parentCRTDirection == 1)
- bool hierarchyProtocol = hierarchyAligned or (hierarchyNeutral and neutralHierarchyPass)
- bool hierarchyHardPass =
- not useHierarchyProtocol or
- not rejectOpposingHierarchy or
- not hierarchyOpposing
- int alignedSMTCount =
- bullishCandidate ? bullishSMTCount :
- bearishCandidate ? bearishSMTCount : 0
- int opposingSMTCount =
- bullishCandidate ? bearishSMTCount :
- bearishCandidate ? bullishSMTCount : 0
- bool smtAligned = alignedSMTCount >= minimumSMTConfirmations
- bool smtOpposing = opposingSMTCount > alignedSMTCount and opposingSMTCount > 0
- bool smtNeutral = alignedSMTCount == 0 and opposingSMTCount == 0
- bool smtProtocol =
- smtAligned or
- (smtNeutral and allowNeutralSMT)
- bool smtHardPass =
- not useSMTProtocol or
- not rejectOpposingSMT or
- not smtOpposing
- int enabledProtocols =
- (useTimeProtocol ? 1 : 0) +
- (useKeyLevelProtocol ? 1 : 0) +
- (useRejectionProtocol ? 1 : 0) +
- (useMidpointProtocol ? 1 : 0) +
- (useRangeSizeProtocol ? 1 : 0) +
- (useBodyProtocol ? 1 : 0) +
- (usePOIProtocol ? 1 : 0) +
- (useHierarchyProtocol ? 1 : 0) +
- (useSMTProtocol ? 1 : 0)
- int protocolScore =
- (useTimeProtocol and timeProtocol ? 1 : 0) +
- (useKeyLevelProtocol and keyLevelProtocol ? 1 : 0) +
- (useRejectionProtocol and rejectionProtocol ? 1 : 0) +
- (useMidpointProtocol and midpointProtocol ? 1 : 0) +
- (useRangeSizeProtocol and rangeSizeProtocol ? 1 : 0) +
- (useBodyProtocol and bodyProtocol ? 1 : 0) +
- (usePOIProtocol and poiProtocol ? 1 : 0) +
- (useHierarchyProtocol and hierarchyProtocol ? 1 : 0) +
- (useSMTProtocol and smtProtocol ? 1 : 0)
- // Protocol 10 is a bonus only and is deliberately excluded from
- // enabledProtocols, protocolScore, effectiveMinimum and protocolQualified.
- int protocolScoreWithLiquidityBonus =
- protocolScore + (meaningfulLiquidityPurge ? 1 : 0)
- int protocolScoreWithContextBonuses =
- protocolScore +
- (meaningfulLiquidityPurge ? 1 : 0) +
- (meaningfulNestedContext ? 1 : 0)
- int effectiveMinimum = math.min(minimumProtocols, math.max(enabledProtocols, 1))
- bool protocolQualified = protocolScore >= effectiveMinimum and hierarchyHardPass and smtHardPass
- bool bullishManipulation = bullishCandidate and protocolQualified
- bool bearishManipulation = bearishCandidate and protocolQualified
- bool qualifiedCRT = bullishManipulation or bearishManipulation
- bool rawQualifiedCRT = bullishCandidate or bearishCandidate
- bool visibleCRT = showRawCRTForTesting ? rawQualifiedCRT : qualifiedCRT
- int currentQualifiedCRTDirection =
- bullishManipulation ? 1 :
- bearishManipulation ? -1 : 0
- bool dedicatedKeyLevelAligned =
- useDedicatedKeyLevelEngine and
- qualifiedCRT and
- sourceKeyLevelType != 0 and
- sourceKeyDirection == currentQualifiedCRTDirection
- int currentKeyLevelType =
- dedicatedKeyLevelAligned ? sourceKeyLevelType : 0
- int latestKeyLevelType =
- nz(ta.valuewhen(qualifiedCRT, currentKeyLevelType, 0), 0)
- int latestKeyLevelDirection =
- nz(ta.valuewhen(qualifiedCRT, currentQualifiedCRTDirection, 0), 0)
- int latestKeyLevelWeight =
- nz(ta.valuewhen(qualifiedCRT, dedicatedKeyLevelAligned ? sourceKeyLevelWeight : 0, 0), 0)
- //======================================================================
- // 11A. PROTOCOL 12 — POST-MANIPULATION DISPLACEMENT / DELIVERY
- // Delayed bonus context only. A CRT is first confirmed normally; the next
- // configured bars are then evaluated for directional delivery.
- //======================================================================
- int barsSinceQualifiedForDelivery = ta.barssince(qualifiedCRT)
- bool deliveryWindowActive =
- useDeliveryContext and
- not na(barsSinceQualifiedForDelivery) and
- barsSinceQualifiedForDelivery >= 1 and
- barsSinceQualifiedForDelivery <= deliveryWindowBars
- int deliveryCRTDirection = nz(ta.valuewhen(qualifiedCRT, bullishManipulation ? 1 : -1, 0), 0)
- float deliveryRangeHigh = ta.valuewhen(qualifiedCRT, rangeHigh, 0)
- float deliveryRangeLow = ta.valuewhen(qualifiedCRT, rangeLow, 0)
- float deliveryRangeMid = not na(deliveryRangeHigh) and not na(deliveryRangeLow) ? (deliveryRangeHigh + deliveryRangeLow) * 0.5 : na
- float deliveryATR = ta.atr(14)
- float deliveryBody = math.abs(close - open)
- bool directionalDelivery =
- deliveryWindowActive and (
- (deliveryCRTDirection == 1 and close > open) or
- (deliveryCRTDirection == -1 and close < open)
- )
- bool strongDeliveryBody =
- deliveryWindowActive and
- deliveryATR > 0 and
- deliveryBody >= deliveryATR * minimumDeliveryBodyATR
- bool deliveredThroughRangeMid =
- deliveryWindowActive and
- not na(deliveryRangeMid) and (
- (deliveryCRTDirection == 1 and close > deliveryRangeMid) or
- (deliveryCRTDirection == -1 and close < deliveryRangeMid)
- )
- bool bullishDeliveryFVG =
- deliveryWindowActive and
- deliveryCRTDirection == 1 and
- bar_index >= 2 and
- low > high[2]
- bool bearishDeliveryFVG =
- deliveryWindowActive and
- deliveryCRTDirection == -1 and
- bar_index >= 2 and
- high < low[2]
- bool deliveryFVGCreated = bullishDeliveryFVG or bearishDeliveryFVG
- int currentDeliveryScore =
- (directionalDelivery ? 1 : 0) +
- (strongDeliveryBody ? 1 : 0) +
- (deliveredThroughRangeMid ? 1 : 0) +
- (deliveryFVGCreated ? 1 : 0)
- var int deliveryContextScore = 0
- if qualifiedCRT
- deliveryContextScore := 0
- else if deliveryWindowActive
- deliveryContextScore := math.max(deliveryContextScore, currentDeliveryScore)
- else
- deliveryContextScore := 0
- bool priorDeliveryFVG =
- bar_index > 0 and deliveryFVGCreated[1]
- bool meaningfulDeliveryContext =
- useDeliveryContext and
- deliveryWindowActive and
- deliveryContextScore >= minimumDeliveryScore and
- (not requireDeliveryFVG or deliveryFVGCreated or priorDeliveryFVG)
- //======================================================================
- // 12. ACTIVE CRT LIFECYCLE
- // Status codes: 0=None, 1=Active Bullish, -1=Active Bearish,
- // 2=Target Reached, -2=Invalidated, 3=Expired.
- //======================================================================
- int newCRTDirection = bullishManipulation ? 1 : bearishManipulation ? -1 : 0
- bool newQualifiedCRT = newCRTDirection != 0
- int latestCRTDirection = nz(ta.valuewhen(newQualifiedCRT, newCRTDirection, 0), 0)
- float latestCRTRangeHigh = ta.valuewhen(newQualifiedCRT, rangeHigh, 0)
- float latestCRTRangeLow = ta.valuewhen(newQualifiedCRT, rangeLow, 0)
- int barsSinceQualifiedCRT = ta.barssince(newQualifiedCRT)
- bool hasTrackedCRT =
- latestCRTDirection != 0 and
- not na(latestCRTRangeHigh) and
- not na(latestCRTRangeLow) and
- not na(barsSinceQualifiedCRT)
- bool crtTargetReached =
- hasTrackedCRT and barsSinceQualifiedCRT > 0 and (
- latestCRTDirection == 1 ?
- (targetRequiresClose ? close >= latestCRTRangeHigh : high >= latestCRTRangeHigh) :
- (targetRequiresClose ? close <= latestCRTRangeLow : low <= latestCRTRangeLow)
- )
- bool crtInvalidated =
- hasTrackedCRT and barsSinceQualifiedCRT > 0 and (
- latestCRTDirection == 1 ?
- (invalidationRequiresClose ? close < latestCRTRangeLow : low < latestCRTRangeLow) :
- (invalidationRequiresClose ? close > latestCRTRangeHigh : high > latestCRTRangeHigh)
- )
- bool crtExpired = hasTrackedCRT and barsSinceQualifiedCRT > lifecycleExpiryBars
- bool crtLifecycleActive =
- hasTrackedCRT and
- not crtTargetReached and
- not crtInvalidated and
- not crtExpired
- int activeCRTDirection = crtLifecycleActive ? latestCRTDirection : 0
- int crtLifecycleStatus =
- crtLifecycleActive ? latestCRTDirection :
- crtTargetReached ? 2 :
- crtInvalidated ? -2 :
- crtExpired ? 3 : 0
- //======================================================================
- // 12A. PROTOCOL 13 — FAILED CRT / REVERSAL CONTEXT
- // A qualified CRT failure is opposite-direction information only.
- // This module is context/alert logic and does not alter CRT qualification.
- //======================================================================
- bool failureWindowActive =
- useFailedCRTContext and
- hasTrackedCRT and
- barsSinceQualifiedCRT > 0 and
- barsSinceQualifiedCRT <= failureWindowBars
- float failedCRTBoundary =
- latestCRTDirection == 1 ? latestCRTRangeLow :
- latestCRTDirection == -1 ? latestCRTRangeHigh : na
- bool failedThroughBoundary =
- failureWindowActive and (
- latestCRTDirection == 1 ?
- (failureRequiresClose ? close < failedCRTBoundary : low < failedCRTBoundary) :
- latestCRTDirection == -1 ?
- (failureRequiresClose ? close > failedCRTBoundary : high > failedCRTBoundary) :
- false
- )
- bool failureDirectionOK =
- not requireFailureDirectionalClose or (
- (latestCRTDirection == 1 and close < open) or
- (latestCRTDirection == -1 and close > open)
- )
- float failureATR = ta.atr(14)
- float failureBody = math.abs(close - open)
- bool failureBodyOK =
- failureATR > 0 and
- failureBody >= failureATR * minimumFailureBodyATR
- bool failedCRTEvent =
- failedThroughBoundary and
- failureDirectionOK and
- failureBodyOK and
- not failedThroughBoundary[1]
- int failedCRTReversalDirection =
- failedCRTEvent ?
- (latestCRTDirection == 1 ? -1 : latestCRTDirection == -1 ? 1 : 0) :
- 0
- int latestFailedCRTReversalDirection =
- nz(ta.valuewhen(failedCRTEvent, failedCRTReversalDirection, 0), 0)
- int barsSinceFailedCRT = ta.barssince(failedCRTEvent)
- bool failedCRTReversalContextActive =
- useFailedCRTContext and
- latestFailedCRTReversalDirection != 0 and
- not na(barsSinceFailedCRT) and
- barsSinceFailedCRT <= failureWindowBars
- //======================================================================
- // 12B. PROTOCOL 14 — CRT TARGET DELIVERY / DRAW ON LIQUIDITY
- // Selects the nearest valid opposite-side objective for the latest
- // qualified CRT. Context only; does not affect CRT qualification.
- // Target type codes:
- // 0=None, 1=Opposite CRT boundary, 2=Previous Day,
- // 3=Previous Week, 4=Previous Month, 5=Swing Liquidity.
- //======================================================================
- float targetATR = ta.atr(14)
- float targetTolerance = targetATR * targetReachToleranceATR
- float targetSwingHigh = ta.highest(high[1], targetSwingLookback)
- float targetSwingLow = ta.lowest(low[1], targetSwingLookback)
- f_pickNearestBullishTarget(
- float referencePrice,
- float crtHigh,
- float pdh,
- float pwh,
- float pmh,
- float swingHigh
- ) =>
- float selectedTarget = na
- int selectedType = 0
- float bestDistance = na
- if includeOppositeCRTRangeBoundary and not na(crtHigh) and crtHigh > referencePrice
- selectedTarget := crtHigh
- selectedType := 1
- bestDistance := crtHigh - referencePrice
- if includePreviousDayTarget and not na(pdh) and pdh > referencePrice
- float distance = pdh - referencePrice
- if na(bestDistance) or distance < bestDistance
- selectedTarget := pdh
- selectedType := 2
- bestDistance := distance
- if includePreviousWeekTarget and not na(pwh) and pwh > referencePrice
- float distance = pwh - referencePrice
- if na(bestDistance) or distance < bestDistance
- selectedTarget := pwh
- selectedType := 3
- bestDistance := distance
- if includePreviousMonthTarget and not na(pmh) and pmh > referencePrice
- float distance = pmh - referencePrice
- if na(bestDistance) or distance < bestDistance
- selectedTarget := pmh
- selectedType := 4
- bestDistance := distance
- if includeSwingLiquidityTarget and not na(swingHigh) and swingHigh > referencePrice
- float distance = swingHigh - referencePrice
- if na(bestDistance) or distance < bestDistance
- selectedTarget := swingHigh
- selectedType := 5
- [selectedTarget, selectedType]
- f_pickNearestBearishTarget(
- float referencePrice,
- float crtLow,
- float pdl,
- float pwl,
- float pml,
- float swingLow
- ) =>
- float selectedTarget = na
- int selectedType = 0
- float bestDistance = na
- if includeOppositeCRTRangeBoundary and not na(crtLow) and crtLow < referencePrice
- selectedTarget := crtLow
- selectedType := 1
- bestDistance := referencePrice - crtLow
- if includePreviousDayTarget and not na(pdl) and pdl < referencePrice
- float distance = referencePrice - pdl
- if na(bestDistance) or distance < bestDistance
- selectedTarget := pdl
- selectedType := 2
- bestDistance := distance
- if includePreviousWeekTarget and not na(pwl) and pwl < referencePrice
- float distance = referencePrice - pwl
- if na(bestDistance) or distance < bestDistance
- selectedTarget := pwl
- selectedType := 3
- bestDistance := distance
- if includePreviousMonthTarget and not na(pml) and pml < referencePrice
- float distance = referencePrice - pml
- if na(bestDistance) or distance < bestDistance
- selectedTarget := pml
- selectedType := 4
- bestDistance := distance
- if includeSwingLiquidityTarget and not na(swingLow) and swingLow < referencePrice
- float distance = referencePrice - swingLow
- if na(bestDistance) or distance < bestDistance
- selectedTarget := swingLow
- selectedType := 5
- [selectedTarget, selectedType]
- float latestQualifiedClose = ta.valuewhen(newQualifiedCRT, close, 0)
- [bullishDrawTarget, bullishDrawType] =
- f_pickNearestBullishTarget(
- latestQualifiedClose,
- latestCRTRangeHigh,
- previousDayHigh,
- previousWeekHigh,
- previousMonthHigh,
- targetSwingHigh
- )
- [bearishDrawTarget, bearishDrawType] =
- f_pickNearestBearishTarget(
- latestQualifiedClose,
- latestCRTRangeLow,
- previousDayLow,
- previousWeekLow,
- previousMonthLow,
- targetSwingLow
- )
- float activeDrawTarget =
- not useTargetDeliveryContext ? na :
- latestCRTDirection == 1 ? bullishDrawTarget :
- latestCRTDirection == -1 ? bearishDrawTarget :
- na
- int activeDrawTargetType =
- not useTargetDeliveryContext ? 0 :
- latestCRTDirection == 1 ? bullishDrawType :
- latestCRTDirection == -1 ? bearishDrawType :
- 0
- bool activeDrawTargetAvailable =
- useTargetDeliveryContext and
- hasTrackedCRT and
- not na(activeDrawTarget) and
- activeDrawTargetType != 0
- bool activeDrawTargetReached =
- activeDrawTargetAvailable and
- barsSinceQualifiedCRT > 0 and (
- latestCRTDirection == 1 ?
- high >= activeDrawTarget - targetTolerance :
- latestCRTDirection == -1 ?
- low <= activeDrawTarget + targetTolerance :
- false
- )
- bool newDrawTargetReached =
- activeDrawTargetReached and
- not activeDrawTargetReached[1]
- //======================================================================
- // 12C. CRT INTELLIGENCE SCORE / GRADE ENGINE
- // Snapshot grade at CRT confirmation. No future-bar information is used
- // in the initial grade, so historical grades do not improve retroactively.
- // Score components:
- // Base qualification=1, protocol depth=0..3, POI=1, SMT=1,
- // liquidity purge=1, nested HTF context=1, target available=1, HTF align=1.
- //======================================================================
- int protocolDepthScore =
- protocolScore >= 7 ? 1 :
- protocolScore >= 5 ? 1 :
- protocolScore >= 3 ? 1 : 0
- // Major context confirmations carry the grade.
- // A neutral or missing context never receives the same weight as alignment.
- int majorContextCount =
- (dedicatedKeyLevelAligned ? 1 : 0) +
- (smtAligned ? 1 : 0) +
- (meaningfulLiquidityPurge ? 1 : 0) +
- (hierarchyAligned ? 1 : 0) +
- (meaningfulNestedContext ? 1 : 0)
- int rawCRTIntelligenceScore =
- qualifiedCRT ?
- protocolDepthScore +
- (dedicatedKeyLevelAligned ? 2 : 0) +
- (smtAligned ? 2 : 0) +
- (meaningfulLiquidityPurge ? 2 : 0) +
- (hierarchyAligned ? 2 : 0) +
- (meaningfulNestedContext ? 1 : 0) :
- 0
- int boundedCRTIntelligenceScore = math.min(rawCRTIntelligenceScore, 10)
- // Hard context gates prevent a technically valid but context-poor CRT
- // from being labelled A or A+.
- bool aPlusGradeGate =
- majorContextCount >= 4 and
- dedicatedKeyLevelAligned and
- (hierarchyAligned or meaningfulNestedContext)
- bool aGradeGate =
- majorContextCount >= 3
- bool bGradeGate =
- majorContextCount >= 1
- int currentCRTGradeCode =
- not useIntelligenceGrade or not qualifiedCRT ? 0 :
- boundedCRTIntelligenceScore >= gradeAPlusThreshold and aPlusGradeGate ? 4 :
- boundedCRTIntelligenceScore >= gradeAThreshold and aGradeGate ? 3 :
- boundedCRTIntelligenceScore >= gradeBThreshold and bGradeGate ? 2 : 1
- int latestCRTIntelligenceScore =
- nz(ta.valuewhen(qualifiedCRT, boundedCRTIntelligenceScore, 0), 0)
- int latestCRTGradeCode =
- nz(ta.valuewhen(qualifiedCRT, currentCRTGradeCode, 0), 0)
- bool gradeAPlusCRT = qualifiedCRT and currentCRTGradeCode == 4
- bool gradeACRT = qualifiedCRT and currentCRTGradeCode == 3
- bool gradeBCRT = qualifiedCRT and currentCRTGradeCode == 2
- bool gradeCCRT = qualifiedCRT and currentCRTGradeCode == 1
- //======================================================================
- // 10. CLEAN SOURCE-TF COLORS + AUTO AMD WINDOWS ON LOWER TIMEFRAMES
- //======================================================================
- int chartSeconds = currentChartSeconds
- int projectionSeconds = timeframe.in_seconds(selectedHTF)
- bool isSourceTimeframe = not na(chartSeconds) and not na(projectionSeconds) and chartSeconds == projectionSeconds
- bool isLowerThanProjection = not na(chartSeconds) and not na(projectionSeconds) and chartSeconds < projectionSeconds
- // Only the selected source timeframe may color CRT candles. Lower timeframes
- // remain untouched so traders cannot confuse HTF projection with LTF CRTs.
- barcolor(
- colorCandles and isSourceTimeframe and visibleCRT ? rangeColor : na,
- offset = -1,
- title = "Qualified CRT Range Candle"
- )
- barcolor(
- colorCandles and isSourceTimeframe and visibleCRT ? manipulationColor : na,
- title = "Qualified CRT Manipulation Candle"
- )
- //----------------------------------------------------------------------
- // Ash ICT Fractal — exact original confirmed swing logic.
- // The centre candle is evaluated only after `periods` candles have closed
- // on its right, then the tiny marker is plotted back on that centre candle.
- //----------------------------------------------------------------------
- float ashICTFractalSourceHigh = ashICTFractalUseHighLow ? high : math.max(open, close)
- float ashICTFractalSourceLow = ashICTFractalUseHighLow ? low : math.min(open, close)
- bool ashICTFractalHigh = true
- bool ashICTFractalLow = true
- for ashFractalIndex = 1 to ashICTFractalPeriods
- ashICTFractalHigh :=
- ashICTFractalHigh and
- ashICTFractalSourceHigh[ashICTFractalPeriods] > ashICTFractalSourceHigh[ashICTFractalPeriods + ashFractalIndex] and
- ashICTFractalSourceHigh[ashICTFractalPeriods] >= ashICTFractalSourceHigh[ashICTFractalPeriods - ashFractalIndex]
- ashICTFractalLow :=
- ashICTFractalLow and
- ashICTFractalSourceLow[ashICTFractalPeriods] < ashICTFractalSourceLow[ashICTFractalPeriods + ashFractalIndex] and
- ashICTFractalSourceLow[ashICTFractalPeriods] <= ashICTFractalSourceLow[ashICTFractalPeriods - ashFractalIndex]
- // Label objects preserve the original tiny triangle appearance without
- // consuming plot slots. This keeps the full engine below TradingView's
- // 64-plot runtime limit.
- if showAshICTFractal and showAshICTFractalHigh and ashICTFractalHigh
- label.new(
- x = bar_index - ashICTFractalPeriods,
- y = ashICTFractalSourceHigh[ashICTFractalPeriods],
- text = "",
- xloc = xloc.bar_index,
- yloc = yloc.abovebar,
- color = ashICTFractalHighColor,
- style = label.style_triangleup,
- textcolor = ashICTFractalHighColor,
- size = size.tiny
- )
- if showAshICTFractal and showAshICTFractalLow and ashICTFractalLow
- label.new(
- x = bar_index - ashICTFractalPeriods,
- y = ashICTFractalSourceLow[ashICTFractalPeriods],
- text = "",
- xloc = xloc.bar_index,
- yloc = yloc.belowbar,
- color = ashICTFractalLowColor,
- style = label.style_triangledown,
- textcolor = ashICTFractalLowColor,
- size = size.tiny
- )
- //----------------------------------------------------------------------
- // HTF qualification mirrored inside the selected source timeframe.
- //----------------------------------------------------------------------
- f_htfQualifiedCRT() =>
- float pRangeHigh = high[1]
- float pRangeLow = low[1]
- float pRangeOpen = open[1]
- float pRangeClose = close[1]
- float pRangeSize = math.max(pRangeHigh - pRangeLow, syminfo.mintick)
- float pRangeMid = (pRangeHigh + pRangeLow) * 0.5
- float pRangeBodyPct = math.abs(pRangeClose - pRangeOpen) / pRangeSize * 100.0
- float pAtr = ta.atr(14)
- bool pSweptHigh = high > pRangeHigh
- bool pSweptLow = low < pRangeLow
- bool pSingleSweep = pSweptHigh != pSweptLow
- bool pClosedInside = close < pRangeHigh and close > pRangeLow
- bool pBullDirection = not requireDirectionalClose or close > open
- bool pBearDirection = not requireDirectionalClose or close < open
- bool pBase =
- barstate.isconfirmed and
- pSingleSweep and
- (not rejectDoubleSweep or not (pSweptHigh and pSweptLow)) and
- (not requireCloseInside or pClosedInside)
- bool pBull = pBase and pSweptLow and not pSweptHigh and pBullDirection
- bool pBear = pBase and pSweptHigh and not pSweptLow and pBearDirection
- float pManipRange = math.max(high - low, syminfo.mintick)
- float pLowerReject = (math.min(open, close) - low) / pManipRange * 100.0
- float pUpperReject = (high - math.max(open, close)) / pManipRange * 100.0
- bool pTime = isAllowedRangeHour(time[1])
- bool pReject = (pBull and pLowerReject >= minimumRejectionPercent) or (pBear and pUpperReject >= minimumRejectionPercent)
- bool pMid = (pBull and close > pRangeMid) or (pBear and close < pRangeMid)
- float pAtrRatio = pAtr[1] > 0.0 ? pRangeSize / pAtr[1] : 0.0
- bool pSize = pAtrRatio >= minimumRangeATR and pAtrRatio <= maximumRangeATR
- bool pBody = pRangeBodyPct >= minimumRangeBodyPercent and pRangeBodyPct <= maximumRangeBodyPercent
- float pPoiTolerance = pAtr[1] * poiToleranceATR
- [pBullPOITypes, pBearPOITypes, pBullPOIScore, pBearPOIScore] = f_detectDirectionalPOIs(pRangeHigh, pRangeLow, pPoiTolerance)
- bool pBullPOIAligned = pBullPOITypes >= minimumPOITypes and pBullPOIScore >= minimumDirectionalPOIScore and (not rejectOpposingPOIDominance or pBullPOIScore >= pBearPOIScore)
- bool pBearPOIAligned = pBearPOITypes >= minimumPOITypes and pBearPOIScore >= minimumDirectionalPOIScore and (not rejectOpposingPOIDominance or pBearPOIScore >= pBullPOIScore)
- bool pPOI = (pBull and pBullPOIAligned) or (pBear and pBearPOIAligned)
- // Key-level requests are deliberately excluded here to avoid nested MTF requests.
- int pEnabled =
- (useTimeProtocol ? 1 : 0) +
- (useRejectionProtocol ? 1 : 0) +
- (useMidpointProtocol ? 1 : 0) +
- (useRangeSizeProtocol ? 1 : 0) +
- (useBodyProtocol ? 1 : 0) +
- (usePOIProtocol ? 1 : 0)
- int pScore =
- (useTimeProtocol and pTime ? 1 : 0) +
- (useRejectionProtocol and pReject ? 1 : 0) +
- (useMidpointProtocol and pMid ? 1 : 0) +
- (useRangeSizeProtocol and pSize ? 1 : 0) +
- (useBodyProtocol and pBody ? 1 : 0) +
- (usePOIProtocol and pPOI ? 1 : 0)
- int pMinimum = math.min(minimumProtocols, math.max(pEnabled, 1))
- (pBull or pBear) and pScore >= pMinimum
- bool projectedQualified = request.security(
- syminfo.tickerid,
- selectedHTF,
- f_htfQualifiedCRT(),
- gaps = barmerge.gaps_off,
- lookahead = barmerge.lookahead_off
- )
- f_htfDirection() =>
- float pRangeHigh = high[1]
- float pRangeLow = low[1]
- bool pSweptHigh = high > pRangeHigh
- bool pSweptLow = low < pRangeLow
- bool pSingleSweep = pSweptHigh != pSweptLow
- bool pClosedInside = close < pRangeHigh and close > pRangeLow
- bool pBase = barstate.isconfirmed and pSingleSweep and (not requireCloseInside or pClosedInside)
- pBase and pSweptLow and not pSweptHigh ? 1 : pBase and pSweptHigh and not pSweptLow ? -1 : 0
- int projectedDirection = request.security(
- syminfo.tickerid,
- selectedHTF,
- f_htfDirection(),
- gaps = barmerge.gaps_off,
- lookahead = barmerge.lookahead_off
- )
- int projectedRangeStart = request.security(syminfo.tickerid, selectedHTF, time[1], gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off)
- int projectedManipulationStart = request.security(syminfo.tickerid, selectedHTF, time, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off)
- int projectedDistributionStart = request.security(syminfo.tickerid, selectedHTF, time_close, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off)
- int projectedDistributionEnd = request.security(syminfo.tickerid, selectedHTF, time_close + (time_close - time), gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off)
- bool newProjectedSetup =
- enableHTFProjection and
- isLowerThanProjection and
- projectedQualified and
- (na(projectedManipulationStart[1]) or projectedManipulationStart != projectedManipulationStart[1])
- // No projection objects are drawn.
- // `newProjectedSetup` is retained only to update the internal HTF direction
- // and Distribution-window timing used by the optional LTF structure engine.
- //======================================================================
- // 11. DIRECTIONAL LTF STRUCTURE UNLOCK
- // After the qualified HTF Manipulation closes, the scanner activates only
- // inside the HTF Distribution window. It does not issue buy/sell signals.
- // It simply colors the aligned LTF CRT Range candle blue and its confirmed
- // Manipulation candle yellow, leaving execution and Fib placement to trader.
- //======================================================================
- var int activeHTFDirection = 0
- var int activeDistributionStart = na
- var int activeDistributionEnd = na
- var int ltfStructuresThisSetup = 0
- if newProjectedSetup
- activeHTFDirection := projectedDirection
- activeDistributionStart := projectedDistributionStart
- activeDistributionEnd := projectedDistributionEnd
- ltfStructuresThisSetup := 0
- float chartMinutes = not na(chartSeconds) ? chartSeconds / 60.0 : na
- // v20.5 — Explicit native-timeframe boundary guard.
- // TradingView reports 15m as both 900 seconds and a native minute interval.
- // Accept either representation so the exact 15m boundary cannot fall
- // between the HTF-analysis and LTF-execution dashboard branches.
- bool executionChartByNativeTF =
- timeframe.isminutes and
- timeframe.multiplier <= maximumExecutionMinutes
- bool executionChartBySeconds =
- not na(chartMinutes) and
- chartMinutes <= maximumExecutionMinutes
- bool executionTimeframeAllowed =
- isLowerThanProjection and
- (executionChartByNativeTF or executionChartBySeconds)
- bool insideDistributionWindow =
- not na(activeDistributionStart) and
- not na(activeDistributionEnd) and
- time >= activeDistributionStart and
- time < activeDistributionEnd
- float localRangeHigh = high[1]
- float localRangeLow = low[1]
- float localRangeMid = (localRangeHigh + localRangeLow) * 0.5
- float localManipulationRange = math.max(high - low, syminfo.mintick)
- bool localSweptLow = low < localRangeLow and high <= localRangeHigh
- bool localSweptHigh = high > localRangeHigh and low >= localRangeLow
- bool localClosedInside = close > localRangeLow and close < localRangeHigh
- float localLowerReject = (math.min(open, close) - low) / localManipulationRange * 100.0
- float localUpperReject = (high - math.max(open, close)) / localManipulationRange * 100.0
- bool localBullishCRT =
- barstate.isconfirmed and
- localSweptLow and
- (not localRequireCloseInside or localClosedInside) and
- (not localRequireMidpoint or close > localRangeMid) and
- localLowerReject >= localMinimumRejection
- bool localBearishCRT =
- barstate.isconfirmed and
- localSweptHigh and
- (not localRequireCloseInside or localClosedInside) and
- (not localRequireMidpoint or close < localRangeMid) and
- localUpperReject >= localMinimumRejection
- bool structureEngineUnlocked =
- enableExecutionEngine and
- executionTimeframeAllowed and
- insideDistributionWindow and
- activeHTFDirection != 0
- bool structureQuotaAvailable = not firstExecutionOnly or ltfStructuresThisSetup == 0
- bool bullishLTFStructure = structureEngineUnlocked and structureQuotaAvailable and activeHTFDirection == 1 and localBullishCRT
- bool bearishLTFStructure = structureEngineUnlocked and structureQuotaAvailable and activeHTFDirection == -1 and localBearishCRT
- bool qualifiedLTFStructure = bullishLTFStructure or bearishLTFStructure
- if qualifiedLTFStructure
- ltfStructuresThisSetup += 1
- // The Range candle is confirmed only when its following Manipulation candle
- // closes, so it is colored retrospectively with offset -1.
- barcolor(
- colorUnlockedLTFStructure and qualifiedLTFStructure ? ltfRangeColor : na,
- offset = -1,
- title = "Unlocked LTF CRT Range Candle"
- )
- barcolor(
- colorUnlockedLTFStructure and qualifiedLTFStructure ? ltfManipulationColor : na,
- title = "Unlocked LTF CRT Manipulation Candle"
- )
- // Scores remain available in TradingView's Data Window only.
- plot(protocolScore, "CRT Protocol Score", display = display.data_window)
- plot(effectiveMinimum, "CRT Minimum Required", display = display.data_window)
- plot(directionalPOIScore, "Directional POI Score", display = display.data_window)
- plot(timeProtocol ? 1 : 0, "Market Time Protocol Passed", display = display.data_window)
- string activeMarketProfile = f_selectedMarketProfile()
- int activeMarketProfileCode =
- activeMarketProfile == "Forex" ? 1 :
- activeMarketProfile == "Indices" ? 2 :
- activeMarketProfile == "Futures" ? 3 :
- activeMarketProfile == "Crypto" ? 4 :
- activeMarketProfile == "Commodities" ? 5 : 6
- plot(parentCRTDirection, "Parent HTF CRT Direction", display = display.data_window)
- plot(hierarchyAligned ? 1 : hierarchyOpposing ? -1 : 0, "Hierarchy Alignment State", display = display.data_window)
- plot(activeCRTDirection, "Active CRT Direction", display = display.data_window)
- plot(crtLifecycleStatus, "CRT Lifecycle Status", display = display.data_window)
- plot(barsSinceQualifiedCRT, "Bars Since Qualified CRT", display = display.data_window)
- plot(bullishSMTCount, "Bullish SMT Confirmation Count", display = display.data_window)
- plot(bearishSMTCount, "Bearish SMT Confirmation Count", display = display.data_window)
- plot(smtAligned ? 1 : smtOpposing ? -1 : 0, "SMT Matrix Alignment State", display = display.data_window)
- plot(liquidityPurgeScore, "Liquidity Purge Score", display = display.data_window)
- plot(meaningfulLiquidityPurge ? 1 : 0, "Meaningful Liquidity Purge", display = display.data_window)
- plot(parentContextDirection, "Active Parent CRT Context Direction", display = display.data_window)
- plot(nestedContextScore, "Nested HTF CRT Context Score", display = display.data_window)
- plot(meaningfulNestedContext ? 1 : 0, "Meaningful Nested HTF Context", display = display.data_window)
- plot(deliveryContextScore, "Displacement Delivery Score", display = display.data_window)
- plot(meaningfulDeliveryContext ? 1 : 0, "Meaningful Displacement Delivery", display = display.data_window)
- plot(deliveryCRTDirection, "Delivery CRT Direction", display = display.data_window)
- plot(failedCRTEvent ? 1 : 0, "Failed CRT Event", display = display.data_window)
- plot(failedCRTReversalContextActive ? 1 : 0, "Failed CRT Reversal Context Active", display = display.data_window)
- plot(barsSinceFailedCRT, "Bars Since Failed CRT", display = display.data_window)
- plot(activeDrawTarget, "Active CRT Draw Target", display = display.data_window)
- plot(activeDrawTargetType, "Active CRT Draw Target Type", display = display.data_window)
- plot(activeDrawTargetAvailable ? 1 : 0, "CRT Draw Target Available", display = display.data_window)
- plot(activeDrawTargetReached ? 1 : 0, "CRT Draw Target Reached", display = display.data_window)
- plot(boundedCRTIntelligenceScore, "CRT Intelligence Score", display = display.data_window)
- plot(currentCRTGradeCode, "CRT Grade Code (4=A+, 3=A, 2=B, 1=C)", display = display.data_window)
- plot(majorContextCount, "Major Grade Context Count", display = display.data_window)
- //======================================================================
- // 14A. CRT INTELLIGENCE DASHBOARD — PREVIEW
- // Latest qualified CRT context only. No chart lines or labels are drawn.
- // Dedicated source-timeframe engine reports exact FVG, IFVG,
- // Order Block, Breaker, or Rejection Block context for the latest CRT.
- //======================================================================
- f_dashboardPosition(string p) =>
- p == "Top Left" ? position.top_left :
- p == "Bottom Right" ? position.bottom_right :
- p == "Bottom Left" ? position.bottom_left :
- position.top_right
- f_dashboardTextSize(string s) =>
- s == "Tiny" ? size.tiny :
- s == "Normal" ? size.normal :
- size.small
- f_gradeText(int gradeCode) =>
- gradeCode == 4 ? "A+" :
- gradeCode == 3 ? "A" :
- gradeCode == 2 ? "B" :
- gradeCode == 1 ? "C" : "—"
- f_keyLevelTypeText(int keyType, int direction) =>
- string directionText =
- direction == 1 ? "BULLISH " :
- direction == -1 ? "BEARISH " : ""
- string typeText =
- keyType == 1 ? "FVG" :
- keyType == 2 ? "IFVG" :
- keyType == 3 ? "ORDER BLOCK" :
- keyType == 4 ? "BREAKER" :
- keyType == 5 ? "REJECTION BLOCK" :
- "NONE"
- keyType == 0 ? "NONE" : directionText + typeText
- f_targetTypeText(int targetType, int direction) =>
- targetType == 1 ? (direction == 1 ? "CRT HIGH" : direction == -1 ? "CRT LOW" : "CRT") :
- targetType == 2 ? (direction == 1 ? "PDH" : direction == -1 ? "PDL" : "PD") :
- targetType == 3 ? (direction == 1 ? "PWH" : direction == -1 ? "PWL" : "PW") :
- targetType == 4 ? (direction == 1 ? "PMH" : direction == -1 ? "PML" : "PM") :
- targetType == 5 ? (direction == 1 ? "SWING HIGH" : direction == -1 ? "SWING LOW" : "SWING") :
- "NONE"
- // v19.0 includes State Colour Intelligence and Multi-Timeframe Execution Guidance.
- // ACTIVE keeps directional colour, DELIVERED is always success-green,
- // FAILED / INVALID are red, and inactive lifecycle states are neutral grey.
- f_stateColor(string state) =>
- state == "BULLISH" or state == "BULLISH ACTIVE" or state == "ALIGNED" or state == "CONFIRMED" or state == "ACTIVE" or state == "REACHED" or state == "STRONG" or state == "BULL REVERSAL" or state == "BULLISH DELIVERED" or state == "BEARISH DELIVERED" or state == "DELIVERED" ? color.new(color.green, 72) :
- state == "BEARISH" or state == "BEARISH ACTIVE" or state == "BULLISH FAILED" or state == "BEARISH FAILED" or state == "BULLISH INVALID" or state == "BEARISH INVALID" or state == "CONFLICT" or state == "FAILED" or state == "INVALID" or state == "BEAR REVERSAL" ? color.new(color.red, 72) :
- state == "NEUTRAL" or state == "MODERATE" ? color.new(color.orange, 72) :
- state == "LTF CRT ALIGNED" ? color.new(color.green, 72) :
- state == "LTF CRT OPPOSED" ? color.new(color.red, 72) :
- state == "EXPIRED" or state == "WAITING" ? color.new(color.gray, 72) :
- color.new(color.gray, 82)
- //======================================================================
- // 14A. TRADE READINESS & ACTION ENGINE — v18.7
- // Converts the existing CRT intelligence into a clear action state.
- // A failed CRT creates reversal context only; it never creates an
- // automatic entry. Reversal entries still require an opposite-direction
- // lower-timeframe CRT confirmation.
- //======================================================================
- // v19.2 Unified lifecycle arbitration.
- // The first terminal event wins for the current CRT. If target delivery
- // occurs before (or on the same bar as) failure, the setup remains DELIVERED.
- // A later failure/invalidation cannot rewrite a completed objective.
- bool crtBoundaryTargetEvent = crtTargetReached and not crtTargetReached[1]
- bool unifiedTargetEvent = crtBoundaryTargetEvent or newDrawTargetReached
- int barsSinceUnifiedTarget = ta.barssince(unifiedTargetEvent)
- bool unifiedTargetBelongsToCurrentCRT =
- hasTrackedCRT and
- not na(barsSinceUnifiedTarget) and
- barsSinceUnifiedTarget <= barsSinceQualifiedCRT
- bool unifiedFailureBelongsToCurrentCRT =
- hasTrackedCRT and
- not na(barsSinceFailedCRT) and
- barsSinceFailedCRT <= barsSinceQualifiedCRT
- // Larger bars-since means the event happened earlier. Equality gives
- // target delivery priority when both events occur on the same candle.
- bool targetWonLifecycle =
- unifiedTargetBelongsToCurrentCRT and
- (not unifiedFailureBelongsToCurrentCRT or barsSinceUnifiedTarget >= barsSinceFailedCRT)
- bool failureWonLifecycle =
- unifiedFailureBelongsToCurrentCRT and
- not targetWonLifecycle
- bool tradeTargetReached = targetWonLifecycle
- bool tradeReversalActive = failedCRTReversalContextActive and failureWonLifecycle
- bool tradeInvalid =
- hasTrackedCRT and
- crtInvalidated and
- not tradeTargetReached and
- not failureWonLifecycle
- bool tradeExpired =
- hasTrackedCRT and
- crtExpired and
- not tradeReversalActive and
- not tradeTargetReached and
- not tradeInvalid
- bool tradeProtocolAligned =
- not hierarchyOpposing and
- not smtOpposing and
- latestCRTIntelligenceScore >= gradeBThreshold
- bool tradeReady =
- not tradeReversalActive and
- crtLifecycleActive and
- meaningfulDeliveryContext and
- tradeProtocolAligned
- bool tradeWatch =
- not tradeReversalActive and
- crtLifecycleActive and
- not tradeReady
- string dashboardTradeStatus =
- tradeReversalActive ? "REVERSAL ACTIVE" :
- tradeTargetReached ? "TARGET REACHED" :
- tradeInvalid ? "INVALID" :
- tradeExpired ? "EXPIRED" :
- tradeReady ? "READY" :
- tradeWatch ? "WATCH" :
- "WAIT"
- int executionDirection =
- tradeReversalActive ? latestFailedCRTReversalDirection :
- crtLifecycleActive ? activeCRTDirection : 0
- string dashboardExecutionBias =
- executionDirection == 1 ? "SEEK LONG" :
- executionDirection == -1 ? "SEEK SHORT" :
- "NEUTRAL"
- string dashboardEntryCondition =
- tradeReversalActive ?
- (executionDirection == 1 ? "WAIT BULLISH LTF CRT" : "WAIT BEARISH LTF CRT") :
- tradeReady ?
- (executionDirection == 1 ? "BULLISH CONFIRMATION" : "BEARISH CONFIRMATION") :
- tradeWatch ?
- (meaningfulDeliveryContext ? "WAIT PROTOCOL ALIGNMENT" : "WAIT FOR DELIVERY") :
- tradeTargetReached ? "NO CHASE • TARGET DONE" :
- tradeInvalid ? "NO TRADE" :
- tradeExpired ? "WAIT NEW CRT" :
- "WAIT QUALIFIED CRT"
- string dashboardRiskState =
- tradeReversalActive ? "ORIGINAL CRT FAILED" :
- tradeTargetReached ? "OBJECTIVE DELIVERED" :
- tradeInvalid ? "INVALIDATED" :
- tradeExpired ? "SETUP EXPIRED" :
- tradeReady ? "CONFIRMED • MANAGE RISK" :
- tradeWatch ? "UNCONFIRMED" :
- "NO ACTIVE RISK"
- string dashboardSetupAge =
- hasTrackedCRT and not na(barsSinceQualifiedCRT) ?
- str.tostring(barsSinceQualifiedCRT) + " / " + str.tostring(lifecycleExpiryBars) + " BARS" :
- "—"
- f_tradeStatusColor(string state, int direction) =>
- state == "READY" or state == "RE-ARMED" or state == "EXECUTION ARMED" or state == "ENTRY CONFIRMED" or state == "DELIVERING" ? (direction == -1 ? color.new(color.red, 60) : color.new(color.green, 60)) :
- state == "REVERSAL ACTIVE" ? (direction == -1 ? color.new(color.red, 60) : direction == 1 ? color.new(color.green, 60) : color.new(color.orange, 65)) :
- state == "INVALID" ? color.new(color.red, 58) :
- state == "TARGET REACHED" ? color.new(color.green, 72) :
- state == "WATCH" ? color.new(color.orange, 65) :
- state == "EXPIRED" ? color.new(color.gray, 72) :
- color.new(color.gray, 82)
- //======================================================================
- // 14B. UNIFIED STORY ENGINE — v19.2
- // On execution charts (15m and below by default), the active H1 story
- // controls directional guidance. The LTF may confirm that direction or
- // remain neutral, but an opposing local CRT cannot flip the HTF bias.
- //======================================================================
- f_executionParentTF() =>
- timeframe.isminutes and timeframe.multiplier <= 15 ? "60" :
- timeframe.isminutes and timeframe.multiplier <= 60 ? "240" :
- not na(chartMinutes) and chartMinutes <= 15.0 ? "60" :
- not na(chartMinutes) and chartMinutes <= 60.0 ? "240" :
- selectedHTF
- string inheritanceParentTF = f_executionParentTF()
- // v20.0 Narrative Transition Memory + Fresh Narrative Validation.
- // Every qualified CRT receives a monotonically increasing source-timeframe ID.
- // After a terminal narrative, a later ID is considered fresh but remains locked
- // until direction, HTF context, delivery, and objective availability validate.
- int narrativeSerial = int(ta.cum(qualifiedCRT ? 1 : 0))
- int latestQualifiedNarrativeID = nz(ta.valuewhen(qualifiedCRT, narrativeSerial, 0), 0)
- int latestQualifiedNarrativeTime = nz(ta.valuewhen(qualifiedCRT, time, 0), 0)
- int latestNarrativeDirection = nz(ta.valuewhen(qualifiedCRT, currentQualifiedCRTDirection, 0), 0)
- bool latestNarrativeHierarchyPass = ta.valuewhen(qualifiedCRT, hierarchyProtocol and hierarchyHardPass, 0)
- bool terminalNarrativeState = tradeTargetReached or tradeInvalid or tradeExpired
- bool terminalNarrativeEvent = terminalNarrativeState and not terminalNarrativeState[1]
- int latestTerminalNarrativeTime = nz(ta.valuewhen(terminalNarrativeEvent, time, 0), 0)
- int latestTerminalNarrativeID = nz(ta.valuewhen(terminalNarrativeEvent, latestQualifiedNarrativeID, 0), 0)
- bool hasFreshNarrativeIdentity =
- enableNarrativeFreshnessEngine and
- latestTerminalNarrativeTime > 0 and
- latestQualifiedNarrativeID > latestTerminalNarrativeID and
- latestQualifiedNarrativeTime > latestTerminalNarrativeTime
- int freshNarrativeAge =
- hasFreshNarrativeIdentity and not na(barsSinceQualifiedCRT) ?
- barsSinceQualifiedCRT : 100000
- bool freshDirectionConfirmed =
- hasFreshNarrativeIdentity and
- latestNarrativeDirection != 0
- bool freshHTFContextConfirmed =
- hasFreshNarrativeIdentity and
- (not requireFreshHierarchyAlignment or latestNarrativeHierarchyPass)
- bool freshDeliveryConfirmed =
- hasFreshNarrativeIdentity and
- (not requireFreshDeliveryConfirmation or meaningfulDeliveryContext)
- bool freshObjectiveOpen =
- hasFreshNarrativeIdentity and
- crtLifecycleActive and
- not tradeTargetReached and
- not tradeInvalid and
- not tradeExpired
- bool freshValidationTimedOut =
- hasFreshNarrativeIdentity and
- freshNarrativeAge > freshValidationWindowBars and
- not freshDeliveryConfirmed
- // v20.1 Narrative Validation Failure Memory.
- // Once a fresh narrative ID fails validation, that exact ID is permanently
- // rejected. Later changes in delivery or context cannot revive it. Only a
- // strictly newer qualified narrative ID may enter validation.
- var int latestRejectedNarrativeID = 0
- bool freshValidationFailureNow =
- enableFreshNarrativeValidation and
- hasFreshNarrativeIdentity and
- latestQualifiedNarrativeID > latestRejectedNarrativeID and (
- not freshDirectionConfirmed or
- not freshHTFContextConfirmed or
- not freshObjectiveOpen or
- freshValidationTimedOut
- )
- if freshValidationFailureNow
- latestRejectedNarrativeID := latestQualifiedNarrativeID
- bool freshNarrativePermanentlyRejected =
- hasFreshNarrativeIdentity and
- latestQualifiedNarrativeID <= latestRejectedNarrativeID
- bool freshValidationRejected =
- enableFreshNarrativeValidation and
- freshNarrativePermanentlyRejected
- bool freshValidationConfirmed =
- hasFreshNarrativeIdentity and
- not freshNarrativePermanentlyRejected and
- (
- not enableFreshNarrativeValidation or
- (
- freshDirectionConfirmed and
- freshHTFContextConfirmed and
- freshDeliveryConfirmed and
- freshObjectiveOpen and
- not freshValidationTimedOut
- )
- )
- // State codes: 0 = none, 1 = validating, 2 = confirmed, 3 = permanently rejected.
- int freshValidationState =
- not hasFreshNarrativeIdentity ? 0 :
- freshValidationRejected ? 3 :
- freshValidationConfirmed ? 2 : 1
- int freshValidationScore =
- (freshDirectionConfirmed ? 1 : 0) +
- (freshHTFContextConfirmed ? 1 : 0) +
- (freshDeliveryConfirmed ? 1 : 0) +
- (freshObjectiveOpen ? 1 : 0)
- //======================================================================
- // 20.3 NARRATIVE DELIVERY & OBJECTIVE TRACKER
- // State codes:
- // 0=Waiting, 1=Candidate validating, 2=Confirmed,
- // 3=Delivery active, 4=Objective near, 5=Objective completed,
- // 6=Invalidated, 7=Expired, 8=Permanently rejected.
- //======================================================================
- float narrativeTrackerATR = ta.atr(14)
- float narrativeObjectiveDistance =
- activeDrawTargetAvailable ? math.abs(activeDrawTarget - close) : na
- bool narrativeObjectiveNear =
- enableNarrativeObjectiveTracker and
- activeDrawTargetAvailable and
- not activeDrawTargetReached and
- narrativeTrackerATR > 0 and
- narrativeObjectiveDistance <= narrativeTrackerATR * objectiveNearThresholdATR
- bool narrativeDeliveryStarted =
- enableNarrativeObjectiveTracker and
- freshValidationConfirmed and
- crtLifecycleActive and
- meaningfulDeliveryContext
- int narrativeTrackerState =
- not enableNarrativeObjectiveTracker ? 0 :
- freshValidationRejected ? 8 :
- tradeTargetReached ? 5 :
- tradeInvalid ? 6 :
- tradeExpired ? 7 :
- hasFreshNarrativeIdentity and freshValidationState == 1 ? 1 :
- freshValidationConfirmed and narrativeObjectiveNear ? 4 :
- narrativeDeliveryStarted ? 3 :
- freshValidationConfirmed ? 2 :
- 0
- string narrativeTrackerStateText =
- narrativeTrackerState == 1 ? "CANDIDATE VALIDATING" :
- narrativeTrackerState == 2 ? "CONFIRMED • WAIT DELIVERY" :
- narrativeTrackerState == 3 ? "DELIVERY ACTIVE" :
- narrativeTrackerState == 4 ? "OBJECTIVE NEAR" :
- narrativeTrackerState == 5 ? "OBJECTIVE COMPLETED" :
- narrativeTrackerState == 6 ? "NARRATIVE INVALIDATED" :
- narrativeTrackerState == 7 ? "NARRATIVE EXPIRED" :
- narrativeTrackerState == 8 ? "PERMANENTLY REJECTED" :
- "WAIT NEW NARRATIVE"
- string narrativeObjectiveTypeText =
- activeDrawTargetType == 1 ? (latestCRTDirection == 1 ? "CRT HIGH" : latestCRTDirection == -1 ? "CRT LOW" : "CRT") :
- activeDrawTargetType == 2 ? (latestCRTDirection == 1 ? "PDH" : latestCRTDirection == -1 ? "PDL" : "PD") :
- activeDrawTargetType == 3 ? (latestCRTDirection == 1 ? "PWH" : latestCRTDirection == -1 ? "PWL" : "PW") :
- activeDrawTargetType == 4 ? (latestCRTDirection == 1 ? "PMH" : latestCRTDirection == -1 ? "PML" : "PM") :
- activeDrawTargetType == 5 ? (latestCRTDirection == 1 ? "SWING HIGH" : latestCRTDirection == -1 ? "SWING LOW" : "SWING") :
- "NONE"
- string narrativeObjectiveText =
- not enableNarrativeObjectiveTracker ? "DISABLED" :
- narrativeTrackerState == 8 ? "WAIT NEWER NARRATIVE ID" :
- narrativeTrackerState == 5 ? "DELIVERED • NO CHASE" :
- narrativeTrackerState == 6 or narrativeTrackerState == 7 ? "CLOSED • WAIT NEW CRT" :
- not activeDrawTargetAvailable ? "NO OPEN OBJECTIVE" :
- narrativeObjectiveTypeText + " • " + str.tostring(activeDrawTarget, format.mintick)
- color narrativeTrackerColor =
- narrativeTrackerState == 3 or narrativeTrackerState == 4 or narrativeTrackerState == 5 ? color.new(color.green, 58) :
- narrativeTrackerState == 1 or narrativeTrackerState == 2 ? color.new(color.orange, 62) :
- narrativeTrackerState == 6 or narrativeTrackerState == 8 ? color.new(color.red, 58) :
- color.new(color.gray, 78)
- plot(narrativeTrackerState, "Narrative Delivery Tracker State", display = display.data_window)
- bool localNarrativeFresh =
- hasFreshNarrativeIdentity and
- crtLifecycleActive and
- freshNarrativeAge <= freshNarrativeDisplayBars
- bool localNarrativeRearmed =
- enableNarrativeRearmEngine and
- crtLifecycleActive and
- freshValidationConfirmed and
- freshNarrativeAge <= rearmDisplayParentBars
- [inheritedReversalActiveRaw, inheritedReversalDirectionRaw, inheritedLifecycleActiveRaw, inheritedActiveDirectionRaw, inheritedTargetReachedRaw, inheritedInvalidRaw, inheritedExpiredRaw, inheritedSetupAgeRaw, inheritedQualifiedNarrativeTimeRaw, inheritedTerminalNarrativeTimeRaw, inheritedNarrativeRearmedRaw, inheritedQualifiedNarrativeIDRaw, inheritedTerminalNarrativeIDRaw, inheritedNarrativeFreshRaw, inheritedFreshNarrativeAgeRaw, inheritedFreshValidationStateRaw, inheritedFreshValidationScoreRaw, inheritedFreshDirectionRaw, inheritedRejectedNarrativeIDRaw, inheritedNarrativeTrackerStateRaw, inheritedNarrativeObjectiveRaw, inheritedNarrativeObjectiveTypeRaw] =
- request.security(
- syminfo.tickerid,
- inheritanceParentTF,
- [tradeReversalActive, executionDirection, crtLifecycleActive and not tradeTargetReached and not tradeInvalid, activeCRTDirection, tradeTargetReached, tradeInvalid, tradeExpired, nz(barsSinceQualifiedCRT, 0), latestQualifiedNarrativeTime, latestTerminalNarrativeTime, localNarrativeRearmed, latestQualifiedNarrativeID, latestTerminalNarrativeID, localNarrativeFresh, freshNarrativeAge, freshValidationState, freshValidationScore, latestNarrativeDirection, latestRejectedNarrativeID, narrativeTrackerState, activeDrawTarget, activeDrawTargetType],
- gaps = barmerge.gaps_off,
- lookahead = barmerge.lookahead_off
- )
- // Every execution chart reads a dedicated parent channel. The parent channel
- // is displayed even when it is terminal/neutral, while the local channel is
- // kept separate for entry timing and local expiry.
- bool executionChildMode =
- executionTimeframeAllowed and
- inheritanceParentTF != timeframe.period
- bool inheritedFreshNarrative =
- enableNarrativeRearmEngine and
- enableNarrativeFreshnessEngine and
- inheritedLifecycleActiveRaw and
- inheritedQualifiedNarrativeIDRaw > inheritedTerminalNarrativeIDRaw and
- inheritedQualifiedNarrativeTimeRaw > inheritedTerminalNarrativeTimeRaw
- bool inheritedFreshValidationConfirmed = inheritedFreshValidationStateRaw == 2
- bool inheritedFreshValidationRejected = inheritedFreshValidationStateRaw == 3
- bool inheritedFreshValidationPending = inheritedFreshValidationStateRaw == 1
- //======================================================================
- // v20.4 NARRATIVE GENERATION HANDOFF ENGINE
- // A terminal narrative remains available in memory for audit, but it is
- // archived and loses ownership of all live guidance until a newer ID
- // qualifies and validates.
- //======================================================================
- bool localNarrativeArchived =
- enableNarrativeRearmEngine and
- terminalNarrativeState and
- not hasFreshNarrativeIdentity
- bool inheritedNarrativeArchived =
- enableNarrativeRearmEngine and
- (inheritedTargetReachedRaw or inheritedInvalidRaw or inheritedExpiredRaw) and
- not inheritedFreshNarrative
- bool narrativeGenerationWaiting =
- executionChildMode ? inheritedNarrativeArchived : localNarrativeArchived
- // v20.5 — One display lock controls every student-facing dashboard row.
- // Local diagnostics may continue running in the background, but no local
- // event is presented as actionable while the owning narrative is archived.
- bool parentStandDownDisplay = executionChildMode and inheritedNarrativeArchived
- bool localStandDownDisplay = not executionChildMode and localNarrativeArchived
- bool dashboardStandDownDisplay = parentStandDownDisplay or localStandDownDisplay
- int archivedNarrativeID =
- executionChildMode ? inheritedTerminalNarrativeIDRaw : latestTerminalNarrativeID
- string archivedNarrativeReason =
- executionChildMode ?
- (inheritedTargetReachedRaw ? "OBJECTIVE COMPLETE" :
- inheritedInvalidRaw ? "INVALIDATED" :
- inheritedExpiredRaw ? "EXPIRED" :
- "TERMINAL") :
- (tradeTargetReached ? "OBJECTIVE COMPLETE" :
- tradeInvalid ? "INVALIDATED" :
- tradeExpired ? "EXPIRED" :
- "TERMINAL")
- string inheritedNarrativeTrackerText =
- inheritedNarrativeTrackerStateRaw == 1 ? "CANDIDATE VALIDATING" :
- inheritedNarrativeTrackerStateRaw == 2 ? "CONFIRMED • WAIT DELIVERY" :
- inheritedNarrativeTrackerStateRaw == 3 ? "DELIVERY ACTIVE" :
- inheritedNarrativeTrackerStateRaw == 4 ? "OBJECTIVE NEAR" :
- inheritedNarrativeTrackerStateRaw == 5 ? "OBJECTIVE COMPLETED" :
- inheritedNarrativeTrackerStateRaw == 6 ? "NARRATIVE INVALIDATED" :
- inheritedNarrativeTrackerStateRaw == 7 ? "NARRATIVE EXPIRED" :
- inheritedNarrativeTrackerStateRaw == 8 ? "PERMANENTLY REJECTED" :
- "WAIT NEW NARRATIVE"
- string inheritedObjectiveTypeText =
- inheritedNarrativeObjectiveTypeRaw == 1 ? (inheritedActiveDirectionRaw == 1 ? "CRT HIGH" : inheritedActiveDirectionRaw == -1 ? "CRT LOW" : "CRT") :
- inheritedNarrativeObjectiveTypeRaw == 2 ? (inheritedActiveDirectionRaw == 1 ? "PDH" : inheritedActiveDirectionRaw == -1 ? "PDL" : "PD") :
- inheritedNarrativeObjectiveTypeRaw == 3 ? (inheritedActiveDirectionRaw == 1 ? "PWH" : inheritedActiveDirectionRaw == -1 ? "PWL" : "PW") :
- inheritedNarrativeObjectiveTypeRaw == 4 ? (inheritedActiveDirectionRaw == 1 ? "PMH" : inheritedActiveDirectionRaw == -1 ? "PML" : "PM") :
- inheritedNarrativeObjectiveTypeRaw == 5 ? (inheritedActiveDirectionRaw == 1 ? "SWING HIGH" : inheritedActiveDirectionRaw == -1 ? "SWING LOW" : "SWING") :
- "NONE"
- string inheritedNarrativeObjectiveText =
- inheritedNarrativeTrackerStateRaw == 8 ? "WAIT NEWER PARENT ID" :
- inheritedNarrativeTrackerStateRaw == 5 ? "DELIVERED • NO CHASE" :
- inheritedNarrativeTrackerStateRaw == 6 or inheritedNarrativeTrackerStateRaw == 7 ? "CLOSED • WAIT NEW PARENT CRT" :
- not na(inheritedNarrativeObjectiveRaw) and inheritedNarrativeObjectiveTypeRaw != 0 ?
- inheritedObjectiveTypeText + " • " + str.tostring(inheritedNarrativeObjectiveRaw, format.mintick) :
- "NO OPEN OBJECTIVE"
- bool inheritedNarrativeStandDown =
- enableNarrativeRearmEngine and (
- (
- (inheritedTargetReachedRaw or inheritedInvalidRaw or inheritedExpiredRaw) and
- not inheritedFreshNarrative
- ) or
- (
- inheritedFreshNarrative and
- not inheritedFreshValidationConfirmed
- )
- )
- // v19.8 keeps the v19.7 Parent Completion Stand-Down Lock and adds
- // explicit reset/re-arm identity checking.
- // IMPORTANT: The inherited story is derived directly from the parent timeframe
- // on every bar. It is never stored in a chart-timeframe `var`, so a 1m/5m local
- // expiry cannot erase it and a stale child chart cannot keep an old parent bias.
- // Parent delivery/invalidation clears the inherited bias consistently on every LTF.
- int inheritedParentStoryType =
- inheritedNarrativeStandDown ? 0 :
- inheritedReversalActiveRaw and inheritedReversalDirectionRaw != 0 ? 2 :
- inheritedLifecycleActiveRaw and inheritedActiveDirectionRaw != 0 ? 1 : 0
- int inheritedHTFDirection =
- inheritedParentStoryType == 2 ? inheritedReversalDirectionRaw :
- inheritedParentStoryType == 1 ? inheritedActiveDirectionRaw : 0
- bool htfBiasInheritanceLock =
- executionTimeframeAllowed and
- inheritedHTFDirection != 0
- bool inheritedAlignedLocalCRT =
- htfBiasInheritanceLock and (
- (inheritedHTFDirection == 1 and localBullishCRT) or
- (inheritedHTFDirection == -1 and localBearishCRT)
- )
- bool inheritedOpposingLocalCRT =
- htfBiasInheritanceLock and (
- (inheritedHTFDirection == 1 and localBearishCRT) or
- (inheritedHTFDirection == -1 and localBullishCRT)
- )
- // Classify the complete local story (active CRT or failed-CRT reversal),
- // not only the current two-candle candidate.
- int localStoryDirection =
- tradeReversalActive ? latestFailedCRTReversalDirection :
- crtLifecycleActive ? activeCRTDirection : 0
- bool localStoryAligned =
- htfBiasInheritanceLock and
- localStoryDirection != 0 and
- localStoryDirection == inheritedHTFDirection
- bool localStoryOpposed =
- htfBiasInheritanceLock and
- localStoryDirection != 0 and
- localStoryDirection != inheritedHTFDirection
- //======================================================================
- // 20.7 ONE-SHOT EXECUTION AUTHORIZATION ENGINE — CORE RETAINED IN v20.9.1
- // State codes:
- // 0=Locked/Waiting, 1=Parent active / setup building, 2=Execution armed,
- // 3=Entry confirmed, 4=Delivery in progress, 5=Target reached,
- // 6=Invalidated, 7=Expired.
- //
- // The engine never places an order. It grants one execution permission per
- // inherited parent narrative ID only after:
- // • the parent narrative owns a confirmed directional bias,
- // • an undelivered objective remains with sufficient room,
- // • an aligned qualified LTF CRT confirms, and
- // • the LTF CRT reacts from liquidity or a directional key level/POI.
- //======================================================================
- int executionAuthorizationCurrentParentID = inheritedQualifiedNarrativeIDRaw
- bool executionAuthorizationParentValidationPass =
- not inheritedFreshNarrative or inheritedFreshValidationConfirmed
- bool executionAuthorizationParentActive =
- enableExecutionAuthorizationEngine and
- executionChildMode and
- htfBiasInheritanceLock and
- executionAuthorizationCurrentParentID > 0 and
- executionAuthorizationParentValidationPass and
- not inheritedTargetReachedRaw and
- not inheritedInvalidRaw and
- not inheritedExpiredRaw and
- not inheritedNarrativeArchived
- float executionAuthorizationATR = ta.atr(14)
- float executionAuthorizationObjectiveDistance =
- inheritedHTFDirection == 1 and not na(inheritedNarrativeObjectiveRaw) ? inheritedNarrativeObjectiveRaw - close :
- inheritedHTFDirection == -1 and not na(inheritedNarrativeObjectiveRaw) ? close - inheritedNarrativeObjectiveRaw :
- na
- bool executionAuthorizationObjectiveOpen =
- executionAuthorizationParentActive and
- not na(executionAuthorizationObjectiveDistance) and
- executionAuthorizationObjectiveDistance > 0
- bool executionAuthorizationRoomPass =
- not authorizationRequireObjectiveRoom or
- (
- executionAuthorizationObjectiveOpen and
- executionAuthorizationATR > 0 and
- executionAuthorizationObjectiveDistance >= executionAuthorizationATR * authorizationMinimumRoomATR and
- inheritedNarrativeTrackerStateRaw != 4
- )
- bool executionAuthorizationWindowPass =
- not authorizationRequireDistributionWindow or insideDistributionWindow
- bool executionAuthorizationAlignedQualifiedCRT =
- barstate.isconfirmed and
- qualifiedCRT and
- currentQualifiedCRTDirection != 0 and
- currentQualifiedCRTDirection == inheritedHTFDirection
- bool executionAuthorizationLiquidityPass =
- executionAuthorizationAlignedQualifiedCRT and meaningfulLiquidityPurge
- bool executionAuthorizationPOIPass =
- executionAuthorizationAlignedQualifiedCRT and
- dedicatedKeyLevelAligned and
- currentKeyLevelType != 0
- bool executionAuthorizationContextPass =
- not authorizationRequireLiquidityOrPOI or
- executionAuthorizationLiquidityPass or
- executionAuthorizationPOIPass
- bool executionAuthorizationSetupArmed =
- executionAuthorizationParentActive and
- executionAuthorizationRoomPass and
- executionAuthorizationWindowPass
- bool executionAuthorizationTrigger =
- executionAuthorizationSetupArmed and
- executionAuthorizationAlignedQualifiedCRT and
- executionAuthorizationContextPass
- var int executionAuthorizationState = 0
- var int executionAuthorizationParentID = 0
- var int executionAuthorizationDirection = 0
- var int executionAuthorizationConsumedParentID = 0
- var int executionAuthorizationEntryBar = na
- var float executionAuthorizationEntryPrice = na
- bool executionAuthorizationIdentityChanged =
- executionChildMode and
- executionAuthorizationCurrentParentID > 0 and
- executionAuthorizationCurrentParentID != executionAuthorizationParentID
- if executionAuthorizationIdentityChanged
- executionAuthorizationParentID := executionAuthorizationCurrentParentID
- executionAuthorizationDirection := inheritedFreshDirectionRaw != 0 ? inheritedFreshDirectionRaw : inheritedHTFDirection
- executionAuthorizationState := 0
- executionAuthorizationEntryBar := na
- executionAuthorizationEntryPrice := na
- if not enableExecutionAuthorizationEngine or not executionChildMode
- executionAuthorizationState := 0
- else if inheritedTargetReachedRaw and executionAuthorizationParentID > 0
- executionAuthorizationState := 5
- else if inheritedInvalidRaw and executionAuthorizationParentID > 0
- executionAuthorizationState := 6
- else if inheritedExpiredRaw and executionAuthorizationParentID > 0
- executionAuthorizationState := 7
- else if inheritedFreshValidationPending or inheritedFreshValidationRejected or inheritedNarrativeArchived
- executionAuthorizationState := 0
- else if executionAuthorizationParentActive
- bool executionAuthorizationAlreadyConsumed =
- executionAuthorizationConsumedParentID == executionAuthorizationCurrentParentID
- if executionAuthorizationAlreadyConsumed
- executionAuthorizationState := not na(executionAuthorizationEntryBar) and bar_index == executionAuthorizationEntryBar ? 3 : 4
- else if executionAuthorizationTrigger
- executionAuthorizationState := 3
- executionAuthorizationConsumedParentID := executionAuthorizationCurrentParentID
- executionAuthorizationDirection := inheritedHTFDirection
- executionAuthorizationEntryBar := bar_index
- executionAuthorizationEntryPrice := close
- else if executionAuthorizationSetupArmed
- executionAuthorizationState := 2
- else
- executionAuthorizationState := 1
- else
- executionAuthorizationState := 0
- bool executionAuthorizationConsumed =
- executionAuthorizationCurrentParentID > 0 and
- executionAuthorizationConsumedParentID == executionAuthorizationCurrentParentID
- bool executionAuthorizationNoChase =
- executionAuthorizationParentActive and
- authorizationRequireObjectiveRoom and
- not executionAuthorizationRoomPass
- string executionAuthorizationStateText =
- not enableExecutionAuthorizationEngine ? "AUTHORIZATION DISABLED" :
- not executionChildMode ? "PARENT-TF GUIDANCE ONLY" :
- inheritedFreshValidationPending ? "LOCKED • VALIDATING PARENT" :
- inheritedFreshValidationRejected ? "LOCKED • PARENT REJECTED" :
- inheritedNarrativeArchived ? "LOCKED • OLD PARENT ARCHIVED" :
- inheritedTargetReachedRaw or executionAuthorizationState == 5 ? "TARGET REACHED • STAND DOWN" :
- inheritedInvalidRaw or executionAuthorizationState == 6 ? "INVALIDATED • WAIT NEW PARENT" :
- inheritedExpiredRaw or executionAuthorizationState == 7 ? "EXPIRED • WAIT NEW PARENT" :
- not htfBiasInheritanceLock ? "LOCKED • WAIT PARENT STORY" :
- executionAuthorizationNoChase ? "LOCKED • NO CHASE • OBJECTIVE NEAR" :
- authorizationRequireDistributionWindow and not executionAuthorizationWindowPass ? "LOCKED • WAIT DISTRIBUTION WINDOW" :
- executionAuthorizationState == 4 ? "DELIVERY #" + str.tostring(executionAuthorizationParentID) + " IN PROGRESS • NO RE-ENTRY" :
- executionAuthorizationState == 3 ? "ENTRY CONFIRMED #" + str.tostring(executionAuthorizationParentID) + " • ONE-SHOT AUTHORIZED" :
- executionAuthorizationState == 2 ? "EXECUTION ARMED #" + str.tostring(executionAuthorizationParentID) + " • WAIT ALIGNED CRT" :
- executionAuthorizationState == 1 ? "PARENT #" + str.tostring(executionAuthorizationParentID) + " ACTIVE • BUILDING SETUP" :
- "LOCKED"
- color executionAuthorizationStateColor =
- inheritedFreshValidationPending ? color.new(color.orange, 62) :
- inheritedFreshValidationRejected ? color.new(color.red, 58) :
- inheritedNarrativeArchived ? color.new(color.orange, 65) :
- executionAuthorizationState == 3 or executionAuthorizationState == 4 ? color.new(color.green, 55) :
- executionAuthorizationState == 2 ? color.new(color.orange, 55) :
- executionAuthorizationState == 5 ? color.new(color.green, 72) :
- executionAuthorizationState == 6 ? color.new(color.red, 55) :
- executionAuthorizationState == 7 ? color.new(color.gray, 68) :
- executionAuthorizationNoChase ? color.new(color.orange, 62) :
- color.new(color.gray, 78)
- int displayExecutionDirection = htfBiasInheritanceLock ? inheritedHTFDirection : executionDirection
- string displayTradeStatus =
- parentStandDownDisplay ? "STAND DOWN" :
- localStandDownDisplay ? "STAND DOWN" :
- executionChildMode and enableExecutionAuthorizationEngine ?
- (inheritedTargetReachedRaw or executionAuthorizationState == 5 ? "TARGET REACHED" :
- inheritedInvalidRaw or executionAuthorizationState == 6 ? "INVALID" :
- inheritedExpiredRaw or executionAuthorizationState == 7 ? "EXPIRED" :
- executionAuthorizationState == 4 ? "DELIVERING" :
- executionAuthorizationState == 3 ? "ENTRY CONFIRMED" :
- executionAuthorizationState == 2 ? "EXECUTION ARMED" :
- executionAuthorizationState == 1 ? "WATCH" :
- "WAIT") :
- executionChildMode ?
- (inheritedTargetReachedRaw ? "TARGET REACHED" :
- inheritedInvalidRaw ? "INVALID" :
- inheritedExpiredRaw ? "EXPIRED" :
- htfBiasInheritanceLock ?
- (inheritedNarrativeRearmedRaw ? "RE-ARMED" : inheritedAlignedLocalCRT or localStoryAligned ? "READY" : "WATCH") :
- "WAIT") :
- (tradeTargetReached ? "TARGET REACHED" :
- tradeInvalid ? "INVALID" :
- tradeExpired ? "EXPIRED" :
- localNarrativeRearmed ? "RE-ARMED" :
- dashboardTradeStatus)
- string displayExecutionBias =
- dashboardStandDownDisplay ? "STAND DOWN" :
- executionChildMode and inheritedTargetReachedRaw ? "STAND DOWN" :
- executionChildMode and (inheritedInvalidRaw or inheritedExpiredRaw) ? "NEUTRAL" :
- not executionChildMode and tradeTargetReached ? "STAND DOWN" :
- not executionChildMode and (tradeInvalid or tradeExpired) ? "NEUTRAL" :
- displayExecutionDirection == 1 ? "SEEK LONG" :
- displayExecutionDirection == -1 ? "SEEK SHORT" :
- "NEUTRAL"
- string displayEntryCondition =
- parentStandDownDisplay ? "NO CHASE • WAIT PARENT RE-ARM" :
- localStandDownDisplay ? "NO CHASE • WAIT NEW CRT" :
- executionChildMode and enableExecutionAuthorizationEngine ?
- (inheritedTargetReachedRaw ? "NO CHASE • PARENT TARGET DONE" :
- inheritedInvalidRaw or inheritedExpiredRaw ? "WAIT NEW PARENT CRT" :
- inheritedFreshValidationPending ? "WAIT PARENT VALIDATION" :
- inheritedFreshValidationRejected ? "WAIT NEWER PARENT ID" :
- executionAuthorizationState == 4 ? "NO RE-ENTRY • MANAGE DELIVERY" :
- executionAuthorizationState == 3 ? "ENTRY CONFIRMED • APPLY RISK PLAN" :
- executionAuthorizationNoChase ? "NO CHASE • INSUFFICIENT OBJECTIVE ROOM" :
- authorizationRequireDistributionWindow and not executionAuthorizationWindowPass ? "WAIT HTF DISTRIBUTION WINDOW" :
- executionAuthorizationState == 2 ?
- (authorizationRequireLiquidityOrPOI ? "WAIT ALIGNED QUALIFIED CRT AT LIQUIDITY / POI" : "WAIT ALIGNED QUALIFIED LTF CRT") :
- executionAuthorizationState == 1 ? "WAIT SETUP CONDITIONS" :
- "WAIT PARENT STORY") :
- executionChildMode ?
- (inheritedTargetReachedRaw ? "NO CHASE • PARENT TARGET DONE" :
- inheritedInvalidRaw ? "WAIT NEW PARENT CRT" :
- inheritedExpiredRaw ? "WAIT NEW PARENT CRT" :
- htfBiasInheritanceLock ?
- (inheritedOpposingLocalCRT or localStoryOpposed ? "IGNORE OPPOSING LTF STORY" :
- inheritedAlignedLocalCRT or localStoryAligned ? "ALIGNED LTF STORY CONFIRMED" :
- displayExecutionDirection == 1 ? "WAIT BULLISH LTF CRT" : "WAIT BEARISH LTF CRT") :
- "WAIT PARENT STORY") :
- tradeTargetReached ? "NO CHASE • TARGET DONE" :
- tradeInvalid ? "NO TRADE • WAIT NEW CRT" :
- tradeExpired ? "WAIT NEW QUALIFIED CRT" :
- dashboardEntryCondition
- string displayRiskState =
- parentStandDownDisplay ? "PARENT NARRATIVE ARCHIVED" :
- localStandDownDisplay ? "NARRATIVE ARCHIVED" :
- executionChildMode and enableExecutionAuthorizationEngine ?
- (inheritedTargetReachedRaw ? "PARENT OBJECTIVE DELIVERED" :
- inheritedInvalidRaw ? "PARENT INVALIDATED" :
- inheritedExpiredRaw ? "PARENT EXPIRED" :
- executionAuthorizationState == 4 ? "ACTIVE EXECUTION • ONE-SHOT CONSUMED" :
- executionAuthorizationState == 3 ? "AUTHORIZED • APPLY RISK PLAN" :
- executionAuthorizationState == 2 ? "NO POSITION • AUTHORIZATION ARMED" :
- executionAuthorizationNoChase ? "NO RISK • NO CHASE" :
- htfBiasInheritanceLock ? "NO ACTIVE RISK • PARENT ACTIVE" : "NO PARENT RISK") :
- executionChildMode ?
- (inheritedTargetReachedRaw ? "PARENT OBJECTIVE DELIVERED" :
- inheritedInvalidRaw ? "PARENT INVALIDATED" :
- inheritedExpiredRaw ? "PARENT EXPIRED" :
- htfBiasInheritanceLock ? "PARENT STORY ACTIVE" : "NO PARENT RISK") :
- dashboardRiskState
- string displaySetupAge =
- parentStandDownDisplay ? "ARCHIVED PARENT #" + str.tostring(inheritedTerminalNarrativeIDRaw) :
- localStandDownDisplay ? "ARCHIVED NARRATIVE #" + str.tostring(latestTerminalNarrativeID) :
- executionChildMode ? str.tostring(inheritedSetupAgeRaw) + " / " + str.tostring(lifecycleExpiryBars) + " PARENT BARS" : dashboardSetupAge
- // v20.6 Parent Story Synchronization (retained in v20.9.1).
- // Candidate state is displayed before the inherited directional lock is allowed
- // to activate. This keeps child dashboards synchronized with the live parent ID
- // and validation score without weakening the validation safety lock.
- string inheritedFreshDirectionText =
- inheritedFreshDirectionRaw == 1 ? "BULLISH" :
- inheritedFreshDirectionRaw == -1 ? "BEARISH" :
- "DIRECTIONAL"
- string inheritedParentStory =
- inheritedFreshNarrative and inheritedFreshValidationPending ?
- inheritanceParentTF + " " + inheritedFreshDirectionText +
- " CANDIDATE #" + str.tostring(inheritedQualifiedNarrativeIDRaw) +
- " • VALIDATING " + str.tostring(inheritedFreshValidationScoreRaw) + "/4" :
- inheritedFreshNarrative and inheritedFreshValidationRejected ?
- inheritanceParentTF + " " + inheritedFreshDirectionText +
- " CANDIDATE #" + str.tostring(inheritedQualifiedNarrativeIDRaw) +
- " • REJECTED" :
- inheritedFreshNarrative and inheritedFreshValidationConfirmed and inheritedParentStoryType != 0 ?
- inheritanceParentTF + " " + inheritedFreshDirectionText +
- " NARRATIVE ACTIVE #" + str.tostring(inheritedQualifiedNarrativeIDRaw) +
- (inheritedNarrativeRearmedRaw ? " • RE-ARMED" : "") :
- inheritedParentStoryType == 2 ?
- inheritanceParentTF + (inheritedHTFDirection == 1 ? " BULL REVERSAL" : " BEAR REVERSAL") :
- inheritedParentStoryType == 1 ?
- inheritanceParentTF + (inheritedHTFDirection == 1 ? " BULLISH NARRATIVE ACTIVE" : " BEARISH NARRATIVE ACTIVE") :
- inheritedTargetReachedRaw ? inheritanceParentTF + " OBJECTIVE DELIVERED • STAND DOWN" :
- inheritedInvalidRaw ? inheritanceParentTF + " INVALIDATED • RESET" :
- inheritedExpiredRaw ? inheritanceParentTF + " EXPIRED • RESET" :
- inheritanceParentTF + " WAITING FOR NEW NARRATIVE"
- // v18.8 lifecycle clarity: the CRT row describes both direction and lifecycle.
- // This prevents a delivered historical bearish CRT from looking like a live short bias.
- string localLifecycleText =
- localNarrativeArchived ? "ARCHIVED" :
- tradeReversalActive ?
- (latestCRTDirection == 1 ? "BULLISH FAILED" : latestCRTDirection == -1 ? "BEARISH FAILED" : "FAILED") :
- tradeTargetReached ? "DELIVERED" :
- tradeInvalid ? "INVALID" :
- tradeExpired ? "EXPIRED" :
- crtLifecycleActive ?
- (activeCRTDirection == 1 ? "BULLISH ACTIVE" : activeCRTDirection == -1 ? "BEARISH ACTIVE" : "ACTIVE") :
- "WAITING"
- string dashboardCRTState =
- executionChildMode and inheritedNarrativeArchived ? "PARENT STORY ARCHIVED" :
- not executionChildMode and localNarrativeArchived ? "NARRATIVE ARCHIVED" :
- htfBiasInheritanceLock and (inheritedOpposingLocalCRT or localStoryOpposed) ? "LTF STORY OPPOSED" :
- htfBiasInheritanceLock and (inheritedAlignedLocalCRT or localStoryAligned) ? "LTF STORY ALIGNED" :
- htfBiasInheritanceLock ? "LTF WAITING" :
- localLifecycleText
- string dashboardHTF =
- hierarchyAligned ? "ALIGNED" :
- hierarchyOpposing ? "CONFLICT" :
- "NEUTRAL"
- string dashboardPOI =
- f_keyLevelTypeText(latestKeyLevelType, latestKeyLevelDirection)
- string dashboardKeyLevelTF =
- latestKeyLevelType != 0 ? selectedHTF : "—"
- string dashboardPurge =
- meaningfulLiquidityPurge ?
- (latestCRTDirection == 1 ? "SSL PURGED" : latestCRTDirection == -1 ? "BSL PURGED" : "CONFIRMED") :
- "NONE"
- string dashboardSMT =
- smtAligned ?
- (latestCRTDirection == 1 ? "BULLISH" : latestCRTDirection == -1 ? "BEARISH" : "CONFIRMED") :
- smtOpposing ? "CONFLICT" :
- "NEUTRAL"
- string dashboardNested =
- meaningfulNestedContext ? "ALIGNED" :
- parentContextActive ? "NEUTRAL" :
- "NONE"
- string dashboardDelivery =
- executionChildMode and inheritedTargetReachedRaw ? "DELIVERED" :
- executionChildMode and inheritedInvalidRaw ? "INVALID" :
- executionChildMode and inheritedExpiredRaw ? "EXPIRED" :
- not executionChildMode and tradeTargetReached ? "DELIVERED" :
- not executionChildMode and tradeInvalid ? "INVALID" :
- not executionChildMode and tradeExpired ? "EXPIRED" :
- htfBiasInheritanceLock ?
- (localStoryAligned ? "ALIGNED" : localStoryOpposed ? "OPPOSED" : "WAITING") :
- meaningfulDeliveryContext ? "CONFIRMED" :
- tradeReversalActive ? "FAILED" :
- "WAITING"
- string dashboardTarget =
- narrativeGenerationWaiting ? "ARCHIVED" :
- f_targetTypeText(activeDrawTargetType, latestCRTDirection)
- string dashboardTargetStatus =
- narrativeGenerationWaiting ? "CLOSED" :
- tradeTargetReached ? "REACHED" :
- activeDrawTargetAvailable and not tradeReversalActive and not tradeInvalid ? "ACTIVE" :
- "NONE"
- //======================================================================
- // 20.8 DASHBOARD CLARITY LAYER
- // Display-only separation of the owning parent objective from local CRT
- // diagnostics. The authorization state machine and room threshold are not
- // modified here.
- //======================================================================
- bool dashboardRoomFilterFailed =
- executionChildMode and
- enableExecutionAuthorizationEngine and
- executionAuthorizationNoChase
- string dashboardObjectiveLabel =
- executionChildMode ? "PARENT OBJECTIVE" : "DRAW ON LIQUIDITY"
- string dashboardObjectiveDisplay =
- executionChildMode ?
- (inheritedNarrativeObjectiveText + (dashboardRoomFilterFailed ? " • TOO NEAR" : "")) :
- dashboardTarget
- string dashboardLocalTargetLabel =
- executionChildMode ? "LOCAL TARGET" : "TARGET STATUS"
- string dashboardLocalTargetDisplay =
- executionChildMode ?
- (tradeTargetReached ? "OLD TARGET REACHED • INFO ONLY" :
- tradeInvalid ? "LOCAL TARGET INVALID • INFO ONLY" :
- tradeExpired ? "LOCAL TARGET EXPIRED • INFO ONLY" :
- activeDrawTargetAvailable and not tradeReversalActive ? "LOCAL TARGET ACTIVE • INFO ONLY" :
- "NO ACTIVE LOCAL TARGET") :
- dashboardTargetStatus
- string dashboardFailure =
- htfBiasInheritanceLock ?
- (localStoryOpposed ? "OPPOSED TO HTF" : localStoryAligned ? "ALIGNED TO HTF" : "NONE") :
- tradeReversalActive ?
- (latestFailedCRTReversalDirection == 1 ? "BULL REVERSAL" : "BEAR REVERSAL") :
- "NONE"
- //======================================================================
- // 14C. STORY TRANSLATION + CENTRAL STATE MATRIX — v19.7
- // Student-facing explanation of the local CRT, its implication, its
- // alignment with the inherited HTF story, and the practical action.
- // This changes dashboard wording only; detection logic is untouched.
- //======================================================================
- string dashboardLocalCRT =
- parentStandDownDisplay ? "INFORMATION ONLY • LOCAL CRT IGNORED" :
- localNarrativeArchived ? "OLD CRT ARCHIVED" :
- tradeReversalActive ?
- (latestCRTDirection == 1 ? "BULLISH CRT FAILED" : latestCRTDirection == -1 ? "BEARISH CRT FAILED" : "CRT FAILED") :
- tradeTargetReached ? "CRT DELIVERED" :
- tradeInvalid ? "CRT INVALID" :
- tradeExpired ? "CRT EXPIRED" :
- crtLifecycleActive ?
- (activeCRTDirection == 1 ? "BULLISH CRT ACTIVE" : activeCRTDirection == -1 ? "BEARISH CRT ACTIVE" : "CRT ACTIVE") :
- "NO LOCAL CRT"
- string dashboardLocalImplication =
- parentStandDownDisplay ? "INFORMATION ONLY • PARENT LOCKED" :
- localNarrativeArchived ? "WAIT NEW NARRATIVE" :
- tradeReversalActive ?
- (latestFailedCRTReversalDirection == 1 ? "BULLISH REVERSAL" : "BEARISH REVERSAL") :
- tradeTargetReached ? "OBJECTIVE COMPLETE" :
- tradeInvalid ? "RESET CONTEXT" :
- tradeExpired ? "WAIT NEW CRT" :
- crtLifecycleActive ?
- (activeCRTDirection == 1 ? "BULLISH DELIVERY" : activeCRTDirection == -1 ? "BEARISH DELIVERY" : "ACTIVE DELIVERY") :
- "WAITING"
- string dashboardHTFAlignment =
- parentStandDownDisplay ? "LOCKED • PARENT ARCHIVED" :
- dashboardRoomFilterFailed and htfBiasInheritanceLock ? "CONFIRMED • PARENT ACTIVE" :
- not htfBiasInheritanceLock ? dashboardHTF :
- localStoryAligned or inheritedAlignedLocalCRT ? "ALIGNED" :
- localStoryOpposed or inheritedOpposingLocalCRT ? "OPPOSED" :
- "WAITING"
- string dashboardAction =
- executionChildMode and inheritedNarrativeArchived ? "WAIT NEW QUALIFIED PARENT CRT" :
- not executionChildMode and localNarrativeArchived ? "WAIT NEW QUALIFIED CRT" :
- not executionChildMode ? (localNarrativeRearmed ? "NEW NARRATIVE • RE-ARMED" : "FOLLOW ENGINE VERDICT") :
- enableExecutionAuthorizationEngine and executionAuthorizationState == 4 ? "MANAGE DELIVERY • NO SECOND ENTRY" :
- enableExecutionAuthorizationEngine and executionAuthorizationState == 3 ? "ENTRY AUTHORIZED • EXECUTE RISK PLAN" :
- enableExecutionAuthorizationEngine and executionAuthorizationNoChase ? "STAND DOWN • OBJECTIVE TOO NEAR" :
- enableExecutionAuthorizationEngine and authorizationRequireDistributionWindow and not executionAuthorizationWindowPass ? "WAIT HTF DISTRIBUTION WINDOW" :
- enableExecutionAuthorizationEngine and executionAuthorizationState == 2 ?
- (authorizationRequireLiquidityOrPOI ? "HUNT ALIGNED CRT AT LIQUIDITY / POI" : "HUNT ALIGNED QUALIFIED LTF CRT") :
- enableExecutionAuthorizationEngine and executionAuthorizationState == 1 ? "BUILDING SETUP • WAIT CONDITIONS" :
- inheritedNarrativeRearmedRaw and htfBiasInheritanceLock ? "RE-ARMED • HUNT ALIGNED LTF CRT" :
- not htfBiasInheritanceLock ? "WAIT PARENT STORY" :
- localStoryOpposed or inheritedOpposingLocalCRT ? "IGNORE • WAIT ALIGNED CRT" :
- tradeExpired ? (displayExecutionDirection == 1 ? "LOCAL RESET • WAIT BULL CRT" : "LOCAL RESET • WAIT BEAR CRT") :
- not insideDistributionWindow ? "WAIT EXECUTION WINDOW" :
- localStoryAligned or inheritedAlignedLocalCRT ? "CONFIRM ENTRY + RISK" :
- displayExecutionDirection == 1 ? "WAIT BULLISH LTF CRT" :
- displayExecutionDirection == -1 ? "WAIT BEARISH LTF CRT" :
- "WAIT HTF BIAS"
- //======================================================================
- // 14B. MULTI-TIMEFRAME EXECUTION GUIDANCE — v19.2
- // Translates the HTF lifecycle into the next practical timeframe, the
- // structure to hunt, and whether the existing LTF execution scanner is
- // locked, open, or has confirmed an aligned CRT. This is guidance only.
- //======================================================================
- f_nextExecutionTF(string sourceTF) =>
- sourceTF == "M" ? "W / D" :
- sourceTF == "W" ? "D / H4" :
- sourceTF == "D" ? "H4 / H1" :
- sourceTF == "240" or sourceTF == "180" or sourceTF == "120" ? "H1 / 15M" :
- sourceTF == "60" ? "15M / 5M" :
- sourceTF == "30" ? "5M / 3M" :
- "5M / 3M / 2M / 1M"
- // v20.2 Narrative Candidate State Tracker.
- // Makes every fresh narrative transition visible:
- // WAIT ID -> CANDIDATE ID -> VALIDATING score -> CONFIRMED/RE-ARMED
- // or -> REJECTED ID (permanent).
- string dashboardFreshValidation =
- executionChildMode ?
- (not inheritedFreshNarrative ? "WAIT FRESH PARENT ID" :
- inheritedFreshValidationConfirmed ?
- "CONFIRMED #" + str.tostring(inheritedQualifiedNarrativeIDRaw) + " • " +
- str.tostring(inheritedFreshValidationScoreRaw) + "/4 • " +
- (inheritedFreshDirectionRaw == 1 ? "BULLISH" : "BEARISH") :
- inheritedFreshValidationRejected ?
- "REJECTED #" + str.tostring(inheritedRejectedNarrativeIDRaw) + " • PERMANENT" :
- "CANDIDATE #" + str.tostring(inheritedQualifiedNarrativeIDRaw) +
- " • VALIDATING " + str.tostring(inheritedFreshValidationScoreRaw) + "/4") :
- not hasFreshNarrativeIdentity ? "WAIT FRESH ID" :
- freshValidationConfirmed ?
- "CONFIRMED #" + str.tostring(latestQualifiedNarrativeID) + " • " +
- str.tostring(freshValidationScore) + "/4 • " +
- (latestNarrativeDirection == 1 ? "BULLISH" : "BEARISH") :
- freshValidationRejected ?
- "REJECTED #" + str.tostring(latestRejectedNarrativeID) + " • PERMANENT" :
- "CANDIDATE #" + str.tostring(latestQualifiedNarrativeID) +
- " • VALIDATING " + str.tostring(freshValidationScore) + "/4"
- string dashboardNarrativeMemory =
- executionChildMode ?
- (inheritedFreshValidationPending ?
- "CANDIDATE #" + str.tostring(inheritedQualifiedNarrativeIDRaw) + " • AGE " + str.tostring(inheritedFreshNarrativeAgeRaw) :
- inheritedNarrativeFreshRaw ?
- "FRESH #" + str.tostring(inheritedQualifiedNarrativeIDRaw) + " • AGE " + str.tostring(inheritedFreshNarrativeAgeRaw) :
- inheritedFreshValidationRejected ?
- "REJECTED #" + str.tostring(inheritedRejectedNarrativeIDRaw) + " • WAIT NEWER ID" :
- inheritedFreshNarrative ?
- "ACTIVE #" + str.tostring(inheritedQualifiedNarrativeIDRaw) :
- inheritedTargetReachedRaw or inheritedInvalidRaw or inheritedExpiredRaw ?
- "RESET #" + str.tostring(inheritedTerminalNarrativeIDRaw) + " • WAIT NEXT ID" :
- inheritedQualifiedNarrativeIDRaw > 0 ?
- "CURRENT #" + str.tostring(inheritedQualifiedNarrativeIDRaw) :
- "NO NARRATIVE ID") :
- freshValidationState == 1 and hasFreshNarrativeIdentity ?
- "CANDIDATE #" + str.tostring(latestQualifiedNarrativeID) + " • AGE " + str.tostring(freshNarrativeAge) :
- localNarrativeFresh ?
- "FRESH #" + str.tostring(latestQualifiedNarrativeID) + " • AGE " + str.tostring(freshNarrativeAge) :
- freshValidationRejected ?
- "REJECTED #" + str.tostring(latestRejectedNarrativeID) + " • WAIT NEWER ID" :
- hasFreshNarrativeIdentity and crtLifecycleActive ?
- "ACTIVE #" + str.tostring(latestQualifiedNarrativeID) :
- tradeTargetReached or tradeInvalid or tradeExpired ?
- "RESET #" + str.tostring(latestTerminalNarrativeID) + " • WAIT NEXT ID" :
- latestQualifiedNarrativeID > 0 ?
- "CURRENT #" + str.tostring(latestQualifiedNarrativeID) :
- "NO NARRATIVE ID"
- string dashboardNarrativeState =
- executionChildMode ?
- (inheritedFreshNarrative and inheritedFreshValidationPending ?
- "CANDIDATE #" + str.tostring(inheritedQualifiedNarrativeIDRaw) + " • PARENT VALIDATING" :
- inheritedFreshNarrative and inheritedFreshValidationRejected ?
- "REJECTED #" + str.tostring(inheritedRejectedNarrativeIDRaw) + " • WAIT NEWER PARENT" :
- inheritedNarrativeRearmedRaw and htfBiasInheritanceLock ?
- "RE-ARMED #" + str.tostring(inheritedQualifiedNarrativeIDRaw) + " • PARENT CONFIRMED" :
- inheritedNarrativeArchived ?
- "ARCHIVED #" + str.tostring(inheritedTerminalNarrativeIDRaw) + " • WAIT NEW PARENT" :
- htfBiasInheritanceLock ? "ARMED • PARENT STORY ACTIVE" :
- "WAIT NEW PARENT NARRATIVE") :
- hasFreshNarrativeIdentity and freshValidationState == 1 ?
- "CANDIDATE #" + str.tostring(latestQualifiedNarrativeID) + " • VALIDATING" :
- hasFreshNarrativeIdentity and freshValidationState == 3 ?
- "REJECTED #" + str.tostring(latestRejectedNarrativeID) + " • WAIT NEWER ID" :
- localNarrativeRearmed ?
- "RE-ARMED #" + str.tostring(latestQualifiedNarrativeID) + " • FRESH CONFIRMED" :
- localNarrativeArchived ?
- "ARCHIVED #" + str.tostring(latestTerminalNarrativeID) + " • WAIT NEW ID" :
- crtLifecycleActive or tradeReversalActive ? "ARMED • NARRATIVE ACTIVE" :
- "WAIT NEW NARRATIVE"
- string dashboardHTFStory =
- executionChildMode and inheritedNarrativeArchived ?
- inheritanceParentTF + " ARCHIVED #" + str.tostring(inheritedTerminalNarrativeIDRaw) + " → WAIT NEW STORY" :
- executionChildMode ? inheritedParentStory :
- localNarrativeArchived ?
- "ARCHIVED #" + str.tostring(latestTerminalNarrativeID) + " → WAIT NEW QUALIFIED CRT" :
- tradeReversalActive ? dashboardCRTState + " → " + dashboardFailure :
- crtLifecycleActive ? dashboardCRTState + " → " + dashboardDelivery :
- "WAIT QUALIFIED HTF CRT"
- string dashboardNextTF =
- parentStandDownDisplay ? "PARENT RE-ARM REQUIRED" :
- localStandDownDisplay ? "NEW QUALIFIED CRT REQUIRED" :
- executionChildMode ? timeframe.period + " LOCAL EXECUTION" :
- tradeInvalid or tradeExpired ? selectedHTF :
- f_nextExecutionTF(selectedHTF)
- string dashboardHunt =
- executionChildMode and enableExecutionAuthorizationEngine ?
- (inheritedFreshNarrative and inheritedFreshValidationPending ? "WAIT PARENT VALIDATION" :
- inheritedFreshNarrative and inheritedFreshValidationRejected ? "WAIT NEXT PARENT CRT" :
- inheritedNarrativeArchived ? "WAIT NEW QUALIFIED PARENT CRT" :
- executionAuthorizationState == 4 or executionAuthorizationState == 3 ? "DELIVERY TO PARENT OBJECTIVE" :
- executionAuthorizationNoChase ? "NO CHASE • OBJECTIVE TOO NEAR" :
- executionAuthorizationState == 2 ?
- (displayExecutionDirection == 1 ? "BULLISH CRT AT SSL / POI" : "BEARISH CRT AT BSL / POI") :
- executionAuthorizationState == 1 ? "LIQUIDITY / POI + ALIGNED CRT" :
- "WAIT PARENT STORY") :
- executionChildMode ?
- (inheritedFreshNarrative and inheritedFreshValidationPending ? "WAIT PARENT VALIDATION" :
- inheritedFreshNarrative and inheritedFreshValidationRejected ? "WAIT NEXT PARENT CRT" :
- inheritedNarrativeRearmedRaw and htfBiasInheritanceLock ? "ALIGNED CRT CONTEXT" :
- inheritedNarrativeArchived ? "WAIT NEW QUALIFIED PARENT CRT" :
- htfBiasInheritanceLock ?
- (displayExecutionDirection == 1 ? "BULLISH LTF CRT" : "BEARISH LTF CRT") :
- "WAIT PARENT STORY") :
- hasFreshNarrativeIdentity and freshValidationState == 1 ? "WAIT VALIDATION" :
- hasFreshNarrativeIdentity and freshValidationState == 3 ? "WAIT NEXT QUALIFIED CRT" :
- localNarrativeRearmed ? "ALIGNED CRT CONTEXT" :
- localNarrativeArchived ? "WAIT NEW QUALIFIED CRT" :
- tradeReversalActive ?
- (executionDirection == 1 ? "BULLISH LTF CRT" : "BEARISH LTF CRT") :
- tradeReady or tradeWatch ?
- (executionDirection == 1 ? "ALIGNED BULLISH CRT" : executionDirection == -1 ? "ALIGNED BEARISH CRT" : "ALIGNED LTF CRT") :
- "HTF RANGE + PURGE"
- string dashboardExecutionState =
- executionChildMode and enableExecutionAuthorizationEngine ? executionAuthorizationStateText :
- executionChildMode and inheritedFreshNarrative and inheritedFreshValidationPending ? "LOCKED • VALIDATING PARENT" :
- executionChildMode and inheritedFreshNarrative and inheritedFreshValidationRejected ? "LOCKED • PARENT REJECTED" :
- executionChildMode and inheritedNarrativeRearmedRaw and htfBiasInheritanceLock ? "RE-ARMED • SCANNING NEW STORY" :
- executionChildMode and inheritedNarrativeArchived ? "LOCKED • OLD PARENT ARCHIVED" :
- not executionChildMode and localNarrativeArchived ? "LOCKED • OLD NARRATIVE ARCHIVED" :
- htfBiasInheritanceLock and (inheritedOpposingLocalCRT or localStoryOpposed) ? "OPPOSED • IGNORE" :
- htfBiasInheritanceLock and (inheritedAlignedLocalCRT or localStoryAligned) ? "CONFIRMED" :
- qualifiedLTFStructure ? "CONFIRMED" :
- structureEngineUnlocked ? "UNLOCKED • SCANNING" :
- executionTimeframeAllowed and not insideDistributionWindow ? "LOCKED • WAIT WINDOW" :
- tradeReversalActive or crtLifecycleActive ? "LOCKED • MOVE TO LTF" :
- "LOCKED"
- color dashboardExecutionStateColor =
- parentStandDownDisplay ? color.new(color.orange, 65) :
- localStandDownDisplay ? color.new(color.orange, 65) :
- executionChildMode and enableExecutionAuthorizationEngine ? executionAuthorizationStateColor :
- executionChildMode and inheritedFreshNarrative and inheritedFreshValidationPending ? color.new(color.orange, 62) :
- executionChildMode and inheritedFreshNarrative and inheritedFreshValidationRejected ? color.new(color.red, 58) :
- executionChildMode and inheritedNarrativeRearmedRaw and htfBiasInheritanceLock ? color.new(color.green, 58) :
- executionChildMode and inheritedTargetReachedRaw ? color.new(color.green, 72) :
- executionChildMode and (inheritedInvalidRaw or inheritedExpiredRaw) ? color.new(color.gray, 72) :
- htfBiasInheritanceLock and (inheritedOpposingLocalCRT or localStoryOpposed) ? color.new(color.red, 58) :
- htfBiasInheritanceLock and (inheritedAlignedLocalCRT or localStoryAligned) ? color.new(color.green, 58) :
- qualifiedLTFStructure ? color.new(color.green, 58) :
- structureEngineUnlocked ? color.new(color.orange, 62) :
- color.new(color.gray, 78)
- string dashboardNarrativeDelivery =
- executionChildMode and inheritedNarrativeArchived ? "ARCHIVED • WAIT NEW STORY" :
- not executionChildMode and localNarrativeArchived ? "ARCHIVED • WAIT NEW STORY" :
- executionChildMode ? inheritedNarrativeTrackerText : narrativeTrackerStateText
- string dashboardNarrativeObjective =
- executionChildMode and inheritedNarrativeArchived ? "OLD OBJECTIVE CLOSED" :
- not executionChildMode and localNarrativeArchived ? "OLD OBJECTIVE CLOSED" :
- executionChildMode ? inheritedNarrativeObjectiveText : narrativeObjectiveText
- color dashboardNarrativeTrackerColor =
- dashboardStandDownDisplay ? color.new(color.gray, 72) :
- executionChildMode ?
- (
- inheritedNarrativeTrackerStateRaw == 3 or
- inheritedNarrativeTrackerStateRaw == 4 or
- inheritedNarrativeTrackerStateRaw == 5 ?
- color.new(color.green, 58) :
- inheritedNarrativeTrackerStateRaw == 1 or
- inheritedNarrativeTrackerStateRaw == 2 ?
- color.new(color.orange, 62) :
- inheritedNarrativeTrackerStateRaw == 6 or
- inheritedNarrativeTrackerStateRaw == 8 ?
- color.new(color.red, 58) :
- color.new(color.gray, 78)
- ) :
- narrativeTrackerColor
- string dashboardGrade = f_gradeText(latestCRTGradeCode)
- string dashboardVerdict =
- executionChildMode and inheritedNarrativeArchived ?
- "PARENT #" + str.tostring(inheritedTerminalNarrativeIDRaw) + " ARCHIVED • WAIT NEW QUALIFIED PARENT CRT" :
- not executionChildMode and localNarrativeArchived ?
- "NARRATIVE #" + str.tostring(latestTerminalNarrativeID) + " ARCHIVED • WAIT NEW QUALIFIED CRT" :
- executionChildMode ?
- (htfBiasInheritanceLock ?
- (localStoryOpposed or inheritedOpposingLocalCRT ?
- inheritedParentStory + " • LOCAL STORY OPPOSED • IGNORE" :
- localStoryAligned or inheritedAlignedLocalCRT ?
- inheritedParentStory + " • LTF ALIGNED • CONFIRM RISK" :
- inheritedParentStory + " • WAIT ALIGNED LTF CRT") :
- inheritedParentStory) :
- tradeReversalActive ?
- localLifecycleText + " • " + dashboardFailure + " • WAIT LTF CONFIRMATION" :
- localLifecycleText == "WAITING" ?
- "WAITING FOR QUALIFIED CRT" :
- dashboardGrade + " " + localLifecycleText + " • " +
- (dashboardDelivery == "CONFIRMED" ? "DELIVERY CONFIRMED" : "WAIT FOR DELIVERY") +
- (dashboardTarget != "NONE" ? " • DRAW " + dashboardTarget : "")
- string dashboardDecisionLabel =
- dashboardRoomFilterFailed ? "ROOM FILTER" :
- htfBiasInheritanceLock ? "ACTION" : "ENGINE VERDICT"
- string dashboardDecisionDisplay =
- dashboardRoomFilterFailed ? "FAILED • NO CHASE" :
- executionChildMode ? dashboardAction : dashboardVerdict
- var table intelligenceDashboard = table.new(
- f_dashboardPosition(dashboardPosition),
- 2,
- 29,
- border_width = 1
- )
- if barstate.islast
- if showIntelligenceDashboard
- table.clear(intelligenceDashboard, 0, 0, 1, 28)
- color headerBg = color.new(color.rgb(25, 25, 35), 5)
- color labelBg = color.new(color.rgb(40, 40, 50), 15)
- color verdictBg = color.new(color.rgb(20, 20, 30), 0)
- color actionLabelBg = color.new(color.rgb(20, 20, 30), 0)
- string marketTF = syminfo.ticker + " • " + timeframe.period
- string txtSize = f_dashboardTextSize(dashboardTextSize)
- table.cell(intelligenceDashboard, 0, 0, "ASH CRT INTELLIGENCE", bgcolor = headerBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 0, marketTF, bgcolor = headerBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 1, "TRADE STATUS", bgcolor = actionLabelBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 1, displayTradeStatus, bgcolor = f_tradeStatusColor(displayTradeStatus, displayExecutionDirection), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 2, "HTF STORY", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 2, dashboardHTFStory, bgcolor = displayExecutionDirection == 1 ? color.new(color.green, 72) : displayExecutionDirection == -1 ? color.new(color.red, 72) : f_stateColor(dashboardCRTState), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 3, "NEXT TF", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 3, dashboardNextTF, bgcolor = headerBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 4, "HUNT", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 4, dashboardHunt, bgcolor = displayExecutionDirection == 1 ? color.new(color.green, 72) : displayExecutionDirection == -1 ? color.new(color.red, 72) : headerBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 5, "EXECUTION", bgcolor = actionLabelBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 5, dashboardExecutionState, bgcolor = dashboardExecutionStateColor, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 6, "EXECUTION BIAS", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 6, displayExecutionBias, bgcolor = displayExecutionDirection == 1 ? color.new(color.green, 72) : displayExecutionDirection == -1 ? color.new(color.red, 72) : color.new(color.gray, 82), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 7, "ENTRY CONDITION", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 7, displayEntryCondition, bgcolor = headerBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 8, "RISK STATE", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 8, displayRiskState, bgcolor = dashboardStandDownDisplay ? color.new(color.orange, 72) : executionChildMode and inheritedTargetReachedRaw ? color.new(color.green, 72) : executionChildMode and inheritedInvalidRaw ? color.new(color.red, 72) : tradeInvalid ? color.new(color.red, 72) : tradeTargetReached ? color.new(color.green, 72) : headerBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 9, "SETUP AGE", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 9, displaySetupAge, bgcolor = headerBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 10, parentStandDownDisplay ? "LOCAL CRT (INFO)" : executionChildMode ? "LOCAL CRT" : "CRT STATE", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 10, executionChildMode ? dashboardLocalCRT : dashboardCRTState, bgcolor = f_stateColor(executionChildMode ? dashboardLocalImplication : dashboardCRTState), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 11, "GRADE / SCORE", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 11, dashboardGrade + " • " + str.tostring(latestCRTIntelligenceScore) + "/10", bgcolor = headerBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 12, "HTF CONTEXT", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 12, dashboardHTF, bgcolor = f_stateColor(dashboardHTF), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 13, "KEY LEVEL / POI", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 13, dashboardPOI, bgcolor = f_stateColor(dashboardPOI), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 14, "LIQUIDITY PURGE", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 14, dashboardPurge, bgcolor = headerBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 15, "SMT", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 15, dashboardSMT, bgcolor = f_stateColor(dashboardSMT), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 16, "NESTED CRT", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 16, dashboardNested, bgcolor = f_stateColor(dashboardNested), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 17, parentStandDownDisplay ? "LOCAL INFO" : htfBiasInheritanceLock ? "LOCAL IMPLICATION" : "DELIVERY", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 17, executionChildMode ? dashboardLocalImplication : dashboardDelivery, bgcolor = f_stateColor(executionChildMode ? dashboardLocalImplication : dashboardDelivery), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 18, dashboardObjectiveLabel, bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 18, dashboardObjectiveDisplay, bgcolor = dashboardRoomFilterFailed ? color.new(color.orange, 62) : headerBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 19, dashboardLocalTargetLabel, bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 19, dashboardLocalTargetDisplay, bgcolor = executionChildMode ? color.new(color.gray, 76) : f_stateColor(dashboardLocalTargetDisplay), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 20, parentStandDownDisplay ? "PARENT LOCK" : htfBiasInheritanceLock ? "HTF ALIGNMENT" : "FAILURE CONTEXT", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 20, executionChildMode ? dashboardHTFAlignment : dashboardFailure, bgcolor = dashboardRoomFilterFailed ? color.new(color.green, 68) : f_stateColor(executionChildMode ? dashboardHTFAlignment : dashboardFailure), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 21, dashboardDecisionLabel, bgcolor = verdictBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 21, dashboardDecisionDisplay, bgcolor = dashboardRoomFilterFailed ? color.new(color.orange, 55) : verdictBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 22, "KEY LEVEL TF", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 22, dashboardKeyLevelTF, bgcolor = headerBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 23, "KEY LEVEL ENGINE", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 23, latestKeyLevelType != 0 ? "TYPE CONFIRMED" : "NONE", bgcolor = latestKeyLevelType != 0 ? color.new(color.green, 72) : color.new(color.gray, 82), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 24, "NARRATIVE ENGINE", bgcolor = actionLabelBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 24, dashboardNarrativeState, bgcolor = str.contains(dashboardNarrativeState, "REJECTED") ? color.new(color.red, 58) : str.contains(dashboardNarrativeState, "CANDIDATE") ? color.new(color.orange, 58) : str.contains(dashboardNarrativeState, "RE-ARMED") or str.contains(dashboardNarrativeState, "ARMED") ? color.new(color.green, 65) : str.contains(dashboardNarrativeState, "STAND DOWN") ? color.new(color.orange, 65) : color.new(color.gray, 78), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 25, "NARRATIVE MEMORY", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 25, dashboardNarrativeMemory, bgcolor = str.contains(dashboardNarrativeMemory, "REJECTED") ? color.new(color.red, 58) : str.contains(dashboardNarrativeMemory, "CANDIDATE") ? color.new(color.orange, 58) : str.contains(dashboardNarrativeMemory, "FRESH") ? color.new(color.green, 58) : str.contains(dashboardNarrativeMemory, "RESET") ? color.new(color.orange, 65) : color.new(color.gray, 78), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 26, "FRESH VALIDATION", bgcolor = actionLabelBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 26, dashboardFreshValidation, bgcolor = str.contains(dashboardFreshValidation, "CONFIRMED") ? color.new(color.green, 58) : str.contains(dashboardFreshValidation, "REJECTED") ? color.new(color.red, 58) : str.contains(dashboardFreshValidation, "VALIDATING") ? color.new(color.orange, 62) : color.new(color.gray, 78), text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 27, "NARRATIVE DELIVERY", bgcolor = actionLabelBg, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 27, dashboardNarrativeDelivery, bgcolor = dashboardNarrativeTrackerColor, text_color = color.white, text_size = txtSize)
- table.cell(intelligenceDashboard, 0, 28, "NARRATIVE OBJECTIVE", bgcolor = labelBg, text_color = color.silver, text_size = txtSize)
- table.cell(intelligenceDashboard, 1, 28, dashboardNarrativeObjective, bgcolor = dashboardNarrativeTrackerColor, text_color = color.white, text_size = txtSize)
- else
- table.clear(intelligenceDashboard, 0, 0, 1, 28)
- //======================================================================
- // 15. ALERTS
- //======================================================================
- bool narrativeRearmSignal =
- executionChildMode ? inheritedNarrativeRearmedRaw : localNarrativeRearmed
- //----------------------------------------------------------------------
- // v20.9.1 Forward-Test Runtime Alert Engine.
- // These alert() calls do not consume plot slots. They are deliberately
- // transition-based and fire once per confirmed bar. In TradingView, create
- // one alert and select: "Any alert() function call".
- //----------------------------------------------------------------------
- int forwardAlertParentID = executionChildMode ? inheritedQualifiedNarrativeIDRaw : latestQualifiedNarrativeID
- int forwardAlertDirection =
- executionChildMode ?
- (inheritedFreshDirectionRaw != 0 ? inheritedFreshDirectionRaw : inheritedHTFDirection) :
- latestNarrativeDirection
- string forwardAlertDirectionText = forwardAlertDirection == 1 ? "BULLISH" : forwardAlertDirection == -1 ? "BEARISH" : "NEUTRAL"
- string forwardAlertParentTF = executionChildMode ? inheritanceParentTF : timeframe.period
- float forwardAlertObjective = executionChildMode ? inheritedNarrativeObjectiveRaw : activeDrawTarget
- string forwardAlertObjectiveText = na(forwardAlertObjective) ? "N/A" : str.tostring(forwardAlertObjective, format.mintick)
- string forwardAlertPrefix = "Ash CRT v20.9.1 | " + syminfo.ticker + " | Chart " + timeframe.period + " | Parent " + forwardAlertParentTF + " | "
- bool forwardParentConfirmedEvent =
- executionChildMode ?
- inheritedFreshValidationConfirmed and (
- not inheritedFreshValidationConfirmed[1] or
- inheritedQualifiedNarrativeIDRaw != inheritedQualifiedNarrativeIDRaw[1]
- ) :
- freshValidationConfirmed and (
- not freshValidationConfirmed[1] or
- latestQualifiedNarrativeID != latestQualifiedNarrativeID[1]
- )
- bool forwardExecutionArmedEvent = executionAuthorizationState == 2 and executionAuthorizationState[1] != 2
- bool forwardEntryConfirmedEvent = executionAuthorizationState == 3 and executionAuthorizationState[1] != 3
- bool forwardDeliveryNoReentryEvent = executionAuthorizationState == 4 and executionAuthorizationState[1] != 4
- bool forwardParentObjectiveCompletedEvent =
- executionChildMode ?
- inheritedNarrativeTrackerStateRaw == 5 and inheritedNarrativeTrackerStateRaw[1] != 5 :
- narrativeTrackerState == 5 and narrativeTrackerState[1] != 5
- bool forwardParentRejectedEvent =
- executionChildMode ?
- inheritedFreshValidationRejected and not inheritedFreshValidationRejected[1] :
- freshValidationRejected and not freshValidationRejected[1]
- bool forwardParentInvalidatedEvent =
- executionChildMode ?
- inheritedInvalidRaw and not inheritedInvalidRaw[1] :
- tradeInvalid and not tradeInvalid[1]
- bool forwardParentExpiredEvent =
- executionChildMode ?
- inheritedExpiredRaw and not inheritedExpiredRaw[1] :
- tradeExpired and not tradeExpired[1]
- bool forwardNoChaseEvent = executionAuthorizationNoChase and not executionAuthorizationNoChase[1]
- if enableForwardTestAlerts and barstate.isconfirmed
- if alertParentConfirmed and forwardParentConfirmedEvent
- alert(
- forwardAlertPrefix + "PARENT CONFIRMED 4/4 | " + forwardAlertDirectionText + " | Narrative #" + str.tostring(forwardAlertParentID) + " | Objective " + forwardAlertObjectiveText,
- alert.freq_once_per_bar_close
- )
- if alertExecutionArmed and forwardExecutionArmedEvent
- alert(
- forwardAlertPrefix + "EXECUTION ARMED | " + forwardAlertDirectionText + " | Narrative #" + str.tostring(executionAuthorizationParentID) + " | Wait aligned qualified LTF CRT",
- alert.freq_once_per_bar_close
- )
- if alertEntryConfirmed and forwardEntryConfirmedEvent
- alert(
- forwardAlertPrefix + "ENTRY CONFIRMED | " + forwardAlertDirectionText + " | Narrative #" + str.tostring(executionAuthorizationParentID) + " | One-shot authorization consumed | Entry " + str.tostring(executionAuthorizationEntryPrice, format.mintick),
- alert.freq_once_per_bar_close
- )
- if alertDeliveryNoReentry and forwardDeliveryNoReentryEvent
- alert(
- forwardAlertPrefix + "DELIVERY IN PROGRESS | Narrative #" + str.tostring(executionAuthorizationParentID) + " | NO RE-ENTRY | Manage the authorized execution",
- alert.freq_once_per_bar_close
- )
- if alertParentObjectiveCompleted and forwardParentObjectiveCompletedEvent
- alert(
- forwardAlertPrefix + "PARENT OBJECTIVE COMPLETED | Narrative #" + str.tostring(forwardAlertParentID) + " | STAND DOWN | No chase",
- alert.freq_once_per_bar_close
- )
- if alertParentRejectedInvalidated and forwardParentRejectedEvent
- alert(
- forwardAlertPrefix + "PARENT CANDIDATE PERMANENTLY REJECTED | Narrative #" + str.tostring(forwardAlertParentID) + " | Wait newer parent CRT",
- alert.freq_once_per_bar_close
- )
- if alertParentRejectedInvalidated and forwardParentInvalidatedEvent
- alert(
- forwardAlertPrefix + "PARENT NARRATIVE INVALIDATED | Narrative #" + str.tostring(forwardAlertParentID) + " | Execution locked",
- alert.freq_once_per_bar_close
- )
- if alertParentRejectedInvalidated and forwardParentExpiredEvent
- alert(
- forwardAlertPrefix + "PARENT NARRATIVE EXPIRED | Narrative #" + str.tostring(forwardAlertParentID) + " | Wait new parent CRT",
- alert.freq_once_per_bar_close
- )
- if alertNoChase and forwardNoChaseEvent
- alert(
- forwardAlertPrefix + "NO CHASE | Parent objective too near or no valid room | Narrative #" + str.tostring(executionAuthorizationParentID) + " | Objective " + forwardAlertObjectiveText,
- alert.freq_once_per_bar_close
- )
- alertcondition(
- narrativeTrackerState == 3 and narrativeTrackerState[1] != 3,
- "Ash CRT — Narrative Delivery Active",
- "The validated CRT narrative has started directional delivery on {{ticker}} {{interval}}."
- )
- alertcondition(
- narrativeTrackerState == 4 and narrativeTrackerState[1] != 4,
- "Ash CRT — Narrative Objective Near",
- "The active CRT narrative is approaching its selected objective on {{ticker}} {{interval}}."
- )
- alertcondition(
- narrativeTrackerState == 5 and narrativeTrackerState[1] != 5,
- "Ash CRT — Narrative Objective Completed",
- "The active CRT narrative completed its selected objective on {{ticker}} {{interval}}. Stand down and avoid chasing."
- )
- alertcondition(
- narrativeTrackerState == 8 and narrativeTrackerState[1] != 8,
- "Ash CRT — Narrative Permanently Rejected",
- "The fresh CRT narrative failed validation and its narrative ID is permanently rejected on {{ticker}} {{interval}}."
- )
- alertcondition(
- narrativeRearmSignal and not narrativeRearmSignal[1],
- "Ash CRT — Narrative Re-Armed",
- "A genuinely newer qualified parent CRT created a fresh bullish or bearish narrative on {{ticker}} {{interval}}. Execution is re-armed; wait for aligned lower-timeframe confirmation."
- )
- alertcondition(
- tradeReady and not tradeReady[1],
- "Ash CRT — Trade Status READY",
- "CRT Trade Readiness Engine changed to READY on {{ticker}} {{interval}}. Confirm execution and risk before entry."
- )
- alertcondition(
- tradeReversalActive and not tradeReversalActive[1],
- "Ash CRT — Reversal Context Active",
- "CRT failure created an opposite-direction reversal context on {{ticker}} {{interval}}. Wait for aligned lower-timeframe CRT confirmation."
- )
- alertcondition(
- tradeInvalid and not tradeInvalid[1],
- "Ash CRT — Trade Status INVALID",
- "The tracked CRT trade state changed to INVALID on {{ticker}} {{interval}}."
- )
- alertcondition(
- tradeTargetReached and not tradeTargetReached[1],
- "Ash CRT — Trade Status TARGET REACHED",
- "The tracked CRT trade state changed to TARGET REACHED on {{ticker}} {{interval}}. Avoid chasing completed delivery."
- )
- alertcondition(
- gradeAPlusCRT,
- "Ash CRT — A+ Intelligence Grade",
- "A+ CRT intelligence grade confirmed on {{ticker}} {{interval}}."
- )
- alertcondition(
- gradeACRT,
- "Ash CRT — A Intelligence Grade",
- "A-grade CRT intelligence setup confirmed on {{ticker}} {{interval}}."
- )
- alertcondition(
- newDrawTargetReached,
- "Ash CRT — Draw on Liquidity Target Reached",
- "The active CRT reached its selected draw-on-liquidity target on {{ticker}} {{interval}}."
- )
- alertcondition(
- failedCRTEvent and failedCRTReversalDirection == 1,
- "Ash CRT — Failed Bearish CRT / Bullish Reversal Context",
- "A qualified bearish CRT failed through its manipulated-side boundary. Bullish reversal context detected on {{ticker}} {{interval}}."
- )
- alertcondition(
- failedCRTEvent and failedCRTReversalDirection == -1,
- "Ash CRT — Failed Bullish CRT / Bearish Reversal Context",
- "A qualified bullish CRT failed through its manipulated-side boundary. Bearish reversal context detected on {{ticker}} {{interval}}."
- )
- alertcondition(
- meaningfulDeliveryContext and not meaningfulDeliveryContext[1],
- "Ash CRT — Displacement Delivery Confirmed",
- "Post-manipulation displacement and directional delivery confirmed on {{ticker}} {{interval}}."
- )
- alertcondition(
- qualifiedCRT and meaningfulLiquidityPurge,
- "Ash CRT — Qualified CRT with Meaningful Liquidity Purge",
- "Qualified CRT also purged meaningful external liquidity on {{ticker}} {{interval}}."
- )
- alertcondition(
- qualifiedCRT and meaningfulNestedContext,
- "Ash CRT — Qualified CRT Nested in Active HTF Context",
- "Qualified CRT is nested or aligned inside an active parent-timeframe CRT context on {{ticker}} {{interval}}."
- )
- alertcondition(
- bullishManipulation,
- "Ash CRT — Qualified Bullish Manipulation",
- "Qualified bullish CRT manipulation confirmed on {{ticker}} {{interval}}. Range low was purged."
- )
- alertcondition(
- bearishManipulation,
- "Ash CRT — Qualified Bearish Manipulation",
- "Qualified bearish CRT manipulation confirmed on {{ticker}} {{interval}}. Range high was purged."
- )
- alertcondition(
- crtTargetReached and not crtTargetReached[1],
- "Ash CRT — Opposite-Side Target Reached",
- "The active CRT reached its opposite-side Range target on {{ticker}} {{interval}}."
- )
- alertcondition(
- crtInvalidated and not crtInvalidated[1],
- "Ash CRT — Active CRT Invalidated",
- "The active CRT was invalidated through its manipulated-side boundary on {{ticker}} {{interval}}."
- )
- alertcondition(
- crtExpired and not crtExpired[1],
- "Ash CRT — Active CRT Expired",
- "The active CRT expired before opposite-side delivery on {{ticker}} {{interval}}."
- )
- alertcondition(
- bullishSMT and not bullishSMT[1],
- "Ash CRT — Bullish SMT Detected",
- "Bullish SMT divergence detected between {{ticker}} and the configured comparison market on {{interval}}."
- )
- alertcondition(
- bearishSMT and not bearishSMT[1],
- "Ash CRT — Bearish SMT Detected",
- "Bearish SMT divergence detected between {{ticker}} and the configured comparison market on {{interval}}."
- )
- alertcondition(
- bullishLTFStructure,
- "Ash CRT — Bullish LTF Structure Confirmed",
- "Bullish lower-timeframe CRT structure confirmed inside the qualified HTF Distribution window on {{ticker}} {{interval}}."
- )
- alertcondition(
- bearishLTFStructure,
- "Ash CRT — Bearish LTF Structure Confirmed",
- "Bearish lower-timeframe CRT structure confirmed inside the qualified HTF Distribution window on {{ticker}} {{interval}}."
- )
Add Comment
Please, Sign In to add comment