OPEN-SOURCE SCRIPT

Volume Delta with Fibonacci Projection [UAlgo]

24 236
Volume Delta Profile with Fibonacci Projection is a structure driven profiling tool that combines swing discovery, lower timeframe volume allocation, delta analysis, Fibonacci mapping, and forward target projection inside a single chart overlay. Its purpose is not only to show where price has moved, but also to show how participation was distributed inside that move and where the next projected objective levels may sit.

The script begins by identifying a dominant recent swing inside a user defined lookback window. Once that swing is found, it becomes the structural anchor for everything else in the indicator. The swing defines the full high to low range, the Fibonacci ladder, the profile segmentation, the delta bands, and the forward projection path. This creates a unified framework where all visual components are tied to the same market structure instead of being calculated independently.

A key part of the script is its lower timeframe profiling engine. It requests intrabar data from a lower timeframe and uses that data to distribute volume into price rows and Fibonacci bands inside the active swing. This allows the indicator to estimate where buying activity and selling activity were concentrated with far more detail than a simple bar based approximation. If lower timeframe data is unavailable for a given bar, the script falls back to the chart bar itself so the profile can still be built.

The profile section shows how total activity was distributed across the swing range, while the delta section shows which Fibonacci bands leaned more bullish or bearish in terms of estimated participation. A Point of Control line can also be drawn to highlight the most active profile row. In addition, the script projects a continuation path from a chosen Fibonacci level toward target extensions such as 100 percent, 127.2 percent, and 161.8 percent of the swing.

The result is a tool that can be used for structure analysis, premium and discount mapping, participation study, and projection planning. It is especially useful for traders who want to combine profile logic and Fibonacci logic inside the same structural framework rather than treating them as separate tools.

🔹 Features

🔸 Structure Based Swing Detection
The script automatically finds a recent dominant swing inside the selected lookback period and requires a minimum separation between the major high and low. This gives the indicator a clean structural base before any profile or projection is drawn.

🔸 Auto Lower Timeframe Intrabar Analysis
The indicator can automatically choose a lower timeframe for intrabar volume analysis based on the current chart timeframe. A custom intrabar timeframe can also be used if desired.

🔸 Volume Profile Across the Swing Range
The full swing range is divided into profile rows, and lower timeframe volume is distributed into those rows according to price overlap. This builds a true participation map across the swing rather than a simple one point volume assignment.

🔸 Delta by Fibonacci Band
In addition to row based profiling, the script also groups volume into six Fibonacci bands between the swing extremes. Each band receives estimated buy and sell volume, and the script calculates directional delta for each band.

🔸 Fib POC Highlighting
A Point of Control line can be displayed at the profile row with the highest total accumulated volume, giving the user a quick view of the strongest participation level inside the swing.

🔸 Flexible Row Sizing
Profile row size can be determined automatically from ATR and tick size, or it can be defined manually through ticks per row. This makes the profile adaptable to very different instruments.

🔸 Forward Projection Path
The script draws a projection path starting from a selected retracement level and extends it toward major target levels such as 100 percent, 127.2 percent, and 161.8 percent of the swing range.

🔸 Optional Target Boxes
Target zones can be shown as compact boxes around the projected objective levels, helping the user visualize likely reaction areas rather than only exact lines.

🔸 Bull and Bear Participation Coloring
The profile and delta display use directional coloring to separate estimated buying volume from estimated selling volume. This makes the participation structure much easier to read visually.

🔸 Complete Structural Integration
The swing line, Fibonacci levels, volume profile, delta profile, Point of Control, and projection targets all come from the same underlying swing. This keeps the whole tool internally consistent.

🔹 Calculations

1) Defining the Swing Object

Pine Script®


This object stores the full structural context of the move being analyzed.

It contains:
where the swing starts,
where it ends,
the starting price,
the ending price,
the full low and high of the move,
the total range,
the direction,
and the bar offsets used for the profiling loop.

This is important because the script does not calculate the profile on an arbitrary fixed range. It first defines a real market swing and then builds all later logic from that anchor.

2) Choosing the Lower Timeframe Automatically

Pine Script®


This function selects a lower timeframe automatically according to the current chart timeframe.

Very fast charts use one second data.
Intraday charts use one minute data.
Daily charts use five minute data.
Higher charts default to sixty minute data.

The goal is to obtain more granular intrabar structure without forcing the user to choose a lower timeframe manually every time.

3) Computing Automatic Row Size

Pine Script®


When row size mode is set to Auto, the script derives the profile row size from ATR and tick size.

It takes twenty percent of ATR, converts that value into ticks, then enforces a minimum of one tick.

This creates a profile row height that adapts to the instrument’s current volatility instead of staying fixed across very different market conditions.

4) Finding the Major Swing

Pine Script®


Pine Script®


Pine Script®


This function discovers the dominant swing inside the selected lookback.

First, it locates the highest bar and lowest bar inside the lookback window. Then it determines which came first in time. If the low occurred earlier and the high occurred later, the swing is bullish. If the high occurred earlier and the low occurred later, the swing is bearish.

The function also forces a minimum separation between the swing endpoints. If the raw highest and lowest points are too close together, it searches farther out to build a more meaningful move.

So the swing used by the indicator is not just the highest high and lowest low. It is a structurally filtered move with time separation and direction.

5) Fibonacci Price Calculation

Pine Script®


This method converts a Fibonacci ratio into an actual price inside the current swing.

For bullish swings, ratios are measured downward from the swing high.
For bearish swings, ratios are measured upward from the swing low.

So the Fibonacci ladder always respects swing direction and preserves the standard premium and discount interpretation.

6) Defining the Six Internal Fibonacci Bands

Pine Script®


These ratio slots define the six profiling bands used in the delta section.

The bands span the space between:
1.000 and 0.786
0.786 and 0.618
0.618 and 0.500
0.500 and 0.382
0.382 and 0.236
0.236 and 0.000

The order is reversed automatically for bearish swings so the structure remains directionally consistent.

So the delta section is not arbitrary. It measures directional participation inside familiar Fibonacci zones.

7) Mapping Prices Into Profile Rows

Pine Script®


This helper function converts any price into its corresponding profile row.

The price is first clamped inside the swing boundaries. Then the script measures how far above the swing low the price sits and divides that by the row step size.

This gives the row index where the price belongs. That mapping is necessary for distributing intrabar volume into the correct profile level.

8) Mapping Prices Into Fibonacci Bands

Pine Script®


This function assigns a price to one of the six Fibonacci bands.

It walks through the band boundaries one by one, checks where the price sits, and returns the matching band index.

That index is later used when a bar or an intrabar has zero height or when band overlap needs to be accumulated. So this function is the bridge between raw prices and the delta profile zones.

9) Lower Timeframe Data Request

Pine Script®


This is the intrabar engine.

The script first decides whether to use the automatic lower timeframe or the custom user defined one. Then it requests arrays of lower timeframe open, high, low, close, and volume values for each chart bar.

This means every bar inside the swing can be broken down into smaller internal bars, allowing a more detailed volume allocation than a single chart timeframe candle would allow.

10) Determining Effective Profile Row Size

Pine Script®


This block finalizes the profile geometry.

It first determines the tick size per row, either from the automatic ATR based logic or from the manual input. Then it ensures the row step is not smaller than that minimum. After that, it calculates how many rows are actually needed to cover the full swing range.

Finally, it recalculates the row height so the entire swing fits perfectly into the effective row count.

So the profile is always both instrument aware and range aligned.

11) Estimating Intrabar Direction

Pine Script®


This block decides whether a lower timeframe bar should be treated as bullish or bearish for volume allocation.

If close is above open, the bar is treated as buying.
If close is below open, the bar is treated as selling.
If the bar is neutral, the script falls back to its relation versus the previous close. If that is also neutral, it inherits the previous direction.

This gives the script a practical directional model for classifying intrabar volume into buy side or sell side participation.

12) Distributing Intrabar Volume Into Profile Rows

Pine Script®


This is one of the most important calculations in the script.

For every lower timeframe bar, the script checks how much of that bar overlaps each profile row. If overlap exists, volume is distributed proportionally according to the fraction of the bar’s range that passed through that row.

So if an intrabar spends more range inside a certain row, more of its volume is assigned there.

This is much more realistic than placing the full volume into a single price row because it respects the bar’s actual vertical path through price.

13) Distributing Intrabar Volume Into Fibonacci Bands

Pine Script®


The same overlap logic is then applied to the six Fibonacci bands.

Each intrabar contributes buy volume and sell volume into the band or bands it overlaps. The contribution is proportional to the amount of overlap relative to the bar’s own range.

So the delta section is not built from row totals. It is built directly from participation inside each Fibonacci segment of the swing.

14) Fallback Logic When Lower Timeframe Arrays Are Empty

Pine Script®


If the lower timeframe request returns no intrabar data for a specific chart bar, the script falls back to the bar itself.

It reads the normal chart timeframe OHLCV values, determines a direction using the helper method, and then distributes that bar’s volume into rows and bands using the same overlap logic.

This is important because it makes the indicator robust. The profile can still be constructed even when granular intrabar data is unavailable.

15) Point of Control Calculation

Pine Script®


This block finds the Point of Control.

The script scans every profile row, calculates total row volume as buy plus sell, and keeps track of the highest one. The midpoint of that strongest row becomes the Point of Control price.

So the POC is the single most active price area inside the swing based on the constructed row profile.

16) Building the Horizontal Volume Profile

Pine Script®


Pine Script®


Pine Script®


This is the profile drawing engine.

Each row’s total participation is scaled relative to the strongest row. That determines how wide the full profile bar should be.

Then the script splits that width between sell volume and buy volume according to their relative shares. The selling segment is drawn first, followed by the buying segment.

So each row shows both:
how much total volume was traded there,
and how that volume split between bearish and bullish participation.

17) Delta Calculation by Fibonacci Band

Pine Script®


This block calculates directional delta inside each Fibonacci band.

Delta is simply buy volume minus sell volume.
Delta percent then normalizes that difference by total volume inside the band.

If the result is positive, the band leaned bullish.
If the result is negative, the band leaned bearish.
If the result is near zero, the band was balanced.

So the delta section tells the user not just how much activity occurred in a band, but which side dominated it.

18) Scaling the Delta Bars

Pine Script®


Pine Script®


The script first finds the maximum absolute delta among all bands. Then it uses that value as the scaling reference for the delta boxes.

A band with the strongest absolute delta receives the widest box. Smaller delta bands receive proportionally narrower boxes.

So the delta profile communicates both direction and relative strength across the Fibonacci segments of the swing.

19) Drawing the Core Fibonacci Ladder

Pine Script®


This loop draws the Fibonacci levels across the swing.

Every ratio from zero to one is converted into price using the earlier swing based Fibonacci method. The selected projection base level plus the zero and one boundaries are emphasized, while the other internal levels are drawn more softly.

So the user gets a full retracement map tied directly to the chosen swing.

20) Building the Projection Path and Targets

Pine Script®


Pine Script®


This is the forward projection engine.

The chosen Fibonacci retracement level becomes point C. From that point, the script projects three forward targets based on the swing range:
100 percent,
127.2 percent,
and 161.8 percent.

For bullish swings, the targets are projected upward.
For bearish swings, the targets are projected downward.

The script then connects the swing end to point C and extends the projection path forward through each target.

So the projection section transforms the structural swing into a directional roadmap.

21) Drawing Target Boxes

Pine Script®


Instead of marking the targets as exact single prices only, the script can draw small target boxes around them.

The vertical thickness of each box is based on a fraction of the swing range, with a minimum tick based width. This helps present the targets as realistic reaction zones rather than razor thin levels.

So the projection module provides both precise target labels and visual target areas.

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.