AG Pro Auto Supply & Demand Zones [AGPro Series]AG Pro Auto Supply & Demand Zones
Overview / What it does
AG Pro Auto Supply & Demand Zones is an overlay that automatically detects supply and demand areas by combining compact base structures with directional displacement. The script is designed to help traders track where price left an area with enough urgency to justify keeping that zone on the chart for future reference, while also showing how that zone evolves over time.
Instead of plotting every possible reaction area, the script applies a structured lifecycle model. A newly created zone begins as Fresh, can transition to Tested after a qualifying retest, and can later become Expired when it no longer meets the active criteria selected by the user. This state-based approach makes the chart easier to interpret because zones are not treated as static drawings. They are continuously re-evaluated as price interacts with them.
The script also distinguishes between proximal and distal boundaries so users can see both the near edge and the full depth of each zone. A built-in active-zone limit helps keep the chart under control, and older zones gradually fade through time-based opacity reduction. This allows recent and decision-relevant areas to remain visually stronger while historical context becomes lighter.
A light higher-timeframe overlay is included for users who want broader context without turning the chart into a dense multi-timeframe map. The goal is not to overwhelm the screen with background structure, but to add a subtle layer of alignment when higher-timeframe supply or demand remains relevant to the current price area.
Unique Edge
The distinctive feature of this script is that it does not stop at zone creation. It manages the full visual and logical lifecycle of a zone. Fresh, Tested, and Expired states are tracked in an explicit way, which makes the output more practical than a simple box-drawing tool.
A second differentiator is the same-side merge logic. When a newly detected zone forms too close to an existing zone on the same side, the script can refresh or merge that area instead of stacking nearly identical layers on top of one another. This helps reduce redundancy and produces a cleaner, more readable structure map.
Another important edge is the visibility architecture. Users can choose between All, Balanced Focus, and Smart Focus modes. This allows the chart to stay informative without becoming overloaded. Nearest active zones can be emphasized, distant context can be softened, and labels can be kept minimal, balanced, or fully expanded depending on the preferred workflow.
Methodology
The script uses a base-plus-displacement framework.
1. Base detection
A candidate zone begins with a compact base cluster. The script evaluates the total base range relative to ATR and can also apply a clean-wick filter so that noisy or overly volatile bases are filtered out.
2. Displacement confirmation
After the base, the script looks for directional expansion. The displacement candle must satisfy body-size conditions relative to ATR and must close with sufficient directional conviction. This is intended to avoid weak breaks that do not clearly separate from the base.
3. Zone construction
For demand zones, the script builds the area using the base body high as the proximal reference and the base low as the distal boundary. For supply zones, it uses the base body low as the proximal reference and the base high as the distal boundary. This gives the user both the near decision line and the full zone range.
4. Lifecycle tracking
A zone is initially Fresh. Once price revisits it under the selected confirmation mode, it can become Tested. If retests exceed the permitted limit, or if the user enables distal close-break invalidation, the zone can transition to Expired.
5. Zone maintenance
The script can merge overlapping same-side zones, cap the total number of active zones, reduce opacity as zones age, and selectively hide distant context based on the selected visibility profile.
6. Light higher-timeframe context
When enabled, the script projects a restrained higher-timeframe supply and demand layer onto the current chart. This is intended as context, not as a replacement for the active zones detected on the chart timeframe.
Signals & Alerts
This script includes alert support for key state events:
- New Demand Zone
- New Supply Zone
- Fresh Demand Touched
- Fresh Supply Touched
- Demand Zone Expired
- Supply Zone Expired
These alerts are designed to follow the script's zone-state logic rather than subjective interpretation. Users can enable or disable zone-creation alerts, fresh-touch alerts, and expiration alerts independently.
Key Inputs
Detection
Base Bars controls how many candles are used to form the base.
Base Range ATR Factor defines how compact the base must remain relative to ATR.
Max Single Base Candle ATR Factor limits oversized candles inside the base.
Displacement Body ATR Factor controls the minimum strength required for displacement.
Displacement Close Location checks whether the displacement candle closes with directional commitment.
Use Clean Base Wick Filter helps reduce noisy base formations.
Zone Management
Merge Nearby Same-Side Zones helps avoid repeated stacking of almost identical zones.
Minimum Same-Side Separation ATR defines how close a new zone can be to an existing same-side zone before merge logic becomes relevant.
Minimum Zone Overlap Ratio requires stronger overlap before two nearby zones are treated as one structure.
Lifecycle
Max Active Zones limits how many active zones remain on the chart.
Max Tests Before Expire controls how many qualified retests a zone can absorb before it expires.
Test Confirmation offers Touch, Penetration, and Close Inside modes.
Min Test Penetration Ratio refines how deep price must move into a zone when Penetration mode is selected.
Expire On Distal Close Break can invalidate a zone when price closes beyond the distal boundary.
Visuals
Show Proximal Line and Show Distal Line let users control boundary visibility.
Zone Visibility allows All, Balanced Focus, or Smart Focus workflows.
Keep Nearest Active Zones Per Side helps preserve immediate context.
Highlight Nearest Zones strengthens the most decision-relevant zones.
Label Mode, Label Size, Label Right Offset Bars, and Label Spacing ATR control how zone labels are displayed.
Light MTF View
Enable Light MTF View activates higher-timeframe context.
MTF Timeframe selects the higher timeframe.
MTF Fill Transparency and MTF Context Bars help keep the overlay subtle.
Panel
The summary panel can be shown or hidden.
Panel Theme, Panel Location, and Panel Font Size allow adaptation to different chart layouts and visual preferences.
How to use it
Many users will treat this script as a context and reaction map rather than as a standalone entry model.
A common workflow is:
- identify the nearest active demand and supply zones,
- check whether the zone is Fresh or already Tested,
- observe whether current price is approaching the proximal boundary or already trading deeper inside the zone,
- use the light higher-timeframe layer for context,
- then combine the zone information with personal confirmation tools such as structure, momentum, candle behavior, or risk rules.
Fresh zones may be more interesting when they align with trend context or with a relevant higher-timeframe area. Tested zones can still matter, but their interpretation should usually be more selective because the zone has already been revisited.
Limitations & Transparency
This script detects supply and demand zones through a rules-based base and displacement model. It does not claim to identify every meaningful reaction area on a chart, and it does not attempt to label institutional intent, order flow, or smart-money behavior as a certainty.
The quality of a zone depends on the selected settings, the volatility profile of the market, and the timeframe being analyzed. A more permissive configuration will naturally surface more zones, while a stricter configuration will produce a cleaner but narrower map. No single setting profile is optimal for every instrument.
The higher-timeframe overlay is intentionally lightweight. It is designed to provide context, not to replace full top-down analysis. Likewise, a Fresh or Tested label should not be treated as a guarantee of reaction. It is simply the script's state classification based on the selected confirmation logic.
This tool is best understood as a structured charting aid. It helps organize zone detection, lifecycle tracking, and visual prioritization. It does not remove the need for trade selection, confirmation, execution discipline, or risk management.
Risk Disclosure
This indicator is for chart analysis and educational use only. It does not provide financial advice, investment recommendations, or guaranteed outcomes. Markets can move through supply and demand zones without reacting, can partially react and fail, or can produce false confirmations. Always test settings carefully, evaluate the script in the context of your own process, and use proper risk management before making trading decisions.
Pine Script® indicator






















