OPEN-SOURCE SCRIPT

Delta Ladder Order Flow [UAlgo]

12 230
Delta Ladder Order Flow is an overlay order flow visualizer that builds a per bar delta ladder using lower timeframe candles as an intrabar proxy. For each recent bar, the script pulls the underlying lower timeframe open, high, low, close, and volume arrays, then distributes volume into discrete price buckets. Each bucket accumulates estimated buy volume and sell volume, producing a ladder that resembles a footprint style view.

The display focuses on three core outputs:

A delta heatmap ladder where each price level is colored by net delta dominance
A Point of Control highlight that marks the highest total volume level inside the bar
A stacked imbalance detector that scans diagonally across levels to identify aggressive one sided participation and optionally projects that stack forward

The system is designed with stability controls for real world chart conditions. It includes dynamic scaling to prevent excessive level counts on high range bars, object budgeting through bars to draw limits, and text filtering to reduce clutter.

🔹 Features

1) Intrabar Resolution via Lower Timeframe Data
The ladder is constructed using request.security_lower_tf. You select an Intrabar Resolution timeframe that must be lower than the chart timeframe. The script then receives arrays of LTF candles for each chart bar and uses them as a proxy for footprint style aggregation.

This approach provides a practical order flow approximation on TradingView charts without requiring native tick level data.

2) Ladder Aggregation with Tick Size Multiplier
Price levels are aggregated using the symbol mintick multiplied by a user multiplier. Increasing the multiplier produces thicker ladder steps and fewer levels. Decreasing it produces finer granularity but increases the number of boxes drawn.

This control is critical for balancing detail versus performance across different symbols and volatility regimes.

3) Dynamic Scaling to Prevent High Range Bar Overload
A single volatile bar can contain too many price steps if the granularity is too fine. To prevent crashes, the script estimates how many steps would be required for the bar and increases the effective step size when the raw step count exceeds Max Levels per Bar.

This keeps rendering stable even during high volatility events while still maintaining a consistent ladder representation.

4) Buy, Sell, and Neutral Volume Attribution
Each LTF candle’s direction is inferred from its open and close:

Close above open is treated as buy side volume
Close below open is treated as sell side volume
Close equal open is treated as neutral and split evenly between buy and sell

Volume is then distributed across the price buckets covered by the LTF candle range so that wide candles spread their influence across multiple levels.

5) Delta Heatmap Ladder with Intensity Scaling
Each price bucket computes delta as buy volume minus sell volume and total volume as the sum of both. Ladder cells are colored positive or negative based on delta sign, and transparency is scaled by how dominant the delta is relative to the maximum total volume level inside that bar. This yields a compact heatmap where strong imbalances visually stand out.

A square root curve is applied to intensity to improve mid tone visibility without making everything fully opaque.

6) Point of Control Highlight
The ladder tracks the price level with the highest total volume and marks it as the Point of Control. When enabled, the POC row uses a dedicated border color and a stronger border width so the acceptance anchor is immediately visible.

7) Stacked Imbalance Detection and Projection
The script can detect stacked diagonal imbalances. It compares volume across adjacent price levels using a diagonal logic similar to footprint tools:

Bullish diagonal checks buy volume at a level versus sell volume at the level below
Bearish diagonal checks sell volume at a level versus buy volume at the level above

An imbalance requires the winning side to exceed the losing side by the configured Imbalance Ratio and also exceed a minimum volume threshold to filter low volume noise. When consecutive imbalanced levels reach the Stacked Levels count, the stack is marked and optionally extended forward as a zone.

Stack members also override normal heatmap coloring and are rendered more solid for emphasis.

8) Clean Visual Controls
Several options support readability:

Bars to Draw limits workload and object count
Show Delta Values can be toggled on or off
Min Delta to Show Text filters small prints
Ladder Width percent controls how wide the ladder is relative to the bar space
Text size can be adjusted for different chart zoom levels
Box outline can be hidden by default for a cleaner footprint aesthetic

🔹 Calculations

1) Intrabar data acquisition (lower timeframe arrays)
The script requests arrays of LTF OHLCV values for each chart bar using request.security_lower_tf.

Pine Script®


These arrays contain the lower timeframe candles that make up each chart bar. Each chart bar index has its own embedded array.

2) Base tick step (bucket size control)
Bucket size starts from mintick multiplied by Tick Size Multiplier.

Pine Script®


This is the baseline price increment used to build the ladder levels.

3) Last bar execution model (performance design)
The script only builds and draws ladders when barstate.islast is true. It then reconstructs the last N bars using an index offset.

Pine Script®


This design dramatically reduces CPU and memory load compared to updating every bar.

4) Dynamic scaling per bar (anti crash protection)
For each bar, the script estimates how many price steps would be needed using the current bucket size. If that count exceeds Max Levels per Bar, it increases the step size only for that bar.

Pine Script®


Result:

Calm bars use fine granularity
High range bars are automatically compressed into fewer buckets

5) LTF candle direction classification (buy, sell, neutral)
Each LTF candle is classified using its open and close. Neutral candles split volume evenly.

Pine Script®


This is a heuristic proxy for aggressor side. It is not true bid ask data.

6) Align LTF candle range to bucket grid
The candle low and high are rounded to the current tick step so bucket prices align cleanly.

Pine Script®


7) Step counting and volume per step
The script computes how many bucket levels the candle touches and divides volume equally across them.

Pine Script®


This means wide candles distribute volume across more ladder cells, while tight candles concentrate volume into fewer cells.

8) Writing volume into the ladder map (PriceLevel storage)
Each chart bar owns a DeltaLadder with a map of price to PriceLevel. Each PriceLevel stores buy and sell volume. Volume is added step by step.

Pine Script®


The add method updates volumes and also tracks max volume and POC:

Pine Script®


The main loop calls this method for each bucket level touched by each LTF candle:

Pine Script®


9) Delta and total volume formulas
Delta and total are defined as methods on PriceLevel.

Pine Script®


These values drive both coloring and POC selection.

10) Stacked imbalance detection (diagonal footprint logic)
Prices are sorted so neighbor comparisons are correct. A stack_map stores whether each price belongs to a bullish or bearish stacked run.

Pine Script®


Diagonal comparisons:

Bullish diagonal compares BuyVol at level i with SellVol at level below i minus 1
Bearish diagonal compares SellVol at level i with BuyVol at level above i plus 1

Bullish check includes a zero handling rule:

Pine Script®


Bearish check includes symmetric logic:

Pine Script®


Runs are tracked and only accepted if the number of consecutive levels meets the stacked requirement:

Pine Script®


The script also draws a projected zone for the detected stack band:

Pine Script®


11) Heatmap intensity and transparency mapping
For each price level, intensity is computed as abs(delta) relative to the maximum total volume level in the bar, then curved and mapped into transparency.

Pine Script®


Stacked members force stronger visibility:

Pine Script®


12) POC marking in the drawing pass
POC is detected during volume accumulation, then used in rendering to upgrade the border style for that cell.

Pine Script®


13) Delta text rendering filter
Text labels are optional and can be filtered by a minimum absolute delta threshold.

Pine Script®

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.