OPEN-SOURCE SCRIPT

IPDA Data Ranges - 20 40 60

318
1. Daily Lookback Ranges
At the core of the IPDA theory, institutions look back over specific windows of time (usually 20, 40, and 60 days) to identify "Old Highs" and "Old Lows", which act as liquidity pools.

The script automatically calculates the highest high and lowest low of the last 20, 40, and 50 days (customizable in settings).
It uses a special function (request.security with the "D" resolution) to strictly pull this data from the Daily timeframe. This means even if you drop down to a 5-minute or 1-hour chart, the boxes will always accurately represent the daily ranges, rather than just 20 or 40 "intraday candles."

2. Box Visualization
Instead of cluttering your chart with lines, the script draws three overlapping transparent rectangle boxes representing these dealing ranges.

The X-axis (Time): The left side of each box starts at the exact opening time of the day the lookback period began, and the right side extends to the current live candle.
The Y-axis (Price): The top of the box rests exactly on the highest price within that window, and the bottom rests on the lowest price.

3. Dynamic Rendering & Performance
To keep TradingView running smoothly and prevent memory bloat, the script uses a barstate.islast check.

Rather than drawing hundreds of historical boxes over past price action, the script only draws three dynamic boxes on your chart.
On every new live tick, it simply updates the borders and boundaries of these 3 existing boxes in real-time, anchoring them perfectly to the right side of the chart.

4. Customization Engine
You have full control over the script’s display through the settings:

Lookback Periods: You can change the 20/40/50 day windows to any number of days.
Labels: You can customize the text labels (e.g., typing "Short Term IPDA" instead of "20 Day IPDA").

Text Alignment: You can use dropdown menus to snap the labels to any corner or center of the box (Left, Center, Right, Top, Bottom) so they don't cover your candles.
Aesthetics: You can tweak the background fill color and the solid border color for each box to match your chart theme.

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.