OPEN-SOURCE SCRIPT
Atualizado Supply Demand Flip Planner [AGPro Series]

Supply Demand Flip Planner [AGPro Series]
🧠 Core Idea
Has an old supply or demand zone changed role and started acting as the opposite side of the market?
📌 Overview / What it does
Supply Demand Flip Planner is a role-change price action tool designed to identify when a prior supply zone turns into demand, or when a prior demand zone turns into supply.
The script detects pivot-based supply and demand zones, monitors breaks through those zones, maps the active flip zone, evaluates retest acceptance, and displays a structured 0-100 score. It also shows invalidation shelves, target rails, centered zone text, labels, and a compact AG Pro dashboard.
It does not predict future price movement, automate trades, or provide guaranteed buy/sell signals. It is a visual decision-support framework for reading supply-demand flip behavior.
🎯 Purpose & Design Philosophy
This script was built for traders who watch support/resistance role reversal but want a cleaner way to separate meaningful flips from ordinary breaks.
Many zones break and never matter again. Some zones break, retest, and start acting as the opposite side of the market. This planner focuses on that role-change moment.
The design supports a structured workflow: map supply and demand, wait for break, monitor retest, evaluate acceptance, then track invalidation.
⚡ Why This Script Is Different
Most supply and demand tools draw zones and leave interpretation fully manual.
This script does NOT simply flood the chart with historical zones.
Instead, it focuses on the active role-change zone, measures retest quality, scores acceptance, and presents the result through a clear READY / MONITOR / WAIT / INVALIDATED framework.
⚙️ Methodology
1. Context Detection
The script detects pivot-based supply and demand zones using configurable left/right pivot confirmation.
2. Reference Mapping
It maps source supply and demand shelves, then converts a broken zone into an active flip zone.
3. Reaction Evaluation
When price retests the flip zone, the script evaluates break strength, retest depth, wick response, body quality, source-zone quality, freshness, and relative volume.
4. Visual Output
The active flip zone is shown with centered text, invalidation shelf, target rails, right-side tags, labels, and an AG Pro panel.
🗺️ How to Read the Chart
Supply zones represent pivot-based resistance shelves.
Demand zones represent pivot-based support shelves.
Demand Flip means old supply has been broken and is being evaluated as new demand.
Supply Flip means old demand has been broken and is being evaluated as new supply.
READY FLIP labels mark retests that pass the selected acceptance score.
Invalidation shelf marks where the flip context weakens or fails.
The AG Pro panel summarizes Flip State, Acceptance, Retest, Failure Risk, and Action.
🚦 Signals & States
• DEMAND → pivot-based demand zone mapped.
• SUPPLY → pivot-based supply zone mapped.
• DEMAND FLIP → old supply was broken and is being watched as new demand.
• SUPPLY FLIP → old demand was broken and is being watched as new supply.
• FLIP RETEST → price is interacting with the active flip zone.
• READY FLIP → retest acceptance reached the required score threshold.
• INVALIDATED → the active flip lost its invalidation edge.
• READY → qualified flip acceptance is active.
• MONITOR → the flip zone is active or retesting.
• WAIT → no qualified flip acceptance is active.
🔔 Alerts Logic
Demand Flip Locked triggers when price breaks above a prior supply zone.
Supply Flip Locked triggers when price breaks below a prior demand zone.
Demand Flip Acceptance Ready triggers when a bullish flip retest reaches the score threshold.
Supply Flip Acceptance Ready triggers when a bearish flip retest reaches the score threshold.
Supply Demand Flip Retest triggers when price interacts with the active flip zone.
Supply Demand Flip Invalidated triggers when the flip loses its invalidation shelf.
Alerts are attention markers, not trade instructions.
🧩 Confluence Logic
The strongest flip contexts appear when break strength, retest depth, wick response, close quality, source-zone quality, freshness, and relative volume align.
When a broken zone is retested cleanly and accepted from the opposite side, the score improves and the panel shifts toward a stronger action state.
📊 When to Use
• Support/resistance role reversal
• Breakout retests
• Trend continuation after zone breaks
• Failed range boundaries that become new reaction zones
• Markets with clear swing structure
⚠️ When NOT to Use
• Extremely noisy markets with weak pivot structure
• Very low liquidity symbols
• Markets with large spread or unreliable candles
• News spikes where zones break and fail too quickly
• Timeframes where pivot zones are too dense or too sparse
🎛️ Key Inputs
• Pivot Left / Right Bars → control how strict the source zone detection is.
• Zone Depth ATR → controls the thickness of supply and demand shelves.
• Break Buffer ATR → requires price to break beyond the source zone by a volatility-adjusted amount.
• Retest Window Bars → controls how long the flip remains relevant.
• Acceptance Buffer ATR → defines how much confirmation is required after retest.
• Invalidation Buffer ATR → controls the failure shelf beyond the flip zone.
• Minimum Ready Score → sets how strict READY labels should be.
• Visual Settings → control zones, labels, centered zone text, target rails, and right-side tags.
• Panel Settings → control panel visibility, location, theme, and font size.
🖥️ Interface & Visual Design
The interface is designed to make role-change structure readable without overwhelming the chart.
The active flip zone uses centered text so the purpose of the zone is immediately visible. Source zones are subtle, while READY labels and target rails stand out only when a valid acceptance context appears.
The panel gives a quick summary of the current flip state and risk context.
🧪 Practical Usage Workflow
1. Identify the latest supply and demand zones.
2. Wait for a zone to break and become a flip candidate.
3. Watch for retest interaction inside the flip zone.
4. Check the READY FLIP label and acceptance score.
5. Compare price with invalidation shelf and target rails.
6. Confirm broader trend, volatility, and liquidity before making decisions.
🔍 Interpretation Guidelines
A high acceptance score means the role-change reaction is cleaner according to the script's rules.
A pending retest means price has returned to the zone but has not yet shown enough acceptance.
A failed flip means price lost the invalidation edge and the role-change context should be treated as weakened.
🚫 What This Script Is NOT
This script is not a prediction engine.
It is not financial advice.
It is not an automated trading system.
It does not guarantee entries, exits, profits, or outcomes.
⚠️ Limitations & Transparency
Pivot-based zones are confirmed after the selected right-side bars, so source zones appear after confirmation.
Different timeframes can create very different supply and demand structures.
High volatility can cause quick break-and-fail behavior around zones.
No rule-based script can fully account for news, liquidity shocks, or sudden market structure changes.
🧠 Market Context Notes
Supply-demand flips are a form of role reversal.
Old resistance can become new support after acceptance. Old support can become new resistance after acceptance.
The script is strongest when used with broader market structure, trend context, liquidity, and volatility analysis.
🧾 Use Case Examples
When price breaks above a supply zone, returns to the zone, and holds above it with clean reaction quality, the script may mark a Demand Flip acceptance.
When price breaks below a demand zone, retests it from below, and rejects cleanly, the script may mark a Supply Flip acceptance.
🧱 System Philosophy
Supply Demand Flip Planner follows the AG Pro Series approach: transform a common market concept into a structured decision map with context, score, risk reference, and clean visuals.
The goal is not to replace judgment. The goal is to make role-change analysis easier to read.
🔐 Non-Promise Statement
No script can provide certainty.
No signal should be treated as guaranteed.
Outputs should always be interpreted with independent analysis and responsible risk control.
📉 Risk Disclosure
Trading involves risk.
Market conditions can change quickly.
Users are responsible for their own decisions, risk management, and trade execution.
This script is for educational and analytical purposes only and does not provide financial advice.
📚 Educational Note
This script is designed to help traders study how supply zones, demand zones, breakout retests, and role-change acceptance behave across different market conditions.
🧠 Core Idea
Has an old supply or demand zone changed role and started acting as the opposite side of the market?
📌 Overview / What it does
Supply Demand Flip Planner is a role-change price action tool designed to identify when a prior supply zone turns into demand, or when a prior demand zone turns into supply.
The script detects pivot-based supply and demand zones, monitors breaks through those zones, maps the active flip zone, evaluates retest acceptance, and displays a structured 0-100 score. It also shows invalidation shelves, target rails, centered zone text, labels, and a compact AG Pro dashboard.
It does not predict future price movement, automate trades, or provide guaranteed buy/sell signals. It is a visual decision-support framework for reading supply-demand flip behavior.
🎯 Purpose & Design Philosophy
This script was built for traders who watch support/resistance role reversal but want a cleaner way to separate meaningful flips from ordinary breaks.
Many zones break and never matter again. Some zones break, retest, and start acting as the opposite side of the market. This planner focuses on that role-change moment.
The design supports a structured workflow: map supply and demand, wait for break, monitor retest, evaluate acceptance, then track invalidation.
⚡ Why This Script Is Different
Most supply and demand tools draw zones and leave interpretation fully manual.
This script does NOT simply flood the chart with historical zones.
Instead, it focuses on the active role-change zone, measures retest quality, scores acceptance, and presents the result through a clear READY / MONITOR / WAIT / INVALIDATED framework.
⚙️ Methodology
1. Context Detection
The script detects pivot-based supply and demand zones using configurable left/right pivot confirmation.
2. Reference Mapping
It maps source supply and demand shelves, then converts a broken zone into an active flip zone.
3. Reaction Evaluation
When price retests the flip zone, the script evaluates break strength, retest depth, wick response, body quality, source-zone quality, freshness, and relative volume.
4. Visual Output
The active flip zone is shown with centered text, invalidation shelf, target rails, right-side tags, labels, and an AG Pro panel.
🗺️ How to Read the Chart
Supply zones represent pivot-based resistance shelves.
Demand zones represent pivot-based support shelves.
Demand Flip means old supply has been broken and is being evaluated as new demand.
Supply Flip means old demand has been broken and is being evaluated as new supply.
READY FLIP labels mark retests that pass the selected acceptance score.
Invalidation shelf marks where the flip context weakens or fails.
The AG Pro panel summarizes Flip State, Acceptance, Retest, Failure Risk, and Action.
🚦 Signals & States
• DEMAND → pivot-based demand zone mapped.
• SUPPLY → pivot-based supply zone mapped.
• DEMAND FLIP → old supply was broken and is being watched as new demand.
• SUPPLY FLIP → old demand was broken and is being watched as new supply.
• FLIP RETEST → price is interacting with the active flip zone.
• READY FLIP → retest acceptance reached the required score threshold.
• INVALIDATED → the active flip lost its invalidation edge.
• READY → qualified flip acceptance is active.
• MONITOR → the flip zone is active or retesting.
• WAIT → no qualified flip acceptance is active.
🔔 Alerts Logic
Demand Flip Locked triggers when price breaks above a prior supply zone.
Supply Flip Locked triggers when price breaks below a prior demand zone.
Demand Flip Acceptance Ready triggers when a bullish flip retest reaches the score threshold.
Supply Flip Acceptance Ready triggers when a bearish flip retest reaches the score threshold.
Supply Demand Flip Retest triggers when price interacts with the active flip zone.
Supply Demand Flip Invalidated triggers when the flip loses its invalidation shelf.
Alerts are attention markers, not trade instructions.
🧩 Confluence Logic
The strongest flip contexts appear when break strength, retest depth, wick response, close quality, source-zone quality, freshness, and relative volume align.
When a broken zone is retested cleanly and accepted from the opposite side, the score improves and the panel shifts toward a stronger action state.
📊 When to Use
• Support/resistance role reversal
• Breakout retests
• Trend continuation after zone breaks
• Failed range boundaries that become new reaction zones
• Markets with clear swing structure
⚠️ When NOT to Use
• Extremely noisy markets with weak pivot structure
• Very low liquidity symbols
• Markets with large spread or unreliable candles
• News spikes where zones break and fail too quickly
• Timeframes where pivot zones are too dense or too sparse
🎛️ Key Inputs
• Pivot Left / Right Bars → control how strict the source zone detection is.
• Zone Depth ATR → controls the thickness of supply and demand shelves.
• Break Buffer ATR → requires price to break beyond the source zone by a volatility-adjusted amount.
• Retest Window Bars → controls how long the flip remains relevant.
• Acceptance Buffer ATR → defines how much confirmation is required after retest.
• Invalidation Buffer ATR → controls the failure shelf beyond the flip zone.
• Minimum Ready Score → sets how strict READY labels should be.
• Visual Settings → control zones, labels, centered zone text, target rails, and right-side tags.
• Panel Settings → control panel visibility, location, theme, and font size.
🖥️ Interface & Visual Design
The interface is designed to make role-change structure readable without overwhelming the chart.
The active flip zone uses centered text so the purpose of the zone is immediately visible. Source zones are subtle, while READY labels and target rails stand out only when a valid acceptance context appears.
The panel gives a quick summary of the current flip state and risk context.
🧪 Practical Usage Workflow
1. Identify the latest supply and demand zones.
2. Wait for a zone to break and become a flip candidate.
3. Watch for retest interaction inside the flip zone.
4. Check the READY FLIP label and acceptance score.
5. Compare price with invalidation shelf and target rails.
6. Confirm broader trend, volatility, and liquidity before making decisions.
🔍 Interpretation Guidelines
A high acceptance score means the role-change reaction is cleaner according to the script's rules.
A pending retest means price has returned to the zone but has not yet shown enough acceptance.
A failed flip means price lost the invalidation edge and the role-change context should be treated as weakened.
🚫 What This Script Is NOT
This script is not a prediction engine.
It is not financial advice.
It is not an automated trading system.
It does not guarantee entries, exits, profits, or outcomes.
⚠️ Limitations & Transparency
Pivot-based zones are confirmed after the selected right-side bars, so source zones appear after confirmation.
Different timeframes can create very different supply and demand structures.
High volatility can cause quick break-and-fail behavior around zones.
No rule-based script can fully account for news, liquidity shocks, or sudden market structure changes.
🧠 Market Context Notes
Supply-demand flips are a form of role reversal.
Old resistance can become new support after acceptance. Old support can become new resistance after acceptance.
The script is strongest when used with broader market structure, trend context, liquidity, and volatility analysis.
🧾 Use Case Examples
When price breaks above a supply zone, returns to the zone, and holds above it with clean reaction quality, the script may mark a Demand Flip acceptance.
When price breaks below a demand zone, retests it from below, and rejects cleanly, the script may mark a Supply Flip acceptance.
🧱 System Philosophy
Supply Demand Flip Planner follows the AG Pro Series approach: transform a common market concept into a structured decision map with context, score, risk reference, and clean visuals.
The goal is not to replace judgment. The goal is to make role-change analysis easier to read.
🔐 Non-Promise Statement
No script can provide certainty.
No signal should be treated as guaranteed.
Outputs should always be interpreted with independent analysis and responsible risk control.
📉 Risk Disclosure
Trading involves risk.
Market conditions can change quickly.
Users are responsible for their own decisions, risk management, and trade execution.
This script is for educational and analytical purposes only and does not provide financial advice.
📚 Educational Note
This script is designed to help traders study how supply zones, demand zones, breakout retests, and role-change acceptance behave across different market conditions.
Notas de Lançamento
UPDATE NOTES - V1.1This update focuses on visual clarity, premium chart presentation, and improved first-glance interpretation.
The core purpose of the script remains unchanged.
This release improves how the existing supply/demand flip logic is presented, organized, and interpreted on the chart.
This script continues to function as an analytical and visualization tool.
It does not attempt to predict price direction or provide guaranteed outcomes.
------------------------
What Changed
------------------------
• Added centered source-zone text
Supply and demand source zones can now display clearer centered context text, making it easier to understand which side of the market is being monitored for a potential role change.
• Added user-adjustable supply and demand zone colors
Based on community feedback, users can now customize the color of source supply and demand zone boxes for better visibility across different chart themes.
• Added active flip color mode
The active flip zone can follow automatic directional colors or use custom bullish and bearish flip colors.
• Improved active flip-zone presentation
The active flip zone now has stronger borders, cleaner fill control, and more informative centered text.
• Added invalidation shelf text
The invalidation shelf can now display a centered label, improving risk-context visibility without changing the underlying logic.
• Improved target rail visibility
Target rails use stronger line weight and clearer color hierarchy for better screenshot readability.
• Added panel context rows
The panel can now show active zone range and target reference values in addition to flip state, acceptance, retest, failure risk, and action.
• Added right-side tag spacing control
Right-side tags can be shifted farther into the future to reduce overlap with candles and active zone elements.
------------------------
Visual Improvements
------------------------
• Improved chart readability by adding centered text to source zones and invalidation shelves
• Refined zone borders and transparency controls for a more premium appearance
• Strengthened visual hierarchy between source zones, active flip zones, target rails, and invalidation shelves
• Improved right-side tag positioning to reduce overlap with candles and zone edges
• Enhanced panel information density without changing the core analytical engine
------------------------
Interface & Usability
------------------------
• Added visual controls for source-zone text, invalidation text, zone transparency, zone border width, and right-tag offset
• Added color controls for supply zones, demand zones, bullish flip zones, and bearish flip zones
• Added optional panel context rows for active zone and targets
• Kept panel header format unchanged: one merged blue header row with the script name
• Preserved existing label and panel font-size controls
------------------------
Behavior Notes
------------------------
This update does not change the core analytical logic of the script.
Flip detection, retest evaluation, acceptance scoring, invalidation logic, target rail calculation, and alerts remain based on the existing V1.0 engine.
The goal is to improve clarity and usability, not to introduce new predictive behavior.
Users should interpret outputs the same way as before, but with improved visual structure.
------------------------
Limitations Reminder
------------------------
The script remains a rule-based analytical tool.
Market conditions such as volatility, liquidity, trend strength, and timeframe differences may affect how zones, retests, and acceptance states appear.
Outputs should always be interpreted within broader market context.
------------------------
Risk Reminder
------------------------
This script is for educational and analytical purposes only.
It does not provide financial advice, guaranteed trading outcomes, automated trade instructions, or price predictions.
Users remain responsible for their own decisions.
Notas de Lançamento
UPDATE NOTES - v1.2This update focuses on label readability and a cleaner, more premium chart.
The core purpose of the script remains unchanged. The supply/demand zone
detection, the role-change flip logic, the 0-100 acceptance score, targets and
invalidation all behave exactly as before. This release only changes how those
outputs are presented. It continues to function as an analytical and
visualization tool and does not attempt to predict price direction or provide
guaranteed outcomes.
------------------------
What Changed
------------------------
* Zone labels are now solid badges in the zone color.
Supply Source, Demand Source and the active flip label are drawn as filled,
centered badges in their zone color instead of plain text. Filled badges stay
readable on light chart themes, where plain white text could disappear.
* One clean label per resolved flip cycle.
When a flip cycle reaches READY, the earlier "Retest watch" and "Acceptance
watch" labels for that same cycle are removed, leaving a single READY badge.
Unresolved or in-progress cycles still show their watch labels for context.
* Anti-collision label staggering.
Event labels that land close together now step progressively away from the
candles so clustered events stay readable instead of overlapping.
* Cleaner right side.
The separate flip top / mid / bottom price tags were removed (the exact zone
range is already in the panel). The T1 and T2 target tags were moved to the
right end of their rails, so they no longer overlap the zone badges.
------------------------
Visual Improvements
------------------------
* Improved chart readability by separating overlapping event labels and by
reducing dense flip-cycle clusters to a single resolution badge.
* Zone labels remain visible on both dark and light chart themes thanks to the
filled, zone-colored badge style.
* Refined visual hierarchy so the active flip zone, its badge, and the targets
each occupy their own space without competing.
* Adjusted target tag placement to the rail end to avoid overlap with zones and
source badges.
------------------------
Interface & Usability
------------------------
* The invalidation shelf text is now off by default to keep the active zone
area clean; the colored risk shelf still draws and the text can be re-enabled.
* Removed an unused tag-offset setting and refined related tooltips.
* All core inputs, scoring, alerts and defaults for the engine are preserved.
------------------------
Behavior Notes
------------------------
This update does not change the core analytical logic of the script. Zone
detection, flip acceptance scoring, targets and invalidation are unchanged.
Only the presentation of those outputs was refined. Users should interpret
outputs the same way as before, now with clearer visual structure.
------------------------
Limitations Reminder
------------------------
The script remains a rule-based analytical tool. Market conditions such as
volatility, liquidity, strong trends and timeframe differences may affect how
zones, flips, retests and targets appear. Pivot-based zones confirm after the
pivot lookback, so labels appear after confirmation rather than in real time.
------------------------
Risk Reminder
------------------------
This script is for educational and analytical purposes only. It does not
provide financial advice or guaranteed trading outcomes. Users remain
responsible for their own decisions.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Public-free scripts + invite-only AGPro workflows for market analysis, liquidity context, risk planning and execution review.
Rules-based. No hype. No guesswork.
Library & access: agprolabs.com/
Telegram: t.me/agprolabs
Rules-based. No hype. No guesswork.
Library & access: agprolabs.com/
Telegram: t.me/agprolabs
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Public-free scripts + invite-only AGPro workflows for market analysis, liquidity context, risk planning and execution review.
Rules-based. No hype. No guesswork.
Library & access: agprolabs.com/
Telegram: t.me/agprolabs
Rules-based. No hype. No guesswork.
Library & access: agprolabs.com/
Telegram: t.me/agprolabs
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.