OPEN-SOURCE SCRIPT

Advanced ICT Theory - A-ICT

8 358
📊 Advanced ICT Theory (A-ICT): The Institutional Manipulation Detector

Are you tired of being the liquidity? Stop chasing shadows and start tracking the architects of price movement.

This is not another lagging indicator. This is a complete framework for viewing the market through the lens of institutional traders. Advanced ICT Theory (A-ICT) is an all-in-one, military-grade analysis engine designed to decode the complex language of "Smart Money." It automates the core tenets of Inner Circle Trader (ICT) methodology, moving beyond simple patterns to build a dynamic, real-time narrative of market manipulation, liquidity engineering, and institutional order flow.

AIT provides a living blueprint of the market, identifying high-probability zones, tracking structural shifts, and scoring the quality of setups with a sophisticated, multi-factor algorithm. This is your X-ray into the market's true intentions.

🔬 THE CORE ENGINE: DECODING THE THEORY & FORMULAS
A-ICT is built upon a sophisticated, multi-layered logic system that interprets price action as a story of cause and effect. It does not guess; it confirms. Here is the foundational theory that drives the engine:

1. Market Structure: The Blueprint of Trend
The script first establishes a deep understanding of the market's skeleton through multi-level pivot analysis. It uses ta.pivothigh and ta.pivotlow to identify significant swing points.
Internal Structure (iBOS): Minor swings that show the short-term order flow. A break of internal structure is the first whisper of a potential shift.
External Structure (eBOS): Major swing points that define the primary trend. A confirmed break of external structure is a powerful statement of trend continuation. AIT validates this with optional Volume Confirmation (volume > volumeSMA * 1.2) and Candle Confirmation to ensure the break is driven by institutional force, not just a random spike.
Change of Character (CHoCH): This is the earthquake. A CHoCH occurs when a confirmed eBOS happens against the prevailing trend (e.g., a bearish eBOS in a clear uptrend). A-ICT flags this immediately, as it is the strongest signal that the primary trend is under threat of reversal.

2. Liquidity Engineering: The Fuel of the Market
Institutions don't buy into strength; they buy into weakness. They need liquidity. A-ICT maps these liquidity pools with forensic precision:
Buyside & Sellside Liquidity (BSL/SSL): Using ta.highest and ta.lowest, AIT identifies recent highs and lows where clusters of stop-loss orders (liquidity) are resting. These are institutional targets.
Liquidity Sweeps: This is the "manipulation" part of the detector. AIT has a specific formula to detect a sweep: high > bsl[1] and close < bsl[1]. This signifies that institutions pushed price just high enough to trigger buy-stops before aggressively selling—a classic "stop hunt." This event dramatically increases the quality score of subsequent patterns.

3. The Element Lifecycle: From Potential to Power
This is the revolutionary heart of A-ICT. Zones are not static; they have a lifecycle. AIT tracks this with its dynamic classification engine.
Phase 1: PENDING (Yellow): The script identifies a potential zone of interest based on a specific candle formation (a "displacement"). It is marked as "Pending" because its true nature is unknown. It is a question.
Phase 2: CLASSIFICATION: After the zone is created, AIT watches what happens next. The zone's identity is defined by its actions:
ORDER BLOCK (Blue): The highest-grade element. A zone is classified as an Order Block if it directly causes a Break of Structure (BOS). This is the footprint of institutions entering the market with enough force to validate the new trend direction.
TRAP ZONE (Orange): A zone is classified as a Trap Zone if it is directly involved in a Liquidity Sweep. This indicates the zone was used to engineer liquidity, setting a "trap" for retail traders before a reversal.
REVERSAL / S&R ZONE (Green): If a zone is not powerful enough to cause a BOS or a major sweep, but still serves as a pivot point, it's classified as a general support/resistance or reversal zone.

4. Market Inefficiencies: Gaps in the Matrix
Fair Value Gaps (FVG): AIT detects FVGs—a 3-bar pattern indicating an imbalance—with a strict formula: low > high[2] (for a bullish FVG) and gapSize > atr14 * 0.5. This ensures only significant, volatile gaps are shown. An FVG co-located with an Order Block is a high-confluence setup.
5. Premium & Discount: The Law of Value
Institutions buy at wholesale (Discount) and sell at retail (Premium). AIT uses a pdLookback to define the current dealing range and divides it into three zones: Premium (sell zone), Discount (buy zone), and Equilibrium. An element's quality score is massively boosted if it aligns with this principle (e.g., a bullish Order Block in a Discount zone).
⚙️ THE CONTROL PANEL: A COMPLETE GUIDE TO THE INPUTS MENU
Every setting is a lever, allowing you to tune the AIT engine to your exact specifications. Master these to unlock the script's full potential.

🎯 A-ICT Detection Engine
Min Displacement Candles: Controls the sensitivity of element detection. How it works: It defines the number of subsequent candles that must be "inside" a large parent candle. Best practice: Use 2-3 for a balanced view on most timeframes. A higher number (4-5) will find only major, more significant zones, ideal for swing trading. A lower number (1) is highly sensitive, suitable for scalping.

Mitigation Method: Defines when a zone is considered "used up" or mitigated. How it works: Cross triggers as soon as price touches the zone's boundary. Close requires a candle to fully close beyond it. Best practice: Cross is more responsive for fast-moving markets. Close is more conservative and helps filter out fake-outs caused by wicks, making it safer for confirmations.

Min Element Size (ATR): A crucial noise filter. How it works: It requires a detected zone to be at least this multiple of the Average True Range (ATR). Best practice: Keep this around 0.5. If you see too many tiny, irrelevant zones, increase this value to 0.8 or 1.0. If you feel the script is missing smaller but valid zones, decrease it to 0.3.

Age Threshold & Pending Timeout: These manage visual clutter. How they work: Age Threshold removes old, mitigated elements after a set number of bars. Pending Timeout removes a "Pending" element if it isn't classified within a certain window. Best practice: The default settings are optimized. If your chart feels cluttered, reduce the Age Threshold. If pending zones disappear too quickly, increase the Pending Timeout.

Min Quality Threshold: Your primary visual filter. How it works: It hides all elements (boxes, lines, labels) that do not meet this minimum quality score (0-100). Best practice: Start with the default 30. To see only A- or B-grade setups, increase this to 60 or 70 for an exceptionally clean, high-probability view.

🏗️ Market Structure
Lookbacks (Internal, External, Major): These define the sensitivity of the trend analysis. How they work: They set the number of bars to the left and right for pivot detection. Best practice: Use smaller values for Internal (e.g., 3) to see minor structure and larger values for External (e.g., 10-15) to map the main trend. For a macro, long-term view, increase the Major Swing Lookback.

Require Volume/Candle Confirmation: Toggles for quality control on BOS/CHoCH signals. Best practice: It is highly recommended to keep these enabled. Disabling them will result in more structure signals, but many will be false alarms. They are your filter against market noise.

... (Continue this detailed breakdown for every single input group: Display Configuration, Zones Style, Levels Appearance, Colors, Dashboards, MTF, Liquidity, Premium/Discount, Sessions, and IPDA).

📊 THE INTELLIGENCE DASHBOARDS: YOUR COMMAND CENTER
The dashboards synthesize all the complex analysis into a simple, actionable intelligence briefing.

Main Dashboard (Bottom Right)
ICT Metrics & Breakdown: This is your statistical overview. Total Elements shows how much structure the script is tracking. High Quality instantly tells you if there are any A/B grade setups nearby. Unmitigated vs. Mitigated shows the balance of fresh opportunities versus resolved price action. The breakdown by Order Blocks, Trap Zones, etc., gives you a quick read on the market's recent character.

Structure & Market Context: This is your core bias. Order Flow tells you the current script-determined trend. Last BOS shows you the most recent structural event. CHoCH Active is a critical warning. HTF Bias shows if you are aligned with the higher timeframe—the checkmark (✓) for alignment is one of the most important confluence factors.

Smart Money Flow: A volume-based sentiment gauge. Net Flow shows the raw buying vs. selling pressure, while the Bias provides an interpretation (e.g., "STRONG BULLISH FLOW").

Key Guide (Large Dashboard only): A built-in legend so you never have to guess. It defines every pattern, structure type, and special level visually.

📖 Narrative Dashboard (Bottom Left)
This is the "story" of the market, updated in real-time. It's designed to build your trading thesis.

Recent Elements Table: A live list of the most recent, high-quality setups. It displays the Type, its Narrative Role (e.g., "Bullish OB caused BOS"), its raw Quality percentage, and its final Trade Score grade. This is your at-a-glance opportunity scanner.

Market Narrative Section: This is the soul of A-ICT. It combines all data points into a human-readable story:

📍 Current Phase: Tells you if you are in a high-volatility Killzone or a consolidation phase like the Asian Range.

🎯 Bias & Alignment: Your primary direction, with a clear indicator of HTF alignment or conflict.

🔗 Events: A causal sequence of recent events, like "💧 Sell-side liquidity swept →

📊 Bullish BOS → 🎯 Active Order Block".

🎯 Next Expectation: The script's logical conclusion. It provides a specific, forward-looking hypothesis, such as "📉 Pullback expected to bullish OB at 1.2345 before continuation up."

🎨 READING THE BATTLEFIELD: A VISUAL INTERPRETATION GUIDE
Every color and line is a piece of information. Learn to read them together to see the full picture.

The Core Zones (Boxes):
Blue Box (Order Block): Highest probability zone for trend continuation. Look for entries here.

Orange Box (Trap Zone): A manipulation footprint. Expect a potential reversal after price interacts with this zone.

Green Box (Reversal/S&R): A standard pivot area. A good reference point but requires more confluence.

Purple Box (FVG): A market imbalance. Acts as a magnet for price. An FVG inside an Order Block is an A+ confluence.

The Structural Lines:
Green/Red Line (eBOS): Confirms the trend direction. A break above the green line is bullish; a break below the red line is bearish.

Thick Orange Line (CHoCH): WARNING. The previous trend is now in question. The market character has changed.

Blue/Red Lines (BSL/SSL): Liquidity targets. Expect price to gravitate towards these lines. A dotted line with a checkmark (✓) means the liquidity has been "swept" or "purged."

How to Synthesize: The magic is in the confluence. A perfect setup might look like this: Price sweeps below a red SSL line, enters a green Discount Zone during the NY Killzone, and forms a blue Order Block which then causes a green eBOS. This sequence, visible at a glance, is the story of a high-probability long setup.

🔧 THE ARCHITECT'S VISION: THE DEVELOPMENT JOURNEY
A-ICT was forged from the frustration of using lagging indicators in a market that is forward-looking. Traditional tools are reactive; they tell you what happened. The vision for A-ICT was to create a proactive engine that could anticipate institutional behavior by understanding their objectives: liquidity and efficiency. The development process was centered on creating a "lifecycle" for price patterns—the idea that a zone's true meaning is only revealed by its consequence. This led to the post-breakout classification system and the narrative-building engine. It's designed not just to show you patterns, but to tell you their story.

⚠️ RISK DISCLAIMER & BEST PRACTICES
Advanced ICT Theory (A-ICT) is a professional-grade analytical tool and does not provide financial advice or direct buy/sell signals. Its analysis is based on historical price action and probabilities. All forms of trading involve substantial risk. Past performance is not indicative of future results. Always use this tool as part of a comprehensive trading plan that includes your own analysis and a robust risk management strategy. Do not trade based on this indicator alone.

観の目つよく、見の目よわく
"Kan no me tsuyoku, ken no me yowaku"
— Miyamoto Musashi, The Book of Five Rings
English: "Perceive that which cannot be seen with the eye."

— Dskyz, Trade with insight. Trade with anticipation.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.