ICT Internal Levels [Amaan]

The ICT Internal Levels [Amaan] is a comprehensive institutional analysis suite designed to bridge the gap between subjective price action and objective algorithmic logic. This script automates the detection of core ICT pillars—Liquidity, Time, and Displacement—into a single, high-performance interface.
🧠 The Core Engine
Unlike standard support/resistance indicators, this script uses a dynamic state-tracking system to identify institutional interest zones. It manages historical levels using memory-efficient User-Defined Types (UDTs) and arrays, ensuring that only the most relevant "unswept" liquidity remains on your chart.
🛠 Key Features
• Auto IFVG Checklist: A real-time confluence engine that "grades" market conditions from C to A+ by cross-verifying Liquidity Sweeps, Midnight Open Bias, and HTF Delivery.
• SMT Divergence Engine: A dual-mode detector (Adjacent & Structural) that identifies cracks in correlation between correlated assets (e.g., NQ/ES) with built-in dynamic invalidation.
• Algorithmic Macros: Six fully customizable time-anchored sessions (New York local time) that highlight the specific "killzones" where institutional volatility is highest.
• Internal Liquidity Scanner: A multi-timeframe scanner for Equal Highs (EQH) and Equal Lows (EQL) that identifies the "Draw on Liquidity" across 1m to 15m charts.
• Institutional Bias Framework: Automatically anchors the Midnight Opening Price to determine Daily Equilibrium (Discount vs. Premium arrays).
📈 Why Use This Script?
This tool is built for the "Smarter Trader." It removes the guesswork from ICT concepts by providing:
1. Objectivity: Know exactly when a setup has enough confluence via the automated Checklist.
2. Clarity: Clear visual distinction between Major and Minor liquidity levels.
3. Risk Management: Automated "Breakeven" logic prompts you when the stop-run phase is likely complete.
📝 Technical Implementation
This version is optimized for speed and accuracy. It features zero repainting on the checklist and SMT components by utilizing closed-candle verification. The UI is fully customizable, allowing you to tailor the dashboard to your specific trading style.
🟢 Advanced BSL & SSL Liquidity Engine
The core of this script is a sophisticated tracking system for Buyside Liquidity (BSL) and Sellside Liquidity (SSL). In institutional trading (ICT), these aren't just highs and lows; they are "Liquidity Pools" where retail stop-losses (buy/sell stops) are clustered, acting as magnets for the market algorithm.
1. The Logic of "Parent Swings"
Unlike basic indicators that mark every fractal high/low, this script uses a Swing Strength filter. It only identifies levels after they have been confirmed by a specific number of bars on either side (lookback/lookforward). This ensures the levels represent significant structural points where true "Smart Money" liquidity resides.
2. Major vs. Minor Classification (The Volatility Filter)
The script includes an intelligent classification system based on the Major Level Threshold %:
• The Calculation: Once a pivot is formed, the script measures the displacement away from that level.
• The Depth: If price expands by more than \bm{X\%} (e.g., 0.5%) after forming a high, it is labeled a "Major BSL".
This tells the trader that this level protected a significant move, making the liquidity sitting above it even more valuable to the algorithm.
3. Proximity Logic: Relatively Equal Highs/Lows (REQH/REQL)
The script features an internal "Proximity Scan." It automatically evaluates the distance between active liquidity levels:
• Logic: If two BSL levels are within a defined price threshold (\bm{REQ\_THRESHOLD}), the script identifies them as Relatively Equal Highs.
• Trading Insight: In ICT concepts, equal highs/lows are "engineered liquidity." The market is much more likely to run through these levels aggressively because there is a double layer of stops resting there.
4. Automated Level Management & Mitigation
To prevent "chart clutter," the script uses Custom Types and Arrays to manage levels dynamically:
• Mitigation (The Purge): As soon as price trades through a level, it is considered "mitigated" or "purged."
• Traded-Through Memory: You can toggle a setting to keep these levels visible. If enabled, the script stops extending the line and reduces its opacity (e.g., to 25%), leaving a "ghost level" on the chart. These often act as S/R Flips or support/resistance zones in future sessions.
📝 Logic behind it
• Methodology: The script utilizes the method keyword in Pine Script v6 to create clean, object-oriented code for level deletion and updates.
• Performance: By using array.unshift() and array.remove(), the script maintains a FIFO (First-In-First-Out) queue. This ensures that even on high-volatility days, the script never exceeds the 500-line drawing limit, maintaining smooth chart performance.
• Coordinate Precision: Lines are pinned using bar_index[swingStrength], ensuring that the line starts at the exact wick peak, providing pixel-perfect accuracy for liquidity analysis.
🟢 Institutional Macro Sessions
In the ICT methodology, Time is the primary filter. Price levels only become significant when they are reached at specific times of the day. This script automates the detection of Algorithmic Macros—tight 20-to-30-minute windows where the "Interbank Price Delivery Algorithm" (IPDA) is programmed to execute specific volatility injections.
1. Algorithmic Directives
During these highlighted windows, the market is not moving randomly. The algorithm is usually "called" to perform one of three tasks:
• Liquidity Purge: A quick run to stop out retail traders at a previous High (BSL) or Low (SSL).
• Rebalancing: Returning to a Fair Value Gap (FVG) or "Imbalance" to seek equilibrium.
• Expansion: Moving rapidly from an internal range toward a higher-timeframe target.
2. The 6 Tracked Macros
Your script identifies the most vital institutional windows for the New York session:
• AM Macro 1 (08:50 – 09:10): Often used for "Setting the Stage" or manipulation before the Equities Open.
• AM Macro 2 (09:50 – 10:10): A high-probability execution window often coinciding with the "Silver Bullet" setup.
• AM Macro 3 (10:50 – 11:10): Frequently marks the "Trend Continuation" or the start of a midday reversal.
• Lunch Macro (11:50 – 12:10): Algorithmic rebalancing before the PM session.
• PM Macro (13:10 – 13:40): The kick-off for the afternoon trend and London Close volatility.
• Last Hour Macro (15:15 – 15:45): The final algorithmic rebalancing before the New York "MOC" (Market On Close) orders.
3. Behind the Logic: Timezone Synchronization
A major technical challenge in Pine Script is ensuring time-boxes align correctly regardless of the user's local clock
• The Solution: This script utilizes a Timezone Shift parameter combined with the timestamp() function.
• Logic: It anchors the calculation to the chart’s syminfo.timezone and then offsets it to match New York Local Time.
This ensures that even if you are trading from London, Tokyo, or Dubai, the "09:50 Macro" will always plot exactly when the New York algorithms become active.
🟢 Multi-Timeframe Liquidity Scanner (EQH/EQL)
One of the most powerful features of V2 is the Stable Deep Scan Logic. Unlike basic fractal indicators, this script doesn't just mark any two similar peaks; it performs a rigorous historical audit of the price action.
The "Unswept" Logic
The table is powered by a custom function, check_liquidity_deep(), which executes a two-stage verification:
1. Detection: It scans a lookback window (default 300 bars) to find price points that are mathematically equal.
2. Verification: Once a level is found, the script runs a secondary loop to ensure that no intervening candle has breached (swept) that level. If a higher high has occurred between the level formation and the current bar, the level is discarded as "invalid/purged."
Data Visualization
The scanner requests this deep-scan data via request.security() for the 1m, 2m, 3m, 4m, 5m, and 15m timeframes simultaneously.
• EQH (Green/Red): Indicates a "Ceiling" of liquidity waiting to be raided.
• EQL (Red/Green): Indicates a "Floor" of sell-side liquidity.
• Both: Alerts the trader to a "bracketed" market, often preceding a high-volatility expansion.
• Memory Management: By using var array structures for SMT lines and labels, the script avoids the "Maximum Objects" limit often hit by lower-quality scripts.
• Optimization: The check_liquidity_deep function is designed to only trigger its heaviest calculations on the barstate.islast, ensuring your chart remains fluid and responsive even with multiple timeframes active.
• Coordinate Precision: The script uses xloc.bar_time for Macro lines to ensure they remain pinned to the correct NYC time regardless of the user's local computer clock or daylight savings shifts.
🟢 The Auto IFVG Checklist
The Auto IFVG Checklist in this script is a real-time confluence engine. It doesn't just display labels; it executes complex multi-timeframe scans and state-checks to verify if an institutional setup is currently active.
1. 🛡️ Liq Sweep (Liquidity Sweep)
Code Logic: high > high[1] and close < high[1] (for Bearish) or low < low[1] and close > low[1] (for Bullish).
• How it works: Your code identifies "Wick Manipulations." It flags a sweep when price breaches a previous candle's extremity but fails to hold that level on the close.
• Persistence: It uses swept_p with a ta.barssince lookback of 5 bars, meaning the "fuel" from the sweep remains valid for 5 candles after it occurs.
2. ⚡ Momentum (Midnight Open Bias)Orderflow Code Logic: midnightOpen = na anchored at hour == 0 and minute == 0.
• How it works: The script establishes a "True Day Open."
• IOF Bullish: Price is currently below Midnight Open (accumulating in a discount).
• IOF Bearish: Price is currently above Midnight Open (distributing in a premium).
• The Checklist Role: The Momentum check confirms if you are trading on the correct side of the "Power of 3" (Accumulation/Manipulation/Distribution).
3. 🎯 Clear DOL (Draw on Liquidity)
Code Logic: iof_bullish ? close < ta.vwap : close > ta.vwap.
• How it works: It uses VWAP (Volume Weighted Average Price) as the standard for algorithmic equilibrium.
• The Objective: If the bias is bullish, the script looks for price to be below VWAP, indicating the "Draw" is toward a higher premium or internal liquidity pool. It ensures the trade has room to "breathe" before hitting equilibrium.
4. 🔄 HTF iFVG (Higher Timeframe Inversion FVG)
Code Logic: f_scan_tf(tf) using request.security.
• How it works: This is the most complex part of the indicator. It scans the 1m, 2m, 3m, 4m, and 5m timeframes for "Inversion."
• The "Inversion" Event: It checks if price has closed completely through a Fair Value Gap (inv_b or inv_s). In your script, if a gap on any of these five timeframes is inverted, it signals a high-probability "Change in State of Delivery."
5. 🚢 HTF Delivery (Higher Timeframe Narrative)
Code Logic: f_scan_tf scanning 15m, 30m, 1H, and 4H.
• How it works: The script checks if price is currently interacting with an institutional zone on much higher timeframes.
• Priority: It uses a hierarchical "if-else" chain. If a 4H zone is found, it overrides the 1H; if a 1H is found, it overrides the 15m. This ensures the Checklist always displays the most significant timeframe currently "delivering" price.
6. ⚖️ Breakeven (The Risk-Off Trigger)
Code Logic: beR = ta.barssince(swept) < 10.
• How it works: This is a time-based risk management filter.
• The Logic: If a Liquidity Sweep occurred within the last 10 bars and the trade is moving, the script flags "Breakeven." It alerts the trader that the "Stop Run" phase should be over, and it is time to move the stop loss to the entry to ensure a risk-free trade.
📊 The Mathematical Rating System
The final "RATING" cell in the table is the result of a weighted boolean check:
• A+: Requires all 5 confluences (Sweep, Momentum, iFVG, Delivery, and DOL).
• A: Requires Sweep, Momentum, iFVG, and DOL.
• B+: Only requires the intraday pillars (Sweep, Momentum, and iFVG).
• C: Only requires an iFVG presence.
🟢 SMT Divergence Engine
The SMT engine in this script acts as a "crack in correlation" detector. It monitors the relationship between current chart and a Comparison Symbol (e.g., NQ vs. ES) to identify institutional accumulation or distribution that isn't visible on a single chart.
1. Dual-Mode Detection
This feature implements two distinct types of SMT to capture both aggressive and structural shifts:
• Adjacent Wick SMT: This is "Micro-SMT." It compares the current candle's wick to the previous candle's wick. If the main symbol makes a Higher High but the correlated symbol does not, it flags an immediate divergence.
• Structural Pivot SMT: This is "Macro-SMT." It uses three different lookback lengths (Primary, Secondary, and Tertiary) to find divergences across major market swings.
2. Dynamic Invalidation Logic (The "Mended Crack")
A common issue with SMT indicators is that they stay on the chart forever. Your code solves this with a Reference Price Check:
• The Logic: When a divergence is found, the script stores the correlated symbol’s high/low in an array (adj_up_comp_refs).
• The Invalidation: If the correlated symbol eventually "catches up" and breaks that stored reference price, the "crack" is considered mended. The script then executes a while loop to purge the lines and labels from the chart automatically.
3. Advanced Memory Management (Array-Based)
This allows the script to track multiple concurrent SMTs. If three different divergences happen in a row, the script can display and manage all of them independently without hitting TradingView's drawing limits or "forgetting" old levels.
4. Triple-Length Pivot Analysis
By using three different pivot lengths (3, 5, and 8), the SMT engine filters "Market Noise":
• Tertiary (3): For scalpers looking for quick entries.
• Primary (5): For standard intraday trend changes.
• Secondary (8): For major structural shifts and daily bias reversals.
5. Algorithmic Correlation Mapping
The script uses fixnan(ta.pivothigh(...)) to ensure that the SMT lines are pinned exactly to the historical pivots, even if the comparison symbol has gaps in its data. This ensures that the "slope" of the SMT line is mathematically accurate, providing a clear visual of the divergence.
⚒️How to use ICT Internal Levels
Step 1: Establish the "Daily Anchor" (Midnight Open)
Before looking for trades, identify your bias using the Midnight Opening Price.
• Look at the Momentum section of your Checklist.
• If the script says "BULL" (price is below Midnight Open), you are in a Discount and should only look for Longs.
• If it says "BEAR" (price is above Midnight Open), you are in a Premium and should only look for Shorts.
Step 2: Identify the "Draw" (EQH/EQL & BSL/SSL)
Now, find out where the market is likely to go.
• The Scanner: Check the Multi-TF EQH/EQL Table. If you see "EQH" across multiple timeframes (1m, 5m, 15m), that is a high-probability Draw on Liquidity (DOL).
• The Levels: Look for the Major BSL/SSL lines. These are your "Targets." The market will likely seek these pools of money before reversing.
Step 3: Wait for the "Time Window" (Macros)
Don't trade in the "dead zones." Wait for price to enter a Macro Session (the highlighted vertical zones).
• Institutional volatility is most consistent during these windows (e.g., 09:50–10:10 AM).
• The Goal: You want to see price reach your "Draw" (from Step 2) during this time window.
Step 4: Confirm the "Crack" (SMT Divergence)
As price approaches a BSL or SSL level within a Macro window, look for an SMT label.
• If the asset you are trading (e.g., NQ) sweeps a high, but the comparison symbol (e.g., ES) does not, the SMT engine will plot a line.
• This confirms that "Smart Money" is actively distributing, and a reversal is imminent.
Step 5: The "Entry Signal" (HTF iFVG)
Wait for the Change in State of Delivery.
• Look for an iFVG (Inversion Fair Value Gap) to form on the 1m or 5m chart.
• When price closes through a gap, the HTF IFVG item on your Checklist will turn green. This is your "Green Light" to enter the market.
Step 6: Final Audit (The Checklist Grade)
Before clicking "Buy" or "Sell," look at the RATING in the bottom corner of the checklist.
• A+ / A: Execute with full confidence. All pillars (Time, Price, SMT, and HTF) are aligned.
• B+: High probability, but perhaps you are trading outside of a Macro or against the HTF Delivery. Use smaller risk.
• C: Avoid this setup; it is likely a trap or a low-probability scalp.
Step 7: Risk Management (Breakeven)
Once you are in the trade:
• Monitor the Breakeven status on the checklist.
• Once it switches to "YES" (usually after 10 bars or a significant move), move your Stop Loss to your entry price. You now have a "Risk-Free" trade.
⚠️ Risk Disclaimer
The ICT Internal Levels [Amaan] V2 is an educational tool for market analysis and does not provide financial advice or guaranteed "buy/sell" signals. Trading involves significant risk, and you may lose some or all of your invested capital.
No Guarantees: Past performance does not guarantee future results. While this script uses advanced logic to identify confluences, all market analysis involves probability, not certainty.
User Responsibility: The author is not liable for any financial losses resulting from the use of this indicator. You are solely responsible for your trading decisions and should always use proper risk management. Use this script to supplement your own manual analysis—never rely on an indicator alone for execution.
สคริปต์แบบเฉพาะผู้ได้รับเชิญเท่านั้น
เฉพาะผู้ใช้งานที่ผู้เขียนอนุมัตเท่านั้นจึงจะสามารถเข้าถึงสคริปต์นี้ได้ คุณจะต้องขอและได้รับอนุญาตก่อนใช้งาน ซึ่งโดยทั่วไปจะได้รับอนุญาตหลังจากชำระเงินแล้ว สำหรับรายละเอียดเพิ่มเติม โปรดทำตามคำแนะนำของผู้เขียนด้านล่าง หรือติดต่อ Yah7ya โดยตรง
TradingView ไม่แนะนำให้จ่ายเงินหรือใช้สคริปต์ เว้นแต่คุณจะเชื่อถือผู้เขียนและเข้าใจวิธีการทำงานของสคริปต์นั้นอย่างถ่องแท้ คุณยังสามารถหาทางเลือกแบบโอเพนซอร์สฟรีได้ใน สคริปต์ชุมชนของเรา
คำแนะนำของผู้เขียน
คำจำกัดสิทธิ์ความรับผิดชอบ
สคริปต์แบบเฉพาะผู้ได้รับเชิญเท่านั้น
เฉพาะผู้ใช้งานที่ผู้เขียนอนุมัตเท่านั้นจึงจะสามารถเข้าถึงสคริปต์นี้ได้ คุณจะต้องขอและได้รับอนุญาตก่อนใช้งาน ซึ่งโดยทั่วไปจะได้รับอนุญาตหลังจากชำระเงินแล้ว สำหรับรายละเอียดเพิ่มเติม โปรดทำตามคำแนะนำของผู้เขียนด้านล่าง หรือติดต่อ Yah7ya โดยตรง
TradingView ไม่แนะนำให้จ่ายเงินหรือใช้สคริปต์ เว้นแต่คุณจะเชื่อถือผู้เขียนและเข้าใจวิธีการทำงานของสคริปต์นั้นอย่างถ่องแท้ คุณยังสามารถหาทางเลือกแบบโอเพนซอร์สฟรีได้ใน สคริปต์ชุมชนของเรา