HTF Candle Profile [UAlgo]HTF Candle Profile is a higher timeframe candle visualization tool that rebuilds each selected HTF candle from the lower timeframe bars that form it, then projects a horizontal volume profile inside that HTF candle range. The goal is to make intrabar participation visible directly on the price chart, so you can see where volume concentrated within the candle, where it was thin, and where the dominant traded price level emerged.
Instead of treating a daily or four hour candle as a single block, the script aggregates the lower timeframe bars as they arrive and distributes their volume across price bins covering the HTF candle’s high to low range. The result is a compact profile drawn from the start time of the HTF candle toward the right, with width proportional to relative volume per bin and color intensity driven by a gradient. This provides a fast read of internal structure: balanced candles, directional candles, rejection wicks, and consolidation pockets become easier to interpret because you can see the volume distribution inside the candle.
The indicator draws on the main chart and keeps a small rolling history of recent HTF candles to stay responsive and to respect object limits.
🔹 Features
1) Multi Timeframe HTF Candle Reconstruction
The script listens for a new HTF candle event using the selected timeframe input. When a new HTF candle begins, the previous one is finalized and drawn. During the active HTF candle, each incoming lower timeframe bar updates the running OHLC and stores its high, low, and volume for profiling.
This approach enables a live building profile for the current HTF candle while preserving completed profiles for recent candles.
2) Intrabar Volume Profile Built from LTF Data
For each HTF candle, the price range from low to high is divided into a user defined number of bins. Each lower timeframe bar contributes volume into all bins it spans. Volume is distributed evenly across the spanned bins to approximate participation within that bar’s range. This produces a per bin volume distribution that is stable and visually interpretable even when lower timeframe candles have large ranges.
3) Gradient Based Profile Intensity
Each bin is drawn as a horizontal box. Its color comes from a gradient that maps low volume to a softer profile color and high volume to a stronger profile color. This makes it easy to spot high participation nodes and low participation voids within the HTF candle.
Inputs allow independent control for bullish and bearish candle coloring and for the low volume and high volume profile colors.
4) POC Line Option
The script can optionally plot a POC line representing the price level of maximum volume within the HTF candle. This is drawn as a dashed horizontal line that spans the candle’s start time to end time. POC is often used as a reference for acceptance, fair value, or a magnet level during retracements.
5) Candle Body, Wick, and Time Boundaries
To keep the profile anchored and readable, the script also draws:
A translucent body box from HTF open to HTF close
A vertical wick line from HTF high to HTF low
A dotted start boundary and a dotted end boundary for the HTF candle window
These elements provide context so the profile is always interpreted within the candle structure that produced it.
6) Object Management and Rolling History
To keep charts clean and avoid exceeding platform limits, the script maintains a small history of HTF candles and deletes drawings for older ones. Each candle owns its objects and can fully clear them when removed from the rolling window.
🔹 Calculations
1) New HTF Candle Detection
A new candle event is detected using timeframe change on the selected timeframe:
isNew = timeframe.change(tf)
When isNew is true:
The previous HTF candle is finalized by setting its end time and drawing it
A new HTF candle object is created and added to the array
Old candles beyond the history limit are removed and their drawings deleted
2) HTF Candle Aggregation from LTF Bars
Each incoming lower timeframe bar updates the active HTF candle:
method addLtf(HtfCandle this, float h, float l, float c, float v) =>
this.ltfData.push(LtfBar.new(h, l, v))
this.h := math.max(this.h, h)
this.l := math.min(this.l, l)
this.c := c
Interpretation:
High is updated to the maximum seen so far within the HTF candle window
Low is updated to the minimum seen so far
Close is updated to the most recent close
Each LTF bar is stored with its high, low, and volume for later bin distribution
3) Bin Construction Across the HTF Candle Range
When drawing a candle, the script divides the HTF range into binCount segments:
float step = (this.h - this.l) / bCount
for i = 0 to bCount - 1
this.bins.push(ProfileData.new(this.l + i * step, this.l + (i + 1) * step, 0.0, na))
Each bin stores:
minP and maxP boundaries
accumulated volume for that price segment
a box handle for drawing
4) Volume Distribution from Each LTF Bar into Bins
For each stored LTF bar, the script determines which bins the bar spans and distributes volume evenly across them:
int startIdx = int((ltf.l - this.l) / step)
int endIdx = int((ltf.h - this.l) / step)
startIdx := math.max(0, math.min(startIdx, bCount - 1))
endIdx := math.max(0, math.min(endIdx, bCount - 1))
int spanned = endIdx - startIdx + 1
float vPerBin = ltf.v / spanned
for j = startIdx to endIdx
ProfileData b = this.bins.get(j)
b.vol += vPerBin
Interpretation:
The bar range is mapped to bin indexes
Indexes are clamped so they remain inside the array
Volume is divided by the number of spanned bins
Each spanned bin receives an equal share of that bar’s volume
This is a robust approach for intrabar profiling without tick data.
5) POC Computation
The script finds the bin with the maximum accumulated volume and sets the POC price at the midpoint of that bin:
float maxVol = 0.0
float pocP = na
for b in this.bins
if b.vol > maxVol
maxVol := b.vol
pocP := math.avg(b.minP, b.maxP)
If enabled, a dashed POC line is drawn across the HTF candle window:
if sPoc and not na(pocP)
this.lPoc := line.new(x1=this.st, y1=pocP, x2=this.et, y2=pocP, xloc=xloc.bar_time, color=cPoc, style=line.style_dashed, width=2)
6) Profile Box Width Scaling
Each bin’s box width scales by its volume relative to the maximum volume bin. Width is capped as a fraction of the candle’s time duration:
int duration = math.max(this.et - this.st, 1)
int volWidth = int((duration * 0.40) * (b.vol / maxVol))
int boxRight = this.st + volWidth
Interpretation:
duration represents the HTF candle time width
0.40 is the maximum profile width fraction of the candle duration
b.vol / maxVol converts volume to a normalized ratio
boxRight is calculated so all profile boxes start at the candle start time and extend rightward based on volume
7) Gradient Coloring of the Profile
Each bin color is mapped from low volume to high volume using a gradient:
color gradColor = color.from_gradient(b.vol, 0, maxVol, cLow, cHigh)
This keeps low participation zones visually lighter and high participation zones more prominent.
8) Candle Body and Wick Drawing
The script draws an HTF candle body box and a wick line for context:
float topP = math.max(this.o, this.c)
float botP = math.min(this.o, this.c)
this.bBody := box.new(left=this.st, top=topP, right=this.et, bottom=botP, xloc=xloc.bar_time, bgcolor=color.new(c, 85))
this.lWick := line.new(x1=midTime, y1=this.h, x2=midTime, y2=this.l, xloc=xloc.bar_time, color=color.new(c, 30), width=2)
It also draws start and end boundary lines so the candle window is clearly defined in time.
Indicatore Pine Script®





