Volume Profile & Delta Heatmap puts four volume readings on the price chart at once: a horizontal volume profile with its POC and value area, a delta heatmap that splits each session into price rows, a second profile drawn vertically to the right of the last candle, and BUY / SELL labels when price breaks the value area or crosses the POC. An info panel at the top sums it up: RSI and its state, then the POC, VAH and VAL prices.
The profile spreads each candle’s volume evenly over the price rows between its high and low. The wicks count twice in the divisor, so a candle with long wicks adds less volume than a candle of the same range made of body. The delta is estimated from the candle colour (a green candle counts its volume as buying, a red one as selling), not from tick data.
vpBars bars. Rows inside the value area are brighter, the POC row is red.vaPct percent of the volume.Every setting is an input() and shows in the indicator’s settings window, grouped in twelve sections. The main ones:
This code is Studio Only: it is written in ProRealCode Script, an extended language compatible with the ProBuilder syntax, and uses input(), FUNCTION, DRAWLABEL and text values. It runs with ProRealCode Studio on ProRealTime Web, not in the platform’s own editor, so no .itf file comes with it.
Everything is drawn on the last bar only and redrawn on each update: past bars carry no profile. The delta is an estimate from the candle colour, not a bid/ask volume split. The session timeframe must be equal to or above the chart’s (a daily session on a weekly chart is refused). The spacing rule, as written in the original, keeps at most one BUY and one SELL label on the chart; it was kept as is.
Original concept and logic by kingshukghosh71, published under the Mozilla Public License 2.0; this port keeps that licence. It is a visual reading tool: the signals have not been tested as a trading system.
//----------------------------------------------------------------
// PRC_Volume Profile & Delta Heatmap | indicator
// Author: Nicolas - port of the original by kingshukghosh71
// Original concept and logic by kingshukghosh71.
// Date: 03.12.2026
// https://www.prorealcode.com
// License: Mozilla Public License 2.0, as the original
// https://mozilla.org/MPL/2.0/
// Studio Only: written in ProRealCode Script, runs in
// ProRealCode Studio, not in the ProRealTime editor.
//----------------------------------------------------------------
DEFPARAM overlay = true
DEFPARAM DRAWONLASTBARONLY = true
// ---- 1. Volume Profile
input(vpBars, 150, "VP: Bars", int, minval = 20, maxval = 500, group = "1. Volume Profile", tooltip = "Bars the horizontal profile covers")
input(vpRows, 24, "VP: Rows", int, minval = 5, maxval = 50, group = "1. Volume Profile", tooltip = "Price rows of the horizontal profile")
input(vaPct, 70, "VP: Value Area %", float, minval = 0, maxval = 100, group = "1. Volume Profile", tooltip = "Share of the volume inside the value area")
input(vpSize, 70, "VP: Size (% of range)", float, minval = 20, maxval = 100, step = 5, group = "1. Volume Profile", tooltip = "Width of the POC row, in percent of VP Bars")
// ---- 2. Delta Heatmap
input(showDelta, 1, "Show Delta Heatmap", bool, group = "2. Delta Heatmap", tooltip = "Per-session delta grid behind the candles")
input(dSessions, 10, "Delta: Sessions", int, minval = 3, maxval = 20, group = "2. Delta Heatmap", tooltip = "Number of sessions in the grid")
input(dRows, 15, "Delta: Price Rows", int, minval = 5, maxval = 25, group = "2. Delta Heatmap", tooltip = "Price rows of the grid")
input(dTf, "1 day", "Delta: Timeframe", timeframe, options = ["1 day", "1 week", "1 month"], group = "2. Delta Heatmap", tooltip = "Period that defines a session")
// ---- 3. RSI Filter
input(useRsi, 1, "Enable RSI Filter", bool, group = "3. RSI Filter", tooltip = "Damp the delta of bars with a neutral RSI to 35 percent")
input(rsiLen, 14, "RSI Length", int, minval = 2, maxval = 50, group = "3. RSI Filter", tooltip = "RSI period")
input(rsiBull, 55, "Bullish Threshold", float, minval = 50, maxval = 80, group = "3. RSI Filter", tooltip = "RSI above this is bullish")
input(rsiBear, 45, "Bearish Threshold", float, minval = 20, maxval = 50, group = "3. RSI Filter", tooltip = "RSI below this is bearish")
// ---- 4. Signals
input(showSigs, 1, "Show Auto Buy/Sell Signals", bool, group = "4. Signals", tooltip = "BUY / SELL labels")
input(sigMode, "Both", "Signal Source", string, options = ["VA Breakout", "POC Bounce", "Both"], group = "4. Signals", tooltip = "Which crossings produce a signal")
input(needRsi, 1, "Require RSI Confirm", bool, group = "4. Signals", tooltip = "A signal needs the RSI threshold")
input(needDelta, 1, "Require Delta Confirm", bool, group = "4. Signals", tooltip = "A signal needs a delta of the same sign")
input(sigGap, 5, "Min Bars Between Signals", int, minval = 1, maxval = 50, group = "4. Signals", tooltip = "Minimum spacing between two signals of one side")
input(maxSigs, 20, "Max Signals Total", int, minval = 1, maxval = 50, group = "4. Signals", tooltip = "Cap on the number of signals drawn")
// ---- 5. Rotated VP
input(showRvp, 1, "Show Rotated VP (middle-right)", bool, group = "5. Rotated VP", tooltip = "Vertical-bar profile right of the last candle")
input(rvpBars, 150, "RV: Number of Bars", int, minval = 1, maxval = 500, group = "5. Rotated VP", tooltip = "Bars the rotated profile covers")
input(rvpRows, 24, "RV: Rows", int, minval = 5, maxval = 100, group = "5. Rotated VP", tooltip = "Columns of the rotated profile")
input(rvpPct, 70, "RV: Value Area %", float, minval = 0, maxval = 100, group = "5. Rotated VP", tooltip = "Share of the volume inside the value area")
// ---- 6. RV Layout
input(rvpOffset, 10, "RV: Horizontal offset from last bar (bars)", int, minval = 0, maxval = 200, group = "6. RV Layout", tooltip = "Gap between the last candle and the profile")
input(rvpVoffset, 0, "RV: Vertical offset (% of range)", float, minval = -200, maxval = 200, step = 5, group = "6. RV Layout", tooltip = "Moves the profile up or down")
input(rvpColw, 2, "RV: Column width", int, minval = 1, maxval = 10, group = "6. RV Layout", tooltip = "Column width in bars")
input(rvpGap, 1, "RV: Gap between columns", int, minval = 0, maxval = 5, group = "6. RV Layout", tooltip = "Gap between columns in bars")
input(rvpHpct, 60, "RV: Histogram height (% of range)", float, minval = 10, maxval = 200, group = "6. RV Layout", tooltip = "Height of the tallest column")
input(rvpLblstep, 5, "RV: Price label every N columns", int, minval = 1, maxval = 20, group = "6. RV Layout", tooltip = "Spacing of the price labels")
input(rvpAxisTicks, 3, "RV: Volume axis ticks", int, minval = 2, maxval = 10, group = "6. RV Layout", tooltip = "Ticks on the volume axis")
// ---- 7. RV Colors
input(rvpBarCol, "#1e78ff", "RV: Volume Bar", color, group = "7. RV Colors", tooltip = "Columns inside the value area")
input(rvpOutCol, "#1e78ff73", "RV: Bar outside VA", color, group = "7. RV Colors", tooltip = "Columns outside the value area")
input(rvpPocCol, "#ef3e4f", "RV: POC", color, group = "7. RV Colors", tooltip = "POC column and marker")
input(rvpVaCol, "#2ee86a", "RV: VAH / VAL", color, group = "7. RV Colors", tooltip = "Value-area brackets")
input(rvpTxtCol, "#c9d6f2", "RV: Text / Axis", color, group = "7. RV Colors", tooltip = "Axes and labels")
input(rvpFrameCol, "#3a4a66", "RV: Frame Border", color, group = "7. RV Colors", tooltip = "Frame outline")
// ---- 8. RV Show
input(rvpShowAxis, 1, "RV: Show Axes & Labels", bool, group = "8. RV Show", tooltip = "Axes, ticks and labels")
input(rvpShowVa, 1, "RV: Show VAH / VAL Brackets", bool, group = "8. RV Show", tooltip = "Value-area brackets")
input(rvpShowFrame, 1, "RV: Show Confining Frame", bool, group = "8. RV Show", tooltip = "Frame around the profile")
// ---- 9. Display
input(showVpLabels, 1, "Show POC/VAH/VAL Labels", bool, group = "9. Display", tooltip = "Level names left of the profile")
input(showAxis, 1, "Show Price Axis", bool, group = "9. Display", tooltip = "Price labels left of the profile")
input(showPanel, 1, "Show Info Panel", bool, group = "9. Display", tooltip = "RSI state and levels")
// ---- 10. Label Sizes
input(szAxisIn, "Tiny", "Price Axis", string, options = ["Tiny", "Small", "Normal", "Large", "Huge"], group = "10. Label Sizes", tooltip = "Price axis labels")
input(szVpIn, "Small", "VP Levels (POC/VAH/VAL)", string, options = ["Tiny", "Small", "Normal", "Large", "Huge"], group = "10. Label Sizes", tooltip = "Level labels")
input(szSigIn, "Normal", "Signal Arrows", string, options = ["Tiny", "Small", "Normal", "Large", "Huge"], group = "10. Label Sizes", tooltip = "BUY / SELL labels")
input(szDeltaIn, "Tiny", "Session Delta", string, options = ["Tiny", "Small", "Normal", "Large", "Huge"], group = "10. Label Sizes", tooltip = "Session delta totals")
input(szPanelIn, "Small", "Info Panel", string, options = ["Tiny", "Small", "Normal", "Large", "Huge"], group = "10. Label Sizes", tooltip = "Info panel")
// ---- 11. Colors
input(hCol, "#1e78ff", "VP Bars", color, group = "11. Colors", tooltip = "Profile rows (opacity set below)")
input(pocCol, "#ef3e4f", "POC", color, group = "11. Colors", tooltip = "POC row, line and label")
input(vaCol, "#2ee86a", "VAH / VAL", color, group = "11. Colors", tooltip = "VAH and VAL lines and labels")
input(buyCol, "#2ee86a", "Buy Signal", color, group = "11. Colors", tooltip = "BUY labels and positive delta")
input(sellCol, "#ef3e4f", "Sell Signal", color, group = "11. Colors", tooltip = "SELL labels and negative delta")
input(txtCol, "#c9d6f2", "Text", color, group = "11. Colors", tooltip = "Price axis text")
// ---- 12. Opacity
input(vaTransp, 80, "VP: VA Transparency", int, minval = 0, maxval = 100, group = "12. Opacity", tooltip = "Transparency of the rows inside the value area")
input(outTransp, 90, "VP: Outside Transparency", int, minval = 0, maxval = 100, group = "12. Opacity", tooltip = "Transparency of the rows outside the value area")
// ================= HELPERS
// Label size names -> DRAWLABEL pixel sizes (tiny/small/normal/large/huge = 8/11/14/18/24)
FUNCTION fSize(s)
px = 14
IF s = "Tiny" THEN
px = 8
ELSIF s = "Small" THEN
px = 11
ELSIF s = "Large" THEN
px = 18
ELSIF s = "Huge" THEN
px = 24
ENDIF
px
ENDFUNCTION
// Packed colour input (0xTTRRGGBB, TT = transparency) -> r, g, b, alpha byte
FUNCTION rgbaOf(c)
RETURN FLOOR(c / 65536) MOD 256, FLOOR(c / 256) MOD 256, c MOD 256, 255 - (FLOOR(c / 16777216) MOD 256)
ENDFUNCTION
// Volume of the slice [y21,y22] (height hgt, volume vol) that falls inside the row [y11,y12]
FUNCTION getVol(y11, y12, y21, y22, hgt, vol)
ov = MAX(MIN(MAX(y11, y12), MAX(y21, y22)) - MAX(MIN(y11, y12), MIN(y21, y22)), 0)
gv = 0
IF hgt > 0 THEN
gv = ov * vol / hgt
ENDIF
gv
ENDFUNCTION
// Price as text, rounded to the tick; ROUND(.., decimals) only strips floating-point noise
FUNCTION tickTxt(y)
ROUND(ROUND(y / ticksize) * ticksize, decimals)
ENDFUNCTION
// Volume as text: K / M / B with 3 decimals
FUNCTION fmtVol(v)
av = ABS(v)
IF av >= 1000000000 THEN
t = ROUND(v / 1000000000, 3) + "B"
ELSIF av >= 1000000 THEN
t = ROUND(v / 1000000, 3) + "M"
ELSIF av >= 1000 THEN
t = ROUND(v / 1000, 3) + "K"
ELSE
t = ROUND(v, 3) + ""
ENDIF
t
ENDFUNCTION
// Transparency (0-100) -> alpha byte
FUNCTION alphaOf(transp)
FLOOR((100 - transp) * 2.55 + 0.5)
ENDFUNCTION
// ================= PER-BAR SERIES (read back with [n] on the last bar)
// Session id = bar index of the session timeframe
TIMEFRAME(dTf)
htfIdx = barindex
TIMEFRAME(default)
sessId = htfIdx
rsiV = RSI[rsiLen](close)
rsiBullOk = rsiV > rsiBull
rsiBearOk = rsiV < rsiBear
rawDelta = 0
IF close > open THEN
rawDelta = volume
ELSIF close < open THEN
rawDelta = -volume
ENDIF
dMult = 1
IF useRsi AND NOT (rsiBullOk OR rsiBearOk) THEN
dMult = 0.35
ENDIF
deltaV = rawDelta * dMult
// ================= LAST BAR
IF islastbarupdate THEN
szAxis = fSize(szAxisIn)
szVp = fSize(szVpIn)
szSig = fSize(szSigIn)
szDelta = fSize(szDeltaIn)
szPanel = fSize(szPanelIn)
(hcolR, hcolG, hcolB, hcolA) = rgbaOf(hCol)
(poccR, poccG, poccB, poccA) = rgbaOf(pocCol)
(buycR, buycG, buycB, buycA) = rgbaOf(buyCol)
(sellcR, sellcG, sellcB, sellcA) = rgbaOf(sellCol)
// The heatmap and the signals look back 500 bars at most
nBuf = MIN(barindex + 1, 500)
IF barindex + 1 >= vpBars THEN
vpTop = Highest[vpBars](high)
vpBot = Lowest[vpBars](low)
vpStep = (vpTop - vpBot) / vpRows
// ---- (A) horizontal Volume Profile
FOR x = 0 TO vpRows DO
$lev[x] = vpBot + vpStep * x
NEXT
FOR x = 0 TO vpRows - 1 DO
$tv[x] = 0
NEXT
FOR b = 0 TO vpBars - 1 DO
bodyTop = MAX(close[b], open[b])
bodyBot = MIN(close[b], open[b])
topWick = high[b] - bodyTop
botWick = bodyBot - low[b]
bodyH = bodyTop - bodyBot
denom = 2 * topWick + 2 * botWick + bodyH
bodyVol = 0
topVol = 0
botVol = 0
IF denom > 0 THEN
bodyVol = bodyH * volume[b] / denom
topVol = 2 * topWick * volume[b] / denom
botVol = 2 * botWick * volume[b] / denom
ENDIF
FOR x = 0 TO vpRows - 1 DO
l1 = $lev[x]
l2 = $lev[x + 1]
$tv[x] = $tv[x] + getVol(l1, l2, bodyBot, bodyTop, bodyH, bodyVol) + getVol(l1, l2, bodyTop, high[b], topWick, topVol) / 2 + getVol(l1, l2, bodyBot, low[b], botWick, botVol) / 2
NEXT
NEXT
// Highest row; on a tie the lowest row wins
maxVol = $tv[0]
poc = 0
sumVol = 0
FOR x = 0 TO vpRows - 1 DO
sumVol = sumVol + $tv[x]
IF $tv[x] > maxVol THEN
maxVol = $tv[x]
poc = x
ENDIF
NEXT
totalMax = sumVol * vaPct / 100
vaTotal = $tv[poc]
up = poc
down = poc
FOR x = 0 TO vpRows - 1 DO
IF vaTotal >= totalMax THEN
BREAK
ENDIF
upperVol = 0
IF up < vpRows - 1 THEN
upperVol = $tv[up + 1]
ENDIF
lowerVol = 0
IF down > 0 THEN
lowerVol = $tv[down - 1]
ENDIF
IF upperVol = 0 AND lowerVol = 0 THEN
BREAK
ENDIF
IF upperVol >= lowerVol THEN
vaTotal = vaTotal + upperVol
up = up + 1
ELSE
vaTotal = vaTotal + lowerVol
down = down - 1
ENDIF
NEXT
pocPrice = ($lev[poc] + $lev[poc + 1]) / 2
vahPrice = $lev[up + 1]
valPrice = $lev[down]
// ---- (B) draw the horizontal VP
xh0 = barindex - vpBars + 1
hw = vpBars * vpSize / 100
rng = vpTop - vpBot
dist = rng / 500
xhR = xh0 - 3
FOR i = 0 TO vpRows - 1 DO
w = 0
IF maxVol > 0 THEN
w = $tv[i] / maxVol * hw
ENDIF
IF i = poc THEN
cR = poccR
cG = poccG
cB = poccB
cA = alphaOf(65)
ELSE
cR = hcolR
cG = hcolG
cB = hcolB
IF i >= down AND i <= up THEN
cA = alphaOf(vaTransp)
ELSE
cA = alphaOf(outTransp)
ENDIF
ENDIF
DRAWRECTANGLE(xh0, $lev[i + 1] - dist, xh0 + FLOOR(w + 0.5), $lev[i] + dist) FILLCOLOR(cR, cG, cB, cA) COLOURED(0, 0, 0, 0)
NEXT
DRAWSEGMENT(xh0, pocPrice, barindex + 1, pocPrice) COLOURED(pocCol) STYLE(line, 2)
DRAWSEGMENT(xh0, vahPrice, barindex + 1, vahPrice) COLOURED(vaCol) STYLE(dottedline, 1)
DRAWSEGMENT(xh0, valPrice, barindex + 1, valPrice) COLOURED(vaCol) STYLE(dottedline, 1)
IF showVpLabels THEN
// Level names left of the profile, transparent box
DRAWLABEL(xhR, pocPrice, "POC", arrowright, szVp * 1) FILLCOLOR(0, 0, 0, 0) COLOURED(pocCol)
DRAWLABEL(xhR, vahPrice, "VAH", arrowright, szVp * 1) FILLCOLOR(0, 0, 0, 0) COLOURED(vaCol)
DRAWLABEL(xhR, valPrice, "VAL", arrowright, szVp * 1) FILLCOLOR(0, 0, 0, 0) COLOURED(vaCol)
ENDIF
// ---- (C) Delta Heatmap
firstSess = sessId - dSessions + 1
IF showDelta THEN
dStep = rng / dRows
FOR si = 0 TO dSessions - 1 DO
$sx1[si] = -1
$sx2[si] = -1
$sds[si] = 0
NEXT
FOR k = 0 TO dSessions * dRows - 1 DO
$grid[k] = 0
NEXT
// Oldest bar first
FOR i = 0 TO nBuf - 1 DO
bb = nBuf - 1 - i
s = sessId[bb]
IF s >= firstSess THEN
si = s - firstSess
h = high[bb]
l = low[bb]
d = deltaV[bb]
xi = barindex - bb
IF $sx1[si] = -1 THEN
$sx1[si] = xi
ENDIF
$sx2[si] = xi
$sds[si] = $sds[si] + d
barRng = MAX(h - l, ticksize)
rLo = MAX(0, FLOOR((l - vpBot) / dStep))
rHi = MIN(dRows - 1, FLOOR((h - vpBot) / dStep))
// A bar wholly outside [vpBot, vpTop] has rLo > rHi: it adds nothing to the grid
FOR r = rLo TO rHi DO
rl = vpBot + dStep * r
rh = vpBot + dStep * (r + 1)
ovl = MAX(0, MIN(h, rh) - MAX(l, rl))
IF ovl > 0 THEN
idx = si * dRows + r
$grid[idx] = $grid[idx] + d * ovl / barRng
ENDIF
NEXT
ENDIF
NEXT
absMax = 0
FOR k = 0 TO dSessions * dRows - 1 DO
IF ABS($grid[k]) > absMax THEN
absMax = ABS($grid[k])
ENDIF
NEXT
FOR si = 0 TO dSessions - 1 DO
x1 = $sx1[si]
x2 = $sx2[si]
IF x1 <> -1 AND x2 >= x1 THEN
FOR r = 0 TO dRows - 1 DO
v = $grid[si * dRows + r]
t = 0
IF absMax > 0 THEN
t = ABS(v) / absMax
ENDIF
// Stronger delta = more opaque: transparency 92 -> 50
IF v > 0 THEN
gR = buycR
gG = buycG
gB = buycB
gA = FLOOR((8 + 42 * t) * 2.55 + 0.5)
ELSIF v < 0 THEN
gR = sellcR
gG = sellcG
gB = sellcB
gA = FLOOR((8 + 42 * t) * 2.55 + 0.5)
ELSE
// No delta: faint grey
gR = 120
gG = 123
gB = 134
gA = alphaOf(95)
ENDIF
DRAWRECTANGLE(x1, vpBot + dStep * (r + 1), x2, vpBot + dStep * r) FILLCOLOR(gR, gG, gB, gA) COLOURED(0, 0, 0, 0)
NEXT
ENDIF
NEXT
FOR si = 0 TO dSessions - 1 DO
x1 = $sx1[si]
x2 = $sx2[si]
IF x1 <> -1 AND x2 >= x1 THEN
sd = $sds[si]
xm = FLOOR((x1 + x2) / 2 + 0.5)
IF sd > 0 THEN
DRAWLABEL(xm, vpTop + vpStep * 2, fmtVol(sd), arrowdown, szDelta * 1) FILLCOLOR(0, 0, 0, 0) COLOURED(buyCol)
ELSE
DRAWLABEL(xm, vpTop + vpStep * 2, fmtVol(sd), arrowdown, szDelta * 1) FILLCOLOR(0, 0, 0, 0) COLOURED(sellCol)
ENDIF
ENDIF
NEXT
ENDIF
// ---- (D) Auto Signals
// Newest bar first
IF showSigs THEN
sigCount = 0
lastBuyBar = -10000
lastSellBar = -10000
FOR bb = 0 TO nBuf - 2 DO
IF sigCount >= maxSigs THEN
BREAK
ENDIF
cl = close[bb]
clPrev = close[bb + 1]
d = deltaV[bb]
rv = rsiV[bb]
xi = barindex - bb
rsiBuyOk = NOT needRsi OR rv > rsiBull
rsiSellOk = NOT needRsi OR rv < rsiBear
deltaBuyOk = NOT needDelta OR d > 0
deltaSellOk = NOT needDelta OR d < 0
vahBkUp = cl > vahPrice AND clPrev <= vahPrice
valBkDn = cl < valPrice AND clPrev >= valPrice
pocUp = cl > pocPrice AND clPrev <= pocPrice AND rv > 50
pocDn = cl < pocPrice AND clPrev >= pocPrice AND rv < 50
buySig = 0
sellSig = 0
IF sigMode = "VA Breakout" OR sigMode = "Both" THEN
IF vahBkUp AND rsiBuyOk AND deltaBuyOk THEN
buySig = 1
ENDIF
IF valBkDn AND rsiSellOk AND deltaSellOk THEN
sellSig = 1
ENDIF
ENDIF
IF sigMode = "POC Bounce" OR sigMode = "Both" THEN
IF pocUp AND rsiBuyOk AND deltaBuyOk THEN
buySig = 1
ENDIF
IF pocDn AND rsiSellOk AND deltaSellOk THEN
sellSig = 1
ENDIF
ENDIF
IF buySig AND xi - lastBuyBar >= sigGap THEN
DRAWLABEL(xi, low[bb] - vpStep * 1.5, "▲ BUY", arrowup, szSig * 1) FILLCOLOR(buycR, buycG, buycB, alphaOf(15)) COLOURED(255, 255, 255)
lastBuyBar = xi
sigCount = sigCount + 1
ELSIF sellSig AND xi - lastSellBar >= sigGap THEN
DRAWLABEL(xi, high[bb] + vpStep * 1.5, "▼ SELL", arrowdown, szSig * 1) FILLCOLOR(sellcR, sellcG, sellcB, alphaOf(15)) COLOURED(255, 255, 255)
lastSellBar = xi
sigCount = sigCount + 1
ENDIF
NEXT
ENDIF
// ---- (E) Price Axis
IF showAxis THEN
axisStep = MAX(1, FLOOR(vpRows / 8 + 0.5))
FOR r = 0 TO vpRows DO
IF (r MOD axisStep) = 0 OR r = vpRows THEN
y = vpBot + vpStep * r
// Price labels left of the profile
DRAWLABEL(xh0 - 3, y, tickTxt(y) + "", arrowleft, szAxis * 1) FILLCOLOR(0, 0, 0, 0) COLOURED(txtCol)
ENDIF
NEXT
ENDIF
// ---- (F) Info Panel
IF showPanel THEN
IF rsiBullOk THEN
rsiState = "BULL ✓"
ELSIF rsiBearOk THEN
rsiState = "BEAR ✓"
ELSE
rsiState = "NEUTRAL"
ENDIF
panelTxt = "RSI: " + ROUND(rsiV, 2) + " | " + rsiState + " · POC: " + tickTxt(pocPrice) + " · VAH: " + tickTxt(vahPrice) + " · VAL: " + tickTxt(valPrice)
xPanel = barindex - FLOOR(vpBars / 2)
IF rsiBullOk THEN
DRAWLABEL(xPanel, vpTop + vpStep * 5, panelTxt, arrowdown, szPanel * 1) FILLCOLOR(0, 0, 0, alphaOf(20)) COLOURED(buyCol)
ELSIF rsiBearOk THEN
DRAWLABEL(xPanel, vpTop + vpStep * 5, panelTxt, arrowdown, szPanel * 1) FILLCOLOR(0, 0, 0, alphaOf(20)) COLOURED(sellCol)
ELSE
// Neutral RSI: grey
DRAWLABEL(xPanel, vpTop + vpStep * 5, panelTxt, arrowdown, szPanel * 1) FILLCOLOR(0, 0, 0, alphaOf(20)) COLOURED(120, 123, 134)
ENDIF
ENDIF
ENDIF
// ---- (G) Rotated VP - its own range and profile
IF showRvp AND barindex + 1 >= rvpBars THEN
rTop = Highest[rvpBars](high)
rBot = Lowest[rvpBars](low)
rStep = (rTop - rBot) / rvpRows
FOR x = 0 TO rvpRows DO
$rlev[x] = rBot + rStep * x
NEXT
FOR x = 0 TO rvpRows - 1 DO
$rtv[x] = 0
NEXT
FOR b = 0 TO rvpBars - 1 DO
rBodyTop = MAX(close[b], open[b])
rBodyBot = MIN(close[b], open[b])
rTopWick = high[b] - rBodyTop
rBotWick = rBodyBot - low[b]
rBodyH = rBodyTop - rBodyBot
rDenom = 2 * rTopWick + 2 * rBotWick + rBodyH
rBodyVol = 0
rTopVol = 0
rBotVol = 0
IF rDenom > 0 THEN
rBodyVol = rBodyH * volume[b] / rDenom
rTopVol = 2 * rTopWick * volume[b] / rDenom
rBotVol = 2 * rBotWick * volume[b] / rDenom
ENDIF
FOR x = 0 TO rvpRows - 1 DO
l1 = $rlev[x]
l2 = $rlev[x + 1]
$rtv[x] = $rtv[x] + getVol(l1, l2, rBodyBot, rBodyTop, rBodyH, rBodyVol) + getVol(l1, l2, rBodyTop, high[b], rTopWick, rTopVol) / 2 + getVol(l1, l2, rBodyBot, low[b], rBotWick, rBotVol) / 2
NEXT
NEXT
rMaxVol = $rtv[0]
rPoc = 0
rSum = 0
FOR x = 0 TO rvpRows - 1 DO
rSum = rSum + $rtv[x]
IF $rtv[x] > rMaxVol THEN
rMaxVol = $rtv[x]
rPoc = x
ENDIF
NEXT
rTotalMax = rSum * rvpPct / 100
rVaTotal = $rtv[rPoc]
rUp = rPoc
rDown = rPoc
FOR x = 0 TO rvpRows - 1 DO
IF rVaTotal >= rTotalMax THEN
BREAK
ENDIF
rUpper = 0
IF rUp < rvpRows - 1 THEN
rUpper = $rtv[rUp + 1]
ENDIF
rLower = 0
IF rDown > 0 THEN
rLower = $rtv[rDown - 1]
ENDIF
IF rUpper = 0 AND rLower = 0 THEN
BREAK
ENDIF
IF rUpper >= rLower THEN
rVaTotal = rVaTotal + rUpper
rUp = rUp + 1
ELSE
rVaTotal = rVaTotal + rLower
rDown = rDown - 1
ENDIF
NEXT
// geometry
rX0 = barindex + rvpOffset
rHgt = (rTop - rBot) * rvpHpct / 100
rRng = rTop - rBot
rMid = (rTop + rBot) / 2 + rRng * rvpVoffset / 100
rBase = rMid - rHgt / 2
rColstep = rvpColw + rvpGap
rXend = rX0 + rvpRows * rColstep
IF rvpShowFrame THEN
// Frame: 2-pixel border, translucent navy fill
DRAWRECTANGLE(rX0 - rColstep * 2, rBase + rHgt * 1.32, rXend + rColstep, rBase - (rTop - rBot) * 0.10) FILLCOLOR(11, 42, 74, alphaOf(85)) COLOURED(rvpFrameCol) STYLE(line, 2)
ENDIF
FOR i = 0 TO rvpRows - 1 DO
x1 = rX0 + i * rColstep
x2 = x1 + rvpColw
hb = 0
IF rMaxVol > 0 THEN
hb = $rtv[i] / rMaxVol * rHgt
ENDIF
IF i = rPoc THEN
DRAWRECTANGLE(x1, rBase + hb, x2, rBase) FILLCOLOR(rvpPocCol) COLOURED(0, 0, 0, 0)
ELSIF i >= rDown AND i <= rUp THEN
DRAWRECTANGLE(x1, rBase + hb, x2, rBase) FILLCOLOR(rvpBarCol) COLOURED(0, 0, 0, 0)
ELSE
DRAWRECTANGLE(x1, rBase + hb, x2, rBase) FILLCOLOR(rvpOutCol) COLOURED(0, 0, 0, 0)
ENDIF
NEXT
IF rvpShowAxis THEN
DRAWSEGMENT(rX0 - 1, rBase, rXend, rBase) COLOURED(rvpTxtCol) STYLE(line, 1)
DRAWSEGMENT(rXend - 1, rBase, rXend + 1, rBase) COLOURED(rvpTxtCol) STYLE(line, 1)
DRAWSEGMENT(rX0 - 1, rBase, rX0 - 1, rBase + rHgt * 1.05) COLOURED(rvpTxtCol) STYLE(line, 1)
FOR t = 0 TO rvpAxisTicks DO
yv = rBase + rHgt * t / rvpAxisTicks
DRAWSEGMENT(rX0 - 2, yv, rX0 - 1, yv) COLOURED(rvpTxtCol) STYLE(line, 1)
DRAWLABEL(rX0 - 2, yv, fmtVol(rMaxVol * t / rvpAxisTicks), arrowright, small) FILLCOLOR(0, 0, 0, 0) COLOURED(rvpTxtCol)
NEXT
FOR i = 0 TO rvpRows - 1 DO
IF (i MOD rvpLblstep) = 0 AND i <> rPoc THEN
pr = ($rlev[i] + $rlev[i + 1]) / 2
// Label at the column's centre
DRAWLABEL(FLOOR(rX0 + i * rColstep + rvpColw / 2 + 0.5), rBase, tickTxt(pr) + "", arrowup, small) FILLCOLOR(0, 0, 0, 0) COLOURED(rvpTxtCol)
ENDIF
NEXT
ENDIF
rHb = rBase + rHgt * 1.02
rPocX = FLOOR(rX0 + rPoc * rColstep + rvpColw / 2 + 0.5)
rPocTop = rBase + $rtv[rPoc] / rMaxVol * rHgt
DRAWSEGMENT(rPocX, rHb, rPocX, rPocTop) COLOURED(rvpPocCol) STYLE(line, 2)
DRAWLABEL(rPocX, rHb + rHgt * 0.15, "POC", arrowdown, small) FILLCOLOR(0, 0, 0, 0) COLOURED(rvpPocCol)
IF rvpShowVa THEN
rValX = FLOOR(rX0 + rDown * rColstep + rvpColw / 2 + 0.5)
rVahX = FLOOR(rX0 + rUp * rColstep + rvpColw / 2 + 0.5)
rValTop = rBase + $rtv[rDown] / rMaxVol * rHgt
rVahTop = rBase + $rtv[rUp] / rMaxVol * rHgt
DRAWSEGMENT(rValX, rValTop, rValX, rHb) COLOURED(rvpVaCol) STYLE(line, 1)
DRAWSEGMENT(rValX, rHb, rPocX, rHb) COLOURED(rvpVaCol) STYLE(dottedline, 1)
DRAWLABEL(rValX, rHb - rHgt * 0.01, "VAL", arrowdown, small) FILLCOLOR(0, 0, 0, 0) COLOURED(rvpVaCol)
DRAWSEGMENT(rVahX, rVahTop, rVahX, rHb) COLOURED(rvpVaCol) STYLE(line, 1)
DRAWSEGMENT(rPocX, rHb, rVahX, rHb) COLOURED(rvpVaCol) STYLE(dottedline, 1)
DRAWLABEL(rVahX, rHb + rHgt * 0.07, "VAH", arrowdown, small) FILLCOLOR(0, 0, 0, 0) COLOURED(rvpVaCol)
ENDIF
ENDIF
ENDIF
RETURN