OPEN-SOURCE SCRIPT
Regression Market Profile [BOSWaves]

Regression Market Profile [BOSWaves] - Curve-Following Distribution Analysis with TPO Letters, Heatmap, and Profile Modes
Overview
Regression Market Profile [BOSWaves] is a regression-anchored market profile system that maps the distribution of price activity relative to a best-fit regression curve rather than within fixed horizontal price boundaries, where row assignment, POC identification, value area construction, and interior visualization are all derived from how far actual price deviated from the regression prediction on each bar rather than from absolute price levels.

Instead of constructing a profile against a static price range, this system fits either a linear or polynomial regression to recent price history and measures each bar's deviation from the fitted curve, distributing that activity into horizontal rows centered on the regression line. As the curve bends and trends through price space, the entire profile follows it, revealing where price consistently clustered above or below the regression prediction and identifying the deviation offset with the highest time-at-price concentration as a dynamic POC that moves with the trend rather than anchoring to a fixed session boundary.
This creates a market profile framework that adapts to the prevailing directional structure of price rather than imposing a fixed container. The interior visualization communicates distribution in three configurable modes: a heatmap that reveals how the distribution migrated across time columns, a profile extending from the right edge showing the cumulative distribution shape, and TPO letter boxes that follow the regression curve encoding chronological time progression through gradient coloring. Standard deviation bounds, value area boundaries, and a dual-line POC glow all follow the curve simultaneously, providing a complete structural reference system that moves with the trend rather than remaining static.
Price is therefore evaluated not for its absolute level but for its position relative to the regression expectation, with the profile revealing which deviation offsets attracted the most sustained activity throughout the regression window.
Conceptual Framework
Regression Market Profile is founded on the principle that meaningful participation clustering should be measured relative to the expected price path defined by recent price history rather than within arbitrary time or price containers that carry no relationship to the actual directional structure of the market.
Traditional market profile approaches anchor distributions to calendar sessions or fixed price ranges, producing profiles that reflect where price traded within a time box rather than where it clustered relative to its own trend. This framework replaces fixed-container profiling with regression-relative distribution measurement, where each bar's contribution to the profile is determined by how far actual price deviated from the best-fit curve rather than where it sat in absolute price space. The profile therefore reveals the structural tendencies of price relative to its own trend dynamics rather than its behavior within an externally imposed boundary.
Three core principles guide the design:
This shifts market profile analysis from session-bounded horizontal distribution tracking into regression-relative participation mapping where the profile reveals structural clustering tendencies within the context of the prevailing trend curvature.
Theoretical Foundation
The indicator combines matrix-based polynomial and linear regression fitting to recent HL2 price data, rolling standard deviation for channel scaling and SD bound construction, deviation-based row assignment for distribution building, POC identification through maximum row count, value area expansion from POC outward, and three distinct interior visualization systems that present the same distribution data through different geometric representations following the regression curve.
The regression is computed using ordinary least squares matrix operations: the design matrix is constructed with powers of bar index up to the polynomial degree, transposed and multiplied to form the normal equations, inverted, and multiplied by the price vector to produce regression coefficients, which are then applied to generate the full prediction array. Standard deviation of the HL2 series over the regression window provides the channel scaling unit and drives the SD bound envelopes. Row assignment divides the channel height by the number of rows and places each bar's deviation from its predicted value into the corresponding row bin. POC and value area use the same maximum-count and outward-expansion logic as conventional market profile, applied to the curved row counts.
Four internal systems operate in tandem:
This design ensures the distribution and all structural reference elements continuously adapt to the regression curve while the three interior modes provide complementary analytical perspectives on the same underlying participation data.
How It Works
Regression Market Profile evaluates price through a sequence of regression-aware distribution and visualization processes:
Together, these elements form a continuously recomputed regression-relative distribution system where every visual element adapts to the current curve shape and all three interior modes present the same participation data from different analytical perspectives.
Interpretation
Regression Market Profile should be interpreted as a regression-relative structural distribution system where clustering above or below the fitted curve reveals directional bias tendencies and participation concentration within the prevailing trend:
POC offset direction, value area extent, distribution shape across modes, and SD bound interactions collectively provide more structural context than any element in isolation.
Signal Logic & Visual Cues
Regression Market Profile does not generate discrete buy or sell signals but provides continuous structural reference through distribution-derived levels:
Standard deviation bound interactions provide additional reference for statistically extreme deviation events that historically attract mean reversion activity back toward the regression curve and POC.
Strategy Integration
Regression Market Profile fits within regression-informed structural analysis and distribution-based approaches:
Technical Implementation Details
Optimal Application Parameters
Timeframe Guidance:
Suggested Baseline Configuration:
These suggested parameters should be used as a baseline; their effectiveness depends on the instrument's trend characteristics, volatility profile, and preferred distribution granularity, so fine-tuning is expected for optimal performance.
Parameter Calibration Notes
Use the following adjustments to refine behavior without altering the core logic:
Adjustments should be incremental and evaluated across multiple session types rather than isolated market conditions.
Performance Characteristics
High Effectiveness:
Reduced Effectiveness:
Integration Guidelines
Disclaimer
Regression Market Profile [BOSWaves] is a professional-grade regression-relative distribution and market profile analysis tool. It uses ordinary least squares curve fitting with deviation-based participation mapping but does not predict future price movements. Results depend on market conditions, instrument trend characteristics, parameter selection, and disciplined execution. BOSWaves recommends deploying this indicator within a broader analytical framework that incorporates order flow context, structural analysis, and comprehensive risk management.
Overview
Regression Market Profile [BOSWaves] is a regression-anchored market profile system that maps the distribution of price activity relative to a best-fit regression curve rather than within fixed horizontal price boundaries, where row assignment, POC identification, value area construction, and interior visualization are all derived from how far actual price deviated from the regression prediction on each bar rather than from absolute price levels.
Instead of constructing a profile against a static price range, this system fits either a linear or polynomial regression to recent price history and measures each bar's deviation from the fitted curve, distributing that activity into horizontal rows centered on the regression line. As the curve bends and trends through price space, the entire profile follows it, revealing where price consistently clustered above or below the regression prediction and identifying the deviation offset with the highest time-at-price concentration as a dynamic POC that moves with the trend rather than anchoring to a fixed session boundary.
This creates a market profile framework that adapts to the prevailing directional structure of price rather than imposing a fixed container. The interior visualization communicates distribution in three configurable modes: a heatmap that reveals how the distribution migrated across time columns, a profile extending from the right edge showing the cumulative distribution shape, and TPO letter boxes that follow the regression curve encoding chronological time progression through gradient coloring. Standard deviation bounds, value area boundaries, and a dual-line POC glow all follow the curve simultaneously, providing a complete structural reference system that moves with the trend rather than remaining static.
Price is therefore evaluated not for its absolute level but for its position relative to the regression expectation, with the profile revealing which deviation offsets attracted the most sustained activity throughout the regression window.
Conceptual Framework
Regression Market Profile is founded on the principle that meaningful participation clustering should be measured relative to the expected price path defined by recent price history rather than within arbitrary time or price containers that carry no relationship to the actual directional structure of the market.
Traditional market profile approaches anchor distributions to calendar sessions or fixed price ranges, producing profiles that reflect where price traded within a time box rather than where it clustered relative to its own trend. This framework replaces fixed-container profiling with regression-relative distribution measurement, where each bar's contribution to the profile is determined by how far actual price deviated from the best-fit curve rather than where it sat in absolute price space. The profile therefore reveals the structural tendencies of price relative to its own trend dynamics rather than its behavior within an externally imposed boundary.
Three core principles guide the design:
- Profile distribution should be measured as deviation from a fitted regression curve rather than as absolute price position, ensuring the profile captures participation clustering relative to trend expectation rather than within arbitrary price boundaries.
- The interior visualization mode should be configurable between temporal migration analysis, cumulative distribution shape, and chronological letter encoding, allowing the same structural data to be interpreted through different analytical lenses depending on the trader's workflow.
- All structural reference elements including POC, value area, standard deviation bounds, and centerline should follow the regression curve continuously rather than anchoring to static horizontal levels, maintaining relevance to the current trend structure throughout the regression window.
This shifts market profile analysis from session-bounded horizontal distribution tracking into regression-relative participation mapping where the profile reveals structural clustering tendencies within the context of the prevailing trend curvature.
Theoretical Foundation
The indicator combines matrix-based polynomial and linear regression fitting to recent HL2 price data, rolling standard deviation for channel scaling and SD bound construction, deviation-based row assignment for distribution building, POC identification through maximum row count, value area expansion from POC outward, and three distinct interior visualization systems that present the same distribution data through different geometric representations following the regression curve.
The regression is computed using ordinary least squares matrix operations: the design matrix is constructed with powers of bar index up to the polynomial degree, transposed and multiplied to form the normal equations, inverted, and multiplied by the price vector to produce regression coefficients, which are then applied to generate the full prediction array. Standard deviation of the HL2 series over the regression window provides the channel scaling unit and drives the SD bound envelopes. Row assignment divides the channel height by the number of rows and places each bar's deviation from its predicted value into the corresponding row bin. POC and value area use the same maximum-count and outward-expansion logic as conventional market profile, applied to the curved row counts.
Four internal systems operate in tandem:
- Regression Engine: Computes linear or polynomial best-fit predictions for all bars in the lookback window using matrix least squares, providing the curved baseline that all distribution measurements, row positioning, and visual elements follow.
- Distribution Construction System: Measures each bar's deviation from its regression prediction, assigns it to a horizontal row within the standard deviation channel, accumulates row counts across the full window, and derives POC and value area from the resulting distribution.
- Interior Visualization Engine: Renders the distribution data inside the channel in one of three modes: curved polygon cells per time column normalized independently for heatmap temporal migration display, curved profile bars extending from the right edge scaled to global row counts for distribution shape display, or TPO letter boxes positioned at the regression-relative row boundaries with gradient chronological coloring for time period encoding.
- Structural Reference System: Draws the dual-line POC glow following the regression curve at the POC row offset, value area boundary polylines at the VA top and bottom offsets, standard deviation envelope polylines at one through three sigma above and below the curve, and a dashed centerline following the regression prediction directly.
This design ensures the distribution and all structural reference elements continuously adapt to the regression curve while the three interior modes provide complementary analytical perspectives on the same underlying participation data.
How It Works
Regression Market Profile evaluates price through a sequence of regression-aware distribution and visualization processes:
- Regression Calculation: On the last bar, the design matrix is constructed from bar index values raised to polynomial powers up to the configured degree. Ordinary least squares solves for the coefficient vector and applies it to produce a prediction array covering all bars in the lookback window.
- Channel Scaling: The standard deviation of HL2 over the regression window multiplied by the configured channel width defines the maximum deviation distance, establishing the vertical extent of the distribution channel centered on the regression curve.
- Row Assignment and Count Accumulation: Each bar's actual HL2 is compared to its regression prediction and the deviation is assigned to a horizontal row bin derived from the channel height divided by the row count. Row counts accumulate across all bars in the window.
- POC Identification: The row with the maximum accumulated count is identified as the Point of Control, representing the deviation offset from the regression curve where price spent the most time during the lookback window.
- Value Area Construction: Starting from the POC row, adjacent rows are added in order of greater count until the cumulative total reaches the configured value area percentage of all bar counts, defining the high-activity zone around the POC.
- Interior Rendering - Heatmap Mode: The lookback window is divided into time columns and each column builds its own per-row counts, normalized independently so each column's internal distribution is shown on its own scale. Curved polygon cells are rendered for each occupied cell with hot-cold gradient coloring by normalized density.
- Interior Rendering - Profile Mode: Each row's global count is expressed as a fraction of the maximum row count and scaled to a configurable proportion of the total regression length. Curved polygon bars extend leftward from the right edge by the scaled bar length, forming a profile shape that follows the regression curve.
- Interior Rendering - Letters Mode: Each bar is assigned a sequential alphabetical letter based on its time period index relative to the TPO timeframe. Letters are accumulated per row and rendered as individual boxes positioned at the regression-relative row boundaries, with gradient coloring that progresses from cold to hot as the letter index advances chronologically.
- POC Polyline Rendering: A wide low-opacity glow polyline and a thinner full-opacity core polyline follow the regression curve at the POC deviation offset, providing a continuously curving reference for the maximum activity level throughout the window.
- Value Area and SD Bound Rendering: Dotted polylines follow the regression curve at the value area high and low offsets and at one, two, and three standard deviation distances above and below the curve, with opacity increasing with distance from the curve.
Together, these elements form a continuously recomputed regression-relative distribution system where every visual element adapts to the current curve shape and all three interior modes present the same participation data from different analytical perspectives.
Interpretation
Regression Market Profile should be interpreted as a regression-relative structural distribution system where clustering above or below the fitted curve reveals directional bias tendencies and participation concentration within the prevailing trend:
- Regression Centerline: The dashed curve following the best-fit prediction represents the trend's expected price path. Price consistently above it indicates sustained positive deviation bias; price consistently below indicates sustained negative deviation bias.
- POC Line: The dual glow and core polyline following the curve at the maximum activity offset marks the deviation level where price spent the most time relative to the regression prediction, representing the most accepted deviation from expected trend behavior during the window.
- Value Area Boundaries: Dotted polylines above and below the POC line mark the deviation range containing the configured percentage of total activity, identifying the zone of concentrated acceptance around the POC.
- Standard Deviation Bounds: One, two, and three sigma dotted envelopes around the curve mark statistically extreme deviation distances, with progressively greater opacity indicating greater statistical rarity of price reaching those offsets.
- Heatmap Mode: Each time column displays its own normalized distribution, with hot colors indicating the most active deviation level within that column and cold colors indicating less active levels. Reading across columns from left to right reveals how the distribution migrated as the window progressed.
- Profile Mode: Curved bars extending from the right edge show the cumulative distribution shape across the full window, with longer bars indicating deviation levels with greater total activity and hot coloring marking the densest regions.
- Letters Mode: Sequential alphabet letters fill the channel rows at their regression-relative positions, with gradient coloring from cold early-window letters to hot late-window letters encoding chronological time progression. Single-letter rows indicate price visited that deviation level in only one time period, functioning as regression-relative single prints.
- POC Offset Interpretation: A POC positioned above the regression centerline indicates that price has consistently traded at a positive deviation from expectations, reflecting bullish structural bias within the window. A POC below the centerline indicates bearish structural bias.
POC offset direction, value area extent, distribution shape across modes, and SD bound interactions collectively provide more structural context than any element in isolation.
Signal Logic & Visual Cues
Regression Market Profile does not generate discrete buy or sell signals but provides continuous structural reference through distribution-derived levels:
- POC Reaction: Price returning to the deviation level corresponding to the POC polyline encounters the most accepted level within the regression window, frequently acting as magnetic reference for reversion or continuation assessment.
- Value Area Boundary Interaction: Price moving outside the value area boundaries enters statistically less accepted deviation territory, suggesting either trend extension beyond typical participation or the beginning of structural repositioning relative to the regression curve.
Standard deviation bound interactions provide additional reference for statistically extreme deviation events that historically attract mean reversion activity back toward the regression curve and POC.
Strategy Integration
Regression Market Profile fits within regression-informed structural analysis and distribution-based approaches:
- POC Reversion Framing: Use the POC polyline as a dynamic reversion target when price has extended to the outer standard deviation bounds, with the curved POC providing a continuously updating level that reflects the trend's accepted center rather than a static price.
- Value Area Acceptance Testing: Monitor whether price is trading within or outside the value area boundaries to assess whether current price activity represents accepted trend behavior or extended deviation warranting mean reversion consideration.
- Heatmap Migration Analysis: Use temporal migration visible in heatmap mode to assess whether distribution is shifting toward positive or negative deviation over the course of the window, providing directional bias evidence from the distribution's evolution rather than from price alone.
- Profile Shape Assessment: Use profile mode to assess distribution symmetry around the regression curve. A distribution skewed above the centerline suggests persistent positive bias; skew below suggests persistent negative bias. A symmetric bell shape suggests balanced acceptance around the regression expectation.
- Single Print Monitoring in Letters Mode: Treat single-letter rows in letters mode as regression-relative thin participation levels that price is likely to revisit, analogous to single prints in conventional market profile.
- Regression Mode Selection: Use Linear mode for markets trending in a consistent direction where a straight best-fit line accurately represents the price path. Use Polynomial mode for markets with visible curvature in their trend structure where the quadratic bend better fits the actual price trajectory.
Technical Implementation Details
- Regression Engine: Matrix OLS computation using design matrix construction, normal equation formation, matrix inversion, and coefficient application for linear or polynomial curve fitting to HL2
- Channel Construction: Rolling standard deviation-scaled channel with configurable width multiplier providing deviation row boundaries
- Distribution System: Deviation-based row assignment with global count accumulation, POC maximum identification, and outward value area expansion
- Heatmap Engine: Per-column count normalization with curved polygon cell rendering using hot-cold gradient by normalized density
- Profile Engine: Global count-scaled curved bar polylines extending from the right edge by proportional bar length
- Letters Engine: TPO timeframe-ratio letter assignment with per-row accumulation and gradient chronological box rendering at regression-relative boundaries
- Structural System: Dual-line POC glow, dotted VA boundary polylines, three-sigma dotted SD envelopes, and dashed centerline all following the regression curve via chart.point arrays
- Performance Profile: All rendering triggered only on the last bar with full object cleanup and rebuild on each update, polyline-based curved geometry for all structural elements
Optimal Application Parameters
Timeframe Guidance:
- 1 - 5 min: Intraday regression profiling with shorter length and tighter channel for fast-adapting curve that captures intraday trend structure
- 15 - 60 min: Session-level distribution analysis with balanced length and moderate channel width for meaningful participation mapping across typical session trends
- 4H - Daily: Swing-level regression profiling with longer lookback and polynomial mode for curve-following distribution across multi-session directional structures
Suggested Baseline Configuration:
- Length: 200
- Mode: Polynomial
- Channel Width (SD×): 3.0
- Inner Display: Letters
- Rows: 12
- TPO Timeframe: 30
- Value Area %: 70
- Show POC: Enabled
- Show Value Area: Enabled
- Show SD Bounds: Enabled
These suggested parameters should be used as a baseline; their effectiveness depends on the instrument's trend characteristics, volatility profile, and preferred distribution granularity, so fine-tuning is expected for optimal performance.
Parameter Calibration Notes
Use the following adjustments to refine behavior without altering the core logic:
- Curve fits too loosely to recent price: Decrease Length to shorten the regression window, producing a curve that adapts more quickly to recent price structure. Switch to Polynomial mode if the trend has visible curvature that a linear fit cannot capture.
- Curve too reactive to short-term price movement: Increase Length to smooth the regression across more history, producing a more stable curve that reflects longer-term directional structure and reduces sensitivity to recent fluctuations.
- Channel too narrow or wide: Adjust Channel Width to scale the standard deviation multiplier, expanding the channel to capture more price activity within the distribution or contracting it to focus on the core deviation range.
- Distribution too coarse or granular: Adjust Rows to increase or decrease the number of horizontal price bins, calibrating vertical resolution to the channel height and the instrument's typical deviation behavior within the regression window.
- Heatmap columns too few or many: Adjust Heatmap Columns to control the time resolution of the migration display, with fewer columns showing broader temporal patterns and more columns revealing finer migration detail at the cost of visual density.
- Profile bars too short or long: Adjust Profile Width to scale the maximum bar length as a fraction of the regression window, calibrating how far the longest bars extend from the right edge relative to the available chart space.
- Too few or many letters per row: Adjust TPO Timeframe to change the time period each letter represents. Higher timeframes produce fewer, broader letters; lower timeframes produce more letters with finer time resolution.
Adjustments should be incremental and evaluated across multiple session types rather than isolated market conditions.
Performance Characteristics
High Effectiveness:
- Trending markets where the regression curve accurately represents the directional price path and the distribution reveals consistent deviation bias that reflects genuine structural tendencies
- Instruments with smooth, curving price trends where polynomial mode produces a better-fitting curve than a straight line and the distribution around the curve is more meaningful than a session-anchored profile
- Market profile-informed approaches that benefit from a continuously adapting POC and value area that follow the trend rather than anchoring to fixed session boundaries
- Distribution analysis workflows where heatmap temporal migration or profile shape provides directional bias evidence from participation patterns rather than from price indicators alone
Reduced Effectiveness:
- Choppy, directionless markets where the regression curve has no clear shape and the distribution is uniform across rows, reducing the interpretive value of POC location and value area extent
- Markets with frequent sharp reversals where the regression window spans multiple opposing structural moves, producing a curve that represents none of them accurately and a distribution without meaningful clustering
- Extremely short lookback windows where the matrix regression calculation is underdetermined or the distribution contains too few bars per row to produce statistically meaningful counts
- Instruments with discontinuous price action including frequent gaps where the HL2 series used for regression produces curves that follow gap-distorted price paths rather than genuine trend structures
Integration Guidelines
- Confluence: Combine with BOSWaves structural tools, momentum oscillators, or volume analysis to validate POC and value area interactions with broader analytical context before acting on regression-relative distribution levels
- POC Offset Bias: Monitor the position of the POC relative to the centerline across successive sessions as a structural bias indicator. A POC consistently above the centerline across multiple regression windows suggests a persistent positive deviation tendency in the current trend phase.
- Mode Selection by Objective: Use Letters mode for structural time-at-price analysis analogous to conventional market profile. Use Heatmap mode to assess how distribution shifted over the regression period. Use Profile mode to quickly assess distribution shape and skew relative to the centerline.
- Regression Mode Discipline: Commit to a regression mode based on the instrument's observed trend curvature rather than switching between modes reactively. Polynomial mode adds a second degree of freedom that can overfit short-term noise if the lookback window is too short.
- Window Length Stability: Maintain a consistent regression length when using the POC and value area as ongoing structural references. Changing the length significantly shifts the curve and redistributes the profile, making successive POC comparisons unreliable.
Disclaimer
Regression Market Profile [BOSWaves] is a professional-grade regression-relative distribution and market profile analysis tool. It uses ordinary least squares curve fitting with deviation-based participation mapping but does not predict future price movements. Results depend on market conditions, instrument trend characteristics, parameter selection, and disciplined execution. BOSWaves recommends deploying this indicator within a broader analytical framework that incorporates order flow context, structural analysis, and comprehensive risk management.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.