OPEN-SOURCE SCRIPT
Institutional Flow Matrix

Institutional Flow Matrix is an open-source market-analysis framework designed to organize trend direction, confirmed market structure, institutional price zones, momentum, and location within a dealing range into one readable chart.
The purpose of this indicator is not to predict every price movement or generate constant entries. It is designed to answer a more practical sequence of questions:
1. What is the current directional bias?
2. Is market structure supporting that direction?
3. Is price trading from a meaningful location?
4. Has price returned to an active institutional zone?
5. Is momentum aligned with the proposed setup?
The script combines these questions into a structured workflow while keeping the default chart intentionally clean.
WHY THIS INDICATOR WAS BUILT
Many market-structure indicators display every swing, imbalance, liquidity level, zone, and signal at the same time. While that information can be useful for detailed analysis, it can also make the chart difficult to interpret during live trading.
Institutional Flow Matrix was built around a visual hierarchy:
* Directional bias is the primary layer.
* Active Order Blocks are the principal reaction zones.
* Momentum is a confirmation layer.
* Premium and Discount provide market location.
* Fair Value Gaps, liquidity pools, sweeps, and higher-timeframe levels are optional study tools.
The default Balanced preset focuses on the information most relevant to a directional pullback setup. Minimal mode removes most supporting visuals for live execution. Full mode reveals the additional market-structure tools for deeper analysis.
WHAT MAKES THE IMPLEMENTATION DIFFERENT
The individual concepts used by this script, including pivots, moving averages, ATR trend filters, Order Blocks, Fair Value Gaps, and Premium/Discount ranges, are established forms of technical analysis.
The original contribution of Institutional Flow Matrix is how those components are synchronized and managed as one decision framework.
Key design elements include:
* Confirmed structure events rather than unconfirmed swing guesses.
* A persistent directional state requiring agreement between structure, EMA alignment, and an ATR-based trend filter.
* Order Block freshness validation before a zone is accepted.
* Separate visual duration and analytical lifetime controls for zones.
* Automatic mitigation and expiration of old zones.
* Limited drawing-object counts to prevent long-term chart clutter.
* A weighted confluence model centered on trend, structure, zone interaction, market location, and momentum.
* Three visual presets that change the information hierarchy without changing the underlying calculations.
* Confirmed-bar signals and event-based alerts.
This is not intended to be a collection of unrelated indicators. Each module has a defined role in the same setup process.
DIRECTIONAL BIAS
The chart background represents the script's confirmed directional state.
A bullish state requires agreement between:
* Bullish market structure.
* Fast EMA positioning above the slow EMA.
* Bullish ATR trend conditions.
A bearish state uses the opposite conditions.
The background changes only after the required conditions are confirmed. A larger BUY or SELL label marks a confirmed change in this directional state.
These shift labels are different from the smaller confluence signals. A shift label identifies a change in directional bias. A confluence signal requires additional location, zone, and momentum conditions.
MARKET STRUCTURE
Confirmed pivot highs and lows form the structure engine.
The script tracks:
* Higher Highs
* Higher Lows
* Lower Highs
* Lower Lows
* Breaks of Structure
* Changes of Character
A bullish break occurs when a confirmed bar closes above the latest unbroken confirmed swing high. A bearish break occurs when a confirmed bar closes below the latest unbroken confirmed swing low.
Swing labels are retrospective by design. A pivot can only be confirmed after the selected number of right-side bars has closed. Once confirmed, its label is placed on the candle where the swing originally occurred. The label was not known on that earlier candle.
ORDER BLOCKS
Order Blocks are the primary reaction zones in the indicator.
After a confirmed structure break or qualifying displacement event, the script searches backward for an opposing candle. A candidate candle can be filtered by:
* Candle range relative to ATR.
* Body size as a percentage of candle range.
* Optional volume expansion.
* Wick-based or body-based zone construction.
Before accepting the candidate, the script checks whether price has already invalidated it. This prevents many stale zones from being created after the fact.
Active Order Blocks can be invalidated by either:
* A close beyond the opposite edge.
* A wick beyond the opposite edge.
The selected mitigation method is used consistently during both zone creation and live zone management.
Order Blocks have separate controls for visual extension and analytical age. This allows users to control how long a box remains visible independently from how long it remains eligible for signal calculations.
PREMIUM, DISCOUNT, AND EQUILIBRIUM
The script creates a rolling dealing range from the highest high and lowest low over the selected lookback.
The range is divided into:
* Premium: the upper portion of the range.
* Discount: the lower portion of the range.
* Equilibrium: the 50% midpoint.
Premium and Discount do not generate trades by themselves. They provide location.
In general:
* Bullish setups receive stronger contextual support in Discount.
* Bearish setups receive stronger contextual support in Premium.
* Equilibrium represents the midpoint of the current rolling range.
Because the range is rolling, its boundaries can change when a new lookback high or low is formed.
MOMENTUM RIBBON
The momentum module uses three exponential moving averages and an ATR-normalized difference between the fast and slow averages.
Bullish momentum requires:
* Fast EMA above the slow EMA.
* Positive normalized momentum.
* Momentum above its signal average.
Bearish momentum uses the opposite conditions.
Diamond markers identify confirmed momentum crossings. The ribbon is intended as confirmation rather than a standalone entry system.
CONFLUENCE SIGNALS
The script calculates a 0-100 Confluence Score from five conditions:
* Directional bias: 25 points.
* Market structure: 15 points.
* Momentum alignment: 15 points.
* Active Order Block interaction: 25 points.
* Premium or Discount location: 20 points.
The score measures condition alignment. It is not a probability, win rate, accuracy estimate, or forecast of future performance.
By default, BUY and SELL signals require:
* Confirmed directional bias.
* Matching confirmed structure.
* Interaction with an active Order Block.
* Correct Premium or Discount location.
* Matching momentum.
* Minimum Confluence Score.
* Completion of the selected signal cooldown.
Signals are displayed only when the complete condition changes from false to true. This prevents repeated labels while the same setup remains active.
OPTIONAL ADVANCED MODULES
Full mode provides additional analytical tools:
* Fair Value Gaps with ATR size filtering.
* Equal-high and equal-low liquidity pools.
* Confirmed liquidity sweeps.
* BOS and CHoCH labels.
* HH, HL, LH, and LL labels.
* Previous day, week, and month highs and lows.
* Optional momentum candle coloring.
These features are disabled or hidden from the default Balanced view to preserve readability.
VISUAL PRESETS
Minimal:
Designed for traders who want the least chart interference. It suppresses the background, ribbon, Premium/Discount display, trailing line, dashboard, and advanced structure annotations.
Balanced:
The default view. It emphasizes directional background, active Order Blocks, Premium/Discount context, momentum ribbon, diamonds, signals, and the dashboard.
Full:
Designed for detailed study. It adds structure labels, BOS/CHoCH events, Fair Value Gaps, liquidity tools, higher-timeframe levels, and optional candle coloring.
FOR NEWER TRADERS
A simple workflow is:
1. Start with the Balanced preset.
2. Use the background to identify the current directional bias.
3. Wait for price to return to an Order Block matching that bias.
4. Check whether price is in Discount for a bullish setup or Premium for a bearish setup.
5. Confirm that the momentum ribbon agrees.
6. Treat the signal as a point for further analysis, not an automatic order.
The equilibrium line can be used as a reference for the midpoint of the current dealing range. It is not automatically an entry or exit instruction.
FOR ADVANCED TRADERS
Experienced users can customize:
* Pivot confirmation sensitivity.
* ATR and EMA trend parameters.
* Wick-based versus body-based Order Blocks.
* Displacement-created zones.
* Candle body, range, and volume filters.
* Close-based versus wick-based mitigation.
* Zone visual duration and analytical age.
* Premium and Discount percentages.
* Fair Value Gap size.
* Liquidity sensitivity.
* Momentum lengths.
* Individual signal requirements.
* Minimum confluence threshold.
* Signal cooldown.
* Higher-timeframe reference levels.
Advanced users can also disable individual hard requirements and use the Confluence Score as a more flexible filtering system.
ALERTS
Alert conditions are included for:
* Break of Structure.
* Change of Character.
* New Order Block.
* BUY signal.
* SELL signal.
* Bias-aligned Order Block entry.
* Trend and momentum confluence.
* Liquidity sweep.
Alerts should be created using Once Per Bar Close when confirmed signals are required.
NON-REPAINTING AND TIMING
Structure breaks, directional shifts, zone creation, zone mitigation, momentum events, and confluence signals are evaluated on confirmed bars.
Pivot-based swing labels require future bars to confirm that a swing occurred. After confirmation, the label is displayed on the original pivot candle. This is delayed confirmation with retrospective placement, not advance knowledge of the swing.
Previous-period levels use completed higher-timeframe data.
LIMITATIONS
* This indicator does not predict future prices.
* It does not calculate position size, stop loss, or account risk.
* It is not a complete automated trading system.
* Signals can fail during volatile, illiquid, or range-bound conditions.
* Rolling Premium, Discount, and equilibrium levels can move when the lookback range changes.
* Confirmed pivots introduce an intentional delay.
* Order Block definitions vary among trading methodologies; this script uses the documented candle-search and filtering rules described above.
* Volume behavior differs across asset classes and data providers.
* Parameter settings that work on one symbol or timeframe may not be appropriate for another.
Suggested starting points are the 15-minute and 1-hour charts for intraday analysis and the 4-hour chart for broader swing structure. Users should test settings on their own symbols and trading sessions.
OPEN-SOURCE PURPOSE
The script is published open-source so traders can inspect the calculations, understand why signals occur, verify the confirmed-bar methodology, and adapt the framework for their own research.
The goal is to provide a readable and transparent market-structure workflow rather than a black-box prediction tool.
DISCLAIMER
This indicator is provided for educational and analytical purposes only. It is not financial advice and does not guarantee profitable results. Historical chart behavior does not ensure future performance. Users are responsible for their own analysis, testing, risk management, and trading decisions.
The purpose of this indicator is not to predict every price movement or generate constant entries. It is designed to answer a more practical sequence of questions:
1. What is the current directional bias?
2. Is market structure supporting that direction?
3. Is price trading from a meaningful location?
4. Has price returned to an active institutional zone?
5. Is momentum aligned with the proposed setup?
The script combines these questions into a structured workflow while keeping the default chart intentionally clean.
WHY THIS INDICATOR WAS BUILT
Many market-structure indicators display every swing, imbalance, liquidity level, zone, and signal at the same time. While that information can be useful for detailed analysis, it can also make the chart difficult to interpret during live trading.
Institutional Flow Matrix was built around a visual hierarchy:
* Directional bias is the primary layer.
* Active Order Blocks are the principal reaction zones.
* Momentum is a confirmation layer.
* Premium and Discount provide market location.
* Fair Value Gaps, liquidity pools, sweeps, and higher-timeframe levels are optional study tools.
The default Balanced preset focuses on the information most relevant to a directional pullback setup. Minimal mode removes most supporting visuals for live execution. Full mode reveals the additional market-structure tools for deeper analysis.
WHAT MAKES THE IMPLEMENTATION DIFFERENT
The individual concepts used by this script, including pivots, moving averages, ATR trend filters, Order Blocks, Fair Value Gaps, and Premium/Discount ranges, are established forms of technical analysis.
The original contribution of Institutional Flow Matrix is how those components are synchronized and managed as one decision framework.
Key design elements include:
* Confirmed structure events rather than unconfirmed swing guesses.
* A persistent directional state requiring agreement between structure, EMA alignment, and an ATR-based trend filter.
* Order Block freshness validation before a zone is accepted.
* Separate visual duration and analytical lifetime controls for zones.
* Automatic mitigation and expiration of old zones.
* Limited drawing-object counts to prevent long-term chart clutter.
* A weighted confluence model centered on trend, structure, zone interaction, market location, and momentum.
* Three visual presets that change the information hierarchy without changing the underlying calculations.
* Confirmed-bar signals and event-based alerts.
This is not intended to be a collection of unrelated indicators. Each module has a defined role in the same setup process.
DIRECTIONAL BIAS
The chart background represents the script's confirmed directional state.
A bullish state requires agreement between:
* Bullish market structure.
* Fast EMA positioning above the slow EMA.
* Bullish ATR trend conditions.
A bearish state uses the opposite conditions.
The background changes only after the required conditions are confirmed. A larger BUY or SELL label marks a confirmed change in this directional state.
These shift labels are different from the smaller confluence signals. A shift label identifies a change in directional bias. A confluence signal requires additional location, zone, and momentum conditions.
MARKET STRUCTURE
Confirmed pivot highs and lows form the structure engine.
The script tracks:
* Higher Highs
* Higher Lows
* Lower Highs
* Lower Lows
* Breaks of Structure
* Changes of Character
A bullish break occurs when a confirmed bar closes above the latest unbroken confirmed swing high. A bearish break occurs when a confirmed bar closes below the latest unbroken confirmed swing low.
Swing labels are retrospective by design. A pivot can only be confirmed after the selected number of right-side bars has closed. Once confirmed, its label is placed on the candle where the swing originally occurred. The label was not known on that earlier candle.
ORDER BLOCKS
Order Blocks are the primary reaction zones in the indicator.
After a confirmed structure break or qualifying displacement event, the script searches backward for an opposing candle. A candidate candle can be filtered by:
* Candle range relative to ATR.
* Body size as a percentage of candle range.
* Optional volume expansion.
* Wick-based or body-based zone construction.
Before accepting the candidate, the script checks whether price has already invalidated it. This prevents many stale zones from being created after the fact.
Active Order Blocks can be invalidated by either:
* A close beyond the opposite edge.
* A wick beyond the opposite edge.
The selected mitigation method is used consistently during both zone creation and live zone management.
Order Blocks have separate controls for visual extension and analytical age. This allows users to control how long a box remains visible independently from how long it remains eligible for signal calculations.
PREMIUM, DISCOUNT, AND EQUILIBRIUM
The script creates a rolling dealing range from the highest high and lowest low over the selected lookback.
The range is divided into:
* Premium: the upper portion of the range.
* Discount: the lower portion of the range.
* Equilibrium: the 50% midpoint.
Premium and Discount do not generate trades by themselves. They provide location.
In general:
* Bullish setups receive stronger contextual support in Discount.
* Bearish setups receive stronger contextual support in Premium.
* Equilibrium represents the midpoint of the current rolling range.
Because the range is rolling, its boundaries can change when a new lookback high or low is formed.
MOMENTUM RIBBON
The momentum module uses three exponential moving averages and an ATR-normalized difference between the fast and slow averages.
Bullish momentum requires:
* Fast EMA above the slow EMA.
* Positive normalized momentum.
* Momentum above its signal average.
Bearish momentum uses the opposite conditions.
Diamond markers identify confirmed momentum crossings. The ribbon is intended as confirmation rather than a standalone entry system.
CONFLUENCE SIGNALS
The script calculates a 0-100 Confluence Score from five conditions:
* Directional bias: 25 points.
* Market structure: 15 points.
* Momentum alignment: 15 points.
* Active Order Block interaction: 25 points.
* Premium or Discount location: 20 points.
The score measures condition alignment. It is not a probability, win rate, accuracy estimate, or forecast of future performance.
By default, BUY and SELL signals require:
* Confirmed directional bias.
* Matching confirmed structure.
* Interaction with an active Order Block.
* Correct Premium or Discount location.
* Matching momentum.
* Minimum Confluence Score.
* Completion of the selected signal cooldown.
Signals are displayed only when the complete condition changes from false to true. This prevents repeated labels while the same setup remains active.
OPTIONAL ADVANCED MODULES
Full mode provides additional analytical tools:
* Fair Value Gaps with ATR size filtering.
* Equal-high and equal-low liquidity pools.
* Confirmed liquidity sweeps.
* BOS and CHoCH labels.
* HH, HL, LH, and LL labels.
* Previous day, week, and month highs and lows.
* Optional momentum candle coloring.
These features are disabled or hidden from the default Balanced view to preserve readability.
VISUAL PRESETS
Minimal:
Designed for traders who want the least chart interference. It suppresses the background, ribbon, Premium/Discount display, trailing line, dashboard, and advanced structure annotations.
Balanced:
The default view. It emphasizes directional background, active Order Blocks, Premium/Discount context, momentum ribbon, diamonds, signals, and the dashboard.
Full:
Designed for detailed study. It adds structure labels, BOS/CHoCH events, Fair Value Gaps, liquidity tools, higher-timeframe levels, and optional candle coloring.
FOR NEWER TRADERS
A simple workflow is:
1. Start with the Balanced preset.
2. Use the background to identify the current directional bias.
3. Wait for price to return to an Order Block matching that bias.
4. Check whether price is in Discount for a bullish setup or Premium for a bearish setup.
5. Confirm that the momentum ribbon agrees.
6. Treat the signal as a point for further analysis, not an automatic order.
The equilibrium line can be used as a reference for the midpoint of the current dealing range. It is not automatically an entry or exit instruction.
FOR ADVANCED TRADERS
Experienced users can customize:
* Pivot confirmation sensitivity.
* ATR and EMA trend parameters.
* Wick-based versus body-based Order Blocks.
* Displacement-created zones.
* Candle body, range, and volume filters.
* Close-based versus wick-based mitigation.
* Zone visual duration and analytical age.
* Premium and Discount percentages.
* Fair Value Gap size.
* Liquidity sensitivity.
* Momentum lengths.
* Individual signal requirements.
* Minimum confluence threshold.
* Signal cooldown.
* Higher-timeframe reference levels.
Advanced users can also disable individual hard requirements and use the Confluence Score as a more flexible filtering system.
ALERTS
Alert conditions are included for:
* Break of Structure.
* Change of Character.
* New Order Block.
* BUY signal.
* SELL signal.
* Bias-aligned Order Block entry.
* Trend and momentum confluence.
* Liquidity sweep.
Alerts should be created using Once Per Bar Close when confirmed signals are required.
NON-REPAINTING AND TIMING
Structure breaks, directional shifts, zone creation, zone mitigation, momentum events, and confluence signals are evaluated on confirmed bars.
Pivot-based swing labels require future bars to confirm that a swing occurred. After confirmation, the label is displayed on the original pivot candle. This is delayed confirmation with retrospective placement, not advance knowledge of the swing.
Previous-period levels use completed higher-timeframe data.
LIMITATIONS
* This indicator does not predict future prices.
* It does not calculate position size, stop loss, or account risk.
* It is not a complete automated trading system.
* Signals can fail during volatile, illiquid, or range-bound conditions.
* Rolling Premium, Discount, and equilibrium levels can move when the lookback range changes.
* Confirmed pivots introduce an intentional delay.
* Order Block definitions vary among trading methodologies; this script uses the documented candle-search and filtering rules described above.
* Volume behavior differs across asset classes and data providers.
* Parameter settings that work on one symbol or timeframe may not be appropriate for another.
Suggested starting points are the 15-minute and 1-hour charts for intraday analysis and the 4-hour chart for broader swing structure. Users should test settings on their own symbols and trading sessions.
OPEN-SOURCE PURPOSE
The script is published open-source so traders can inspect the calculations, understand why signals occur, verify the confirmed-bar methodology, and adapt the framework for their own research.
The goal is to provide a readable and transparent market-structure workflow rather than a black-box prediction tool.
DISCLAIMER
This indicator is provided for educational and analytical purposes only. It is not financial advice and does not guarantee profitable results. Historical chart behavior does not ensure future performance. Users are responsible for their own analysis, testing, risk management, and trading decisions.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。