OPEN-SOURCE SCRIPT
Auto Dynamic S/R Zones Pro [identityKa]

Overview
The Auto Dynamic S/R Zones Pro [identityKa] is a structural Price Action utility that automatically identifies, draws, and manages Supply (Resistance) and Demand (Support) liquidity zones. Unlike traditional pivot indicators that draw single horizontal lines, this script constructs volumetric "boxes" to represent areas of historical institutional interest. Furthermore, it incorporates a Smart Mitigation Engine that automatically cleans the chart by deleting zones once they have been functionally broken or fully mitigated by price action.
Core Zone Calculation Methodology
The script utilizes historical pivot detection (ta.pivothigh and ta.pivotlow) based on a user-defined lookback/lookforward sensitivity. Once a structural extreme is found, the engine calculates the boundaries of the zone to capture the entire rejection area rather than just the wick tip:
Resistance Zones (Supply): The top of the box is anchored to the absolute high of the pivot candle. The bottom of the box is calculated using the maximum value between the open and close of that same candle (capturing the wick-to-body spread).
Support Zones (Demand): The bottom of the box is anchored to the absolute low of the pivot candle. The top of the box is calculated using the minimum value between the open and close (capturing the lower wick-to-body spread).
The Smart Mitigation Engine (Chart Cleanup)
To prevent chart clutter and outdated data, the script utilizes dynamic arrays to manage the drawn boxes.
The script continuously monitors the closing price relative to all active zones.
If a candlestick closes strictly above the upper boundary of a Resistance box, or strictly below the lower boundary of a Support box, the zone is mathematically considered "Mitigated" (broken).
Upon mitigation, the script instantly deletes the box and its associated label from the chart history, firing a breakout alert and leaving only fresh, untested zones visible.
HUD Dashboard & AI Logic
The integrated on-chart panel evaluates the immediate relationship between the current price and the active S/R arrays:
Dangerous: Triggered whenever the current closing price is actively printing inside the coordinates of any active Support or Resistance box. This indicates price is in a high-friction decision zone where rejections are highly probable.
LONG / SHORT: The engine tracks the most recent structural breakout. If the last mitigated zone was a Resistance, it adopts a "LONG" bias indicating bullish structure. If the last mitigated zone was a Support, it adopts a "SHORT" bias indicating bearish structure, provided the price is not currently stuck inside another zone.
How to Use It
This indicator simplifies top-down analysis. Traders can use a higher timeframe (e.g., 1H or 4H) to let the script automatically map out major untested supply and demand zones. When the price enters an active zone (triggering the "Dangerous" AI state), traders can drop to a lower timeframe to look for reversal patterns. Alternatively, traders can trade the momentum of the breakouts by setting alerts for when a zone is officially broken/mitigated.
The Auto Dynamic S/R Zones Pro [identityKa] is a structural Price Action utility that automatically identifies, draws, and manages Supply (Resistance) and Demand (Support) liquidity zones. Unlike traditional pivot indicators that draw single horizontal lines, this script constructs volumetric "boxes" to represent areas of historical institutional interest. Furthermore, it incorporates a Smart Mitigation Engine that automatically cleans the chart by deleting zones once they have been functionally broken or fully mitigated by price action.
Core Zone Calculation Methodology
The script utilizes historical pivot detection (ta.pivothigh and ta.pivotlow) based on a user-defined lookback/lookforward sensitivity. Once a structural extreme is found, the engine calculates the boundaries of the zone to capture the entire rejection area rather than just the wick tip:
Resistance Zones (Supply): The top of the box is anchored to the absolute high of the pivot candle. The bottom of the box is calculated using the maximum value between the open and close of that same candle (capturing the wick-to-body spread).
Support Zones (Demand): The bottom of the box is anchored to the absolute low of the pivot candle. The top of the box is calculated using the minimum value between the open and close (capturing the lower wick-to-body spread).
The Smart Mitigation Engine (Chart Cleanup)
To prevent chart clutter and outdated data, the script utilizes dynamic arrays to manage the drawn boxes.
The script continuously monitors the closing price relative to all active zones.
If a candlestick closes strictly above the upper boundary of a Resistance box, or strictly below the lower boundary of a Support box, the zone is mathematically considered "Mitigated" (broken).
Upon mitigation, the script instantly deletes the box and its associated label from the chart history, firing a breakout alert and leaving only fresh, untested zones visible.
HUD Dashboard & AI Logic
The integrated on-chart panel evaluates the immediate relationship between the current price and the active S/R arrays:
Dangerous: Triggered whenever the current closing price is actively printing inside the coordinates of any active Support or Resistance box. This indicates price is in a high-friction decision zone where rejections are highly probable.
LONG / SHORT: The engine tracks the most recent structural breakout. If the last mitigated zone was a Resistance, it adopts a "LONG" bias indicating bullish structure. If the last mitigated zone was a Support, it adopts a "SHORT" bias indicating bearish structure, provided the price is not currently stuck inside another zone.
How to Use It
This indicator simplifies top-down analysis. Traders can use a higher timeframe (e.g., 1H or 4H) to let the script automatically map out major untested supply and demand zones. When the price enters an active zone (triggering the "Dangerous" AI state), traders can drop to a lower timeframe to look for reversal patterns. Alternatively, traders can trade the momentum of the breakouts by setting alerts for when a zone is officially broken/mitigated.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。