1. Component Deconstruction¶
The script’s architecture is centered around a single, highly configurable, custom-built component: a Multi-Timeframe Volume Profile Engine. It does not use standard Pine Script® indicators like RSI or EMA. Instead, it constructs its own market studies from raw price and volume data.
Volume Profile Engine¶
Specific Configuration:
Model: The engine has two primary operational modes selected via
input.enum:Traditional Volume Profile: Measures the total volume transacted at each price level.Delta Profile: Measures the net difference between “buying” and “selling” volume at each price level.
Profile Granularity (
rows): The vertical resolution of the profile. The total price range of a high-timeframe (HTF) period is divided into this number of discrete price bins. Default is20.Data Timeframes: The script can run up to five independent profile calculations simultaneously (
htf1throughhtf5). Each is configured with:htf(Higher Timeframe): The period over which the profile is built (e.g., “240” for 4-hour, “1D” for daily).lowerTF(Lower Timeframe): The timeframe from which volume data is sourced. Default is"1"(1-minute). This is a critical configuration for data fidelity.
Functional Modification (Non-Standard Mechanics):
Data Sourcing via
request.security_lower_tf: This is the script’s core “hack.” Instead of using the volume from the HTF bars (e.g., one volume value for a 4-hour bar), it requests an array of all volume data from a much smaller timeframe (e.g., all 240 one-minute bars within that 4-hour period). This provides a high-fidelity dataset to construct a more accurate profile, as it captures the intraday distribution of volume which would otherwise be lost.Volume Directionality (Delta Calculation): The
direction()function approximates order flow aggression.For Tick Timeframe (
1T): It usesclose == bid(seller-initiated trade) andclose == ask(buyer-initiated trade) to determine direction. This is the most precise method available in Pine Script for assessing delta.For All Other Timeframes: It uses a standard uptick/downtick rule:
math.sign(close - close[1]). A positive result implies buying pressure, and a negative result implies selling pressure. The volume from thelowerTFbar is then signed (+ or -) based on this result.
Volume Distribution (
setValsmethod): When a singlelowerTFbar’s range (high-low) spans multiple price bins (rows), the script divides that bar’s volume equally among all the bins it touches (div = data.V / (math.abs(upLev - dnLev) + 1)). This is a volume-smoothing and distribution algorithm to prevent a single large-range bar from allocating all its volume to just one or two bins.Value Area (VA) & Point of Control (POC) Algorithm:
POC: Identified by finding the index of the price bin with the maximum
totalVol(htfProfile.totalVol.indexof(htfProfile.totalVol.max())).VA: Calculated by taking the total volume for the entire profile, multiplying it by
0.7(a hard-coded 70% standard), and then expanding outwards (up and down) from the POC row, summing the volume of each new row until the 70% target is met. The highest price level in this range is the Value Area High (VAH) and the lowest is the Value Area Low (VAL).
2. Logic Layering & Confluence¶
The script’s filtering mechanism is not sequential or conditional in the traditional sense (e.g., if conditionA then check conditionB). Instead, it operates on the principle of Visual and Locational Confluence, where the trader, not the code, performs the final filtering step.
Interaction Dynamics:
Locational Convergence: The core purpose of the script is to display up to five independent volume profiles side-by-side. The engine’s primary “signal” is the visual alignment of key levels from these different profiles. A powerful setup occurs when the POC from the
htf1(“30”) profile aligns at the same price as the VAL from thehtf3(“240”) profile. This convergence of significant levels across different timeframes dramatically increases the perceived importance of that price zone. The script provides the map; the user identifies where the roads intersect.No Divergence Calculation: The script does not compute price-vs-indicator divergences.
Hierarchical Filtering:
Gatekeeper #1 (Multi-Timeframe Structure): The primary filter is the multi-timeframe analysis itself. A POC on a 30-minute profile is considered less significant than a price level that acts as a POC on the 30-minute, 4-hour, and Daily profiles simultaneously. The hierarchy is implicitly defined by the timeframe; longer timeframes carry more weight.
Gatekeeper #2 (Delta Profile Mode): Switching the
modeltodeltaVPintroduces a sophisticated secondary filter.Traditional Profile: Answers “Where did volume trade?”
Delta Profile: Answers “Where were buyers or sellers more aggressive?”
This acts as a confirmation layer. For example, if price drops to a support level identified by a
Traditional ProfilePOC, the trader can switch toDelta Profilemode. Seeing a large positive delta (green bars) at that level confirms that buyers are aggressively absorbing the selling pressure, validating a potential long entry. This filters out “support” levels where no significant buying response is actually occurring.
3. The Execution Engine¶
This script is a discretionary analysis tool, not an automated strategy. It has no “Execution Engine” that generates true/false buy or sell signals. The “trigger” is a cognitive event in the trader’s mind based on the confluence of data presented.
Boolean Logic (Discretionary Conditions): A discretionary “true” signal for a long entry would be the logical AND of the following observed conditions:
Priceis currently trading at or near a key HTF level (POC, VAH, or VAL).AND This level demonstrates Locational Confluence (i.e., it is also a key level on at least one other displayed HTF profile).
AND (if using Delta Profile) The delta at this price level is positive, indicating buyer absorption is outweighing seller aggression.
Mathematical Constants & Their Significance:
0.7: The hard-coded multiplier used to calculate the Value Area. It defines the VA as the price range containing 70% of the session’s volume, a widely accepted industry standard. This directly impacts the width of the calculated value area.15: A visual normalization multiplier (* 15) used when calculating the horizontal length of the profile’s bars (normBuy,normSell). This constant has no impact on the trading logic or the calculation of POC/VAH/VAL. Its sole purpose is to scale the profile’s visual width for better readability on the chart.bar_index + [offset]: The offsets used in the finalgetHTFvalscalls (e.g.,bar_index + 49,bar_index + 109) are purely for visual positioning. They shift each profile horizontally to the right, creating distinct columns on the chart and preventing them from overlapping. They have no analytical or mathematical significance for the profile’s values.20: The default value forrows. A lower number creates a low-resolution, “blocky” profile, while a higher number creates a high-resolution, granular profile. This directly influences the precision of the calculated POC, VAH, and VAL levels.