OPEN-SOURCE SCRIPT
Updated

ADX/DI Profile & Volume Footprint

1 191
🔶Overview
This script merges two powerful analytical frameworks—"Algorithmic ADX/DI Price Profile" and "High-Precision Volume Footprint"—into a single chart overlay. By moving Directional Movement data from the time axis (X-axis) to the price axis (Y-axis) and scanning lower timeframe (LTF) tick arrays, it accurately visualizes where trend energy is concentrated and how buyers and sellers interact at discrete price levels. This allows you to objectively verify market structure before committing capital.
🔶System Modules and Execution Flow
  • Volume Footprint Engine: Utilizes request.security_lower_tf() to scan up to 50 historical bars on a lower timeframe (down to 1-second for Premium users) to reconstruct intra-bar order flow. [Execution]: Toggle between "Individual Bars" mode for per-candle footprints, and "Composite (N Bars)" mode to aggregate order flow over a specified range into a single comprehensive structure.
  • ADX/DI Profile Matrix: Computes standard 14-period DMI components, scalable via a Multi-Timeframe (MTF) engine. Generates fixed bounding boxes over historical sessions to project +DI, -DI, and ADX intensity as horizontal histograms. [Execution]: Profiles are visually separated (Left, Right, Center aligned). A real-time heatmap shader shifts from "Cold" to "Hot" based on energy concentration, instantly identifying trend exhaustion or accumulation zones.
  • Local VWAP & Fibonacci Controller: Using the dynamically calculated profile range as an anchor, it draws a local Volume Weighted Average Price (VWAP) and customizable Fibonacci extensions, providing highly logical stop-loss and take-profit targets.
  • Analytical HUD (Default OFF): A fixed 50-column matrix table dynamically tracks Delta, Total Volume, Total Buy, and Total Sell orders, eliminating the need to manually decipher individual numbers inside the boxes.

🔶Configuration and Filtering Options
  • Resolution & Boundaries: Defines profile row counts (10 to 50 tiers; max 40 recommended for perfect stability, though this does not apply to line rendering) and width multipliers. When trading highly volatile assets like crypto or indices, reducing this to 30 thickens the price buckets and improves visibility.
  • Algorithmic Noise Filter: A critical threshold gate (0.0 to 1.0). Price tiers failing to meet this relative intensity ratio are visually muted. Increasing the default 0.08 to 0.15 (15%) mathematically erases low-impact price zones, leaving only institutional-level support/resistance clusters.
  • Volume Weight Toggle: An option to fuse volume data into DMI calculations. Prioritizes directional moves backed by real capital over empty price spikes.
  • Premium Seconds-Timeframe Guard: An automated downgrade protocol to ensure script stability. If a non-Premium plan is detected, it automatically converts 1-second (1S) requests to a 1-minute timeframe to prevent fatal array compilation errors.

🔶Trading Strategy and Practical Applications
  • "Wait & See" Filter (Avoiding Chop): The system's color shader acts as your first gate of discipline. If the ADX profile (center) shows "Cold" colors (e.g., dark orange/amber), it means trend energy is low. Do not trade; remain in a no-position state until the ADX blocks turn "Hot" (bright yellow), confirming massive algorithmic participation.
  • Absorption and Exhaustion Setups: Watch the Footprint engine boxes drawn over the candles closely. If a massive spike of aggressive buying (high positive delta, green text) occurs, yet the candle fails to break out and is immediately capped by a dense -DI profile block (right side, Hot Red), this is "Absorption." Buyers are trapped. Enter short right below this Point of Control (POC) with a tight stop-loss just above the profile box.
  • VWAP / Fibonacci Targeting: Once an entry is validated by Footprint delta, use the dynamically plotted VWAP as a baseline. For longs, target the upper Fibonacci bands (0.618 or 1.000). The beauty of this system is that these bands are derived strictly from the profiled session's "volume", reacting mathematically to the current market environment rather than arbitrary historical swings.

🔶Architecture and Quantitative Logic (Code Breakdown)
This script relies on multiple mathematical matrices to transform time-based indicators into price-based structures.
1. Footprint Volume Distribution (Tick Estimation)




Pine Script®


  • Why this calculation is performed: TradingView cannot provide sub-second Bid/Ask data. To measure aggressive market participation at specific price levels and objectively distinguish local buying absorption from selling pressure, the engine mathematically divides the lower timeframe bar's spread (High - Low) and distributes volume evenly across each tick to synthesize aggressive trading behavior.
  • Actual Output Value: A raw Float representing estimated volume at a single price tick. For example, if a 1-second volume (c_v) is 100 contracts and the spread covers 5 ticks, the output (v_tick) is exactly 20.0 per tick. Absolute volumes are formatted as strings (e.g., "1.5K") for the UI, while net delta is output to the HUD summary table as raw positive/negative floats.

2. DMI Profile Allocation and Normalization




Pine Script®


  • Why this calculation is performed: To pinpoint the exact price nodes where trend strength (ADX) and direction (+DI/-DI) physically occurred, filtering out empty volatility. Standard DMI ignores volume; this script multiplies DI intensity by trading volume (c_vol) and scales it via net_di_ratio to highlight zones where one side completely overwhelmed the other.
  • Actual Output Value: A large integer/float representing the local energy assigned to that price tier. If raw +DI is 30, raw -DI is 10, and volume is 1,000, the net_di_ratio is 20 / 40 = 0.5. The final p_plus output assigned to that tier is 30 * 1000 * 1.5 = 45,000 energy points.

3. Box Scaling and Noise Filter




Pine Script®



  • Why this calculation is performed: To eliminate market noise. max_plus is the Point of Control (POC)—the price tier with the absolute maximum energy. All other tiers are divided by this maximum to output a percentage (0.0 to 1.0). The noise filter (default 0.08, or 8%) culls tiers holding less than 8% of the POC's intensity.
  • Actual Output Value: A Float ratio between 0.0 and 1.0. A tier with 22,500 energy against a POC of 45,000 outputs 0.5. This 0.5 is passed directly to the f_get_heatmap_color function, outputting an RGBA hex color code that dynamically blends "Cold" and "Hot" variables based on intensity.

4. VWAP and Geometric Fibonacci Derivation
  • Why this calculation is performed: To establish a baseline fair value and logical standard deviation bands derived directly from the profiled session's volume distribution.
  • Actual Output Value: Exact absolute price coordinates (Y-axis floats). The Local VWAP is calculated by dividing the sum of (Typical Price * Volume) by Total Volume within the profile window. Fibonacci levels are output as the absolute distance from the VWAP to the session high/low multiplied by standard ratios (0.382, 0.618, 1.000). These are mapped as solid, dashed, or dotted lines across the X-axis bounds of the profile box.

🔶Capabilities and Limitations
  • Capabilities: Synthesizes massive LTF data arrays into clean, readable UI boxes without repainting. Modular layout prevents candlesticks from being obscured.
  • Limitations: TradingView imposes strict limits of 500 boxes, 500 lines, and 500 labels per script. On highly volatile assets with deep tick resolution, maximizing row_count or setting footprint lookbacks to 50 bars may cause older UI elements to clip (disappear) due to platform-level garbage collection constraints.

Release Notes
Update Notes
[ Maximum Optimization of Stability & Processing Performance ]

[Critical] Revamped Memory Release Logic for Drawing Objects
Introduced the safer for...in construct for destroying historical drawing data (Boxes, Lines, Labels). This completely eliminates the risk of "Out of Bounds" errors caused by array index shifts during prolonged chart display or extreme market volatility, significantly enhancing overall operational stability.

Loop Processing Optimization (Drastic CPU Load Reduction)
Reviewed the massive repetitive calculations (loops) required for generating ADX/DI profiles and footprints. Loop-invariant evaluations—such as static layout checks and max-width scaling—have been extracted outside the loops (pre-calculation). This drastically reduces the number of internal calculation steps and provides noticeably faster chart rendering speeds.

Constant UI Definitions
Centralized internal text and UI group names into compile-time constants (const string) at the top of the script, resulting in zero runtime memory overhead and a highly optimized code structure. (Note: The core analytical algorithms and profile calculation results remain completely unchanged.)

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.