BTC Cost Basis Quantile Bands

2 196
BTC-CQB (Cost-Basis Quantile Bands) is a Bitcoin-only valuation and regime indicator. It estimates, bar by bar, a statistically-derived "fair value" band structure around Bitcoin's price by measuring how far price has historically deviated from its own rolling cost basis, and expressing that deviation as a live empirical probability distribution rather than as a fixed multiple of standard deviation. The result is five adaptive bands — Q10, Q25, Q50, Q75 and Q90 — that behave like percentile rails: Q50 is the statistical center of gravity (the cost basis itself), Q75 and Q90 mark the levels price has historically only traded above 25% and 10% of the time respectively, and Q25 and Q10 mark the symmetric levels on the downside. Everything else built into the script — the fast cost-basis overlay, the bandwidth squeeze detector, the divergence engine, the heat-map candle coloring, and the dashboard — exists to help a trader read what that distribution is doing right now, without needing to run the percentile math by hand.
スナップショット
スナップショット
This description explains, in detail, what the indicator measures, how each module is calculated, what every setting controls, how the pieces interact, what is original about the approach, and how to use it responsibly. It is written for traders who want to understand the statistical reasoning behind the tool, not just click a button and hope for the best.

WHY BITCOIN ONLY
The indicator is intentionally locked to Bitcoin pairs. If you try to load it on anything that is not a BTC base-currency pair — any altcoin, any index, any FX pair, any equity — it will refuse to calculate and show a runtime error instead of silently producing numbers that don't mean what they claim to mean. The quote/settlement currency is unrestricted: BTCUSD, BTCUSDT, BTCUSDC, BTCEUR, BTC perpetual futures on any exchange, and similar pairs will all work, because the statistical engine only cares about Bitcoin's price behaviour relative to itself, not about which fiat or stablecoin it is quoted against.

This restriction exists because cost-basis-style valuation bands are a lens that was originally built around a single, specific asset's supply and holder behaviour. Bitcoin has a known, disinflationary issuance schedule, a roughly four-year halving cycle, and a multi-year history of swinging between deep discounts to its own cost basis and extreme premiums above it — behaviour that is well documented across its trading history. Applying the exact same percentile thresholds, the same 4-hour minimum granularity, and the same "cycle" framing to an asset with a different supply schedule, different liquidity profile, or a much shorter trading history would produce numbers that look identical on the chart but mean something statistically different underneath. Rather than publish a generic tool and imply it works equally well everywhere, this script restricts itself to the one asset its internal assumptions were built and tuned around, and is explicit about that restriction in the Market Lock settings group.

The companion timeframe floor — a minimum of 4 hours, configurable in the Market Lock group but not removable below that point — exists for a related reason: the whole premise of a "cost basis" is a position that was entered and is being held through time. On intraday timeframes below 4 hours, the signal-to-noise ratio of that holding-horizon concept collapses into market microstructure noise (exchange-specific order flow, wick-hunting, funding-driven basis moves) that the percentile engine was not designed to filter.

WHAT PROBLEM THIS INDICATOR ACTUALLY SOLVES
A large family of Bitcoin valuation tools exists under names like "realized price," "aggregate cost basis," or "MVRV," and they are built from blockchain-level data: every UTXO's price at creation, weighted by the coins that moved on-chain. That data is powerful, but it has three practical limitations for a trading chart: it requires a paid or delayed external data feed, it updates slowly (once per block or once per day), and it cannot be computed purely inside Pine Script, because Pine Script only has access to OHLCV price and volume series, not blockchain UTXO data.

BTC-CQB takes a different, self-contained approach: instead of trying to reconstruct the on-chain cost basis directly, it builds a statistically analogous concept purely from price and volume. It defines a cost-basis proxy using a volume-sensitive moving average (by default, a VWMA), then measures the log-deviation of price from that proxy over a long rolling window, and finally computes the empirical percentiles of that distribution of deviations. Converting those percentiles back into price terms gives bands that behave, in practice, very similarly to a realized-price-style valuation band, but recompute live, every bar, from data that is available on every exchange and every BTC pair, with no external data dependency, no delay, and no paid data subscription. This is the core original contribution of the script: an exchange-agnostic, blockchain-data-free, empirical-quantile reconstruction of a cost-basis valuation framework, computed entirely from the price series Pine Script already has access to.

THE COST-BASIS ENGINE, STEP BY STEP
The engine starts with a source price series (Source Price input, default close) and a Cost Basis Type choice between SMA, EMA and VWMA. All three variants are computed every bar internally (this is a deliberate implementation detail to keep Pine's internal history tracking consistent across the three moving-average types; it does not change which one is displayed, only which one is calculated as a "live" option versus a "selected" option). The default, VWMA, weights each bar's contribution to the moving average by that bar's traded volume. This matters because it gives heavier influence to bars where a large amount of capital actually changed hands and less influence to quiet, low-volume drift — which is conceptually closer to a true aggregate cost basis (where what matters is how much money was actually committed at each price level) than a plain time-weighted average. SMA gives every bar equal weight regardless of volume or recency and is the most stable, slowest-reacting option. EMA weights recent bars exponentially more than older ones and reacts fastest to new trend information, at the cost of being more sensitive to short-term noise.

The length of this average is controlled by the Main Cost-Basis Lookback (Bars) input, defaulting to 155. Once this average (call it CB) is established, the script computes, for every bar, the natural-log deviation of price from it: dev = ln(close / CB). Using log-deviation rather than simple percentage deviation makes the distribution symmetric around zero regardless of whether Bitcoin's absolute price is $3,000 or $300,000 — a move from CB to 2×CB and a move from CB to 0.5×CB produce equal-and-opposite log-deviations, which is the correct way to compare "stretch above cost basis" to "stretch below cost basis" across Bitcoin's entire multi-order-of-magnitude trading history.

Every one of those log-deviation values is pushed into a rolling array sized by the Quantile Window (Bars) input (default 365). Once per bar, that array is copied, sorted, and its 10th, 25th, 50th, 75th and 90th percentiles are extracted using linear interpolation between the two nearest ranked observations — the standard, textbook method for computing a percentile from a finite empirical sample. Each percentile of log-deviation is then converted back into an actual price level by exponentiating it and multiplying by the current cost basis: band = CB × exp(percentile_of_dev). This round trip through log-space and back is what allows the bands to expand and contract honestly with Bitcoin's own historical dispersion, instead of assuming a fixed percentage width.

Two further processing steps are applied to the raw percentile bands before they are plotted. First, an optional ATR-based volatility floor (Enable ATR Volatility Floor, on by default) prevents the two extreme bands, Q90 and Q10, from collapsing to an unrealistically tight distance from Q50 during periods when the rolling percentile sample itself happens to be unusually compressed. It does this by enforcing a minimum half-width, in price terms, equal to the ATR (length set by ATR Length for Floor, default 14) multiplied by the ATR Floor Multiplier (default 1.0). If the raw statistical band would sit closer to Q50 than this floor allows, the floor value is used instead. Second, an optional light EMA smoothing pass (Band Smoothing, default 1) can be applied to the finished bands purely for visual stability; at its default value of 1 this smoothing is mathematically a no-op (an EMA with a length of 1 returns its own input unchanged), so out of the box you are looking at the pure, unaltered percentile mathematics with zero added lag.

An optional secondary average, the Fast Cost Basis (Enable Fast Cost-Basis Overlay, on by default, length set by Fast Cost-Basis Lookback (Bars), default 30), is computed using the same SMA/EMA/VWMA selection as the main cost basis but over a much shorter window. It is plotted as a white line and is also compared against the main cost basis on the dashboard: when the fast line sits above the main cost basis, it implies that, on average, more recent participants are paying a premium relative to the longer-run base — a simple, transparent proxy for short-term positioning strength that requires no additional indicator and uses the same underlying price data already being processed.

A note on the lookback units: the Main Cost-Basis Lookback, Fast Cost-Basis Lookback and Quantile Window are all specified in chart bars, not calendar days, because that is what the underlying Pine functions actually consume. On a Daily chart, a value of 365 is close to 365 real calendar days. On a 4-hour chart (the lowest timeframe the script allows), the same numeric value of 365 only covers about 61 real days, because six 4-hour bars make up one day. If you want the lookback values to always represent the same amount of real-world time regardless of which allowed timeframe you are viewing, turn on Auto-Scale Lookbacks to Calendar Days in the Cost Basis Engine group. With it off (the default), the script behaves exactly as a bar-counting tool; with it on, every lookback is automatically multiplied by the number of bars per day implied by your current chart timeframe, so a value of 365 always means 365 real days of price history, whichever allowed timeframe you are viewing it from.

THE BAND-POSITION SCORE
Separately from the five price-level bands themselves, the script computes a single normalized number between roughly 0 and 99.5 that expresses where the current close sits relative to the bands — this is what the dashboard calls the "Cost-Basis Quantile" score. Below Q10 it is scored on a scale that extrapolates below 10, between Q10 and Q25 it is scored between 10 and 25, between Q25 and Q50 between 25 and 50, between Q50 and Q75 between 50 and 75, between Q75 and Q90 between 75 and 90, and above Q90 it extrapolates above 90. This gives a single, continuously comparable oscillator-like reading that can be tracked over time, which is also what the divergence engine (explained below) is built on, instead of building divergence off the raw, non-stationary price series.
スナップショット
The dashboard turns this score into a plain-language Regime label: 90 and above is "EUPHORIA," 75 to 90 is "+Q75 OVERHEATED," 55 to 75 is "BULLISH," 40 to 55 is "NEUTRAL," 25 to 40 is "WEAK," and below 25 is "CAPITULATION." These labels are descriptive classifications of where price currently sits inside its own recent statistical history — they are not predictions, and a reading of EUPHORIA does not mean price cannot go higher, just as CAPITULATION does not mean price cannot go lower; it means price is statistically stretched relative to its own recent behaviour, which is a different and more modest claim.

THE BANDWIDTH SQUEEZE MODULE
Bandwidth is defined as (Q90 − Q10) / Q50, expressed as a percentage. This is the same core idea as a Bollinger Band-Width squeeze, applied here to the empirical quantile bands instead of a standard-deviation envelope. The script tracks the lowest bandwidth reading over a rolling window (Squeeze Lookback Window, default 100 bars) and flags the current bar as being inside a squeeze whenever its bandwidth sits within a configurable tolerance (Squeeze Sensitivity Threshold (%), default 5.0%) of that rolling minimum. In plain terms: when the distance between the euphoria band and the capitulation band compresses to close to its tightest point of the last 100 bars, the market's own recent dispersion is unusually low, which historically often precedes a period of expansion (the bands widening again as price moves more forcefully in one direction). The squeeze module does not predict direction — only that the current state of compression is unusual and historically tends to resolve into expansion. A squeeze-start event (the first bar a squeeze becomes active) can optionally trigger a background highlight (Highlight Squeeze Bars) and has its own alert condition.

THE QUANTILE MOMENTUM DIVERGENCE MODULE
This module applies the classic price/oscillator divergence concept to the band-position score described above, instead of to RSI, MACD, or stochastics. It uses standard pivot detection (Pivot Left Lookback and Pivot Right Lookback, defaults 5 and 3) to identify confirmed swing highs and swing lows in price. A bullish divergence is flagged when a new, confirmed swing low in price is lower than the previous confirmed swing low, while the band-position score at that same new low is higher than the band-position score was at the previous low — in other words, price pushed to a deeper low, but did so while sitting relatively less extreme inside its own statistical distribution than it did at the prior low, which is a classic loss-of-downside-momentum signature. A bearish divergence is the mirror case at swing highs. Because pivot confirmation requires price action that has already happened (a pivot can only be confirmed once the number of bars set by Pivot Right Lookback have passed), this module is structurally non-repainting: once a divergence prints, it will not later move or disappear, unlike oscillator divergences built on unconfirmed, still-forming swing points.
スナップショット
SIGNAL CONFIRMATION AND WHY IT MATTERS
Although the price bands themselves and the band-position score are, by necessity, live numbers that keep updating while the current bar is still forming (this is true of literally any moving average, percentile, or oscillator that is plotted on real-time bars — it is not unique to this script, and it is not something that can be "fixed" without simply not showing you the current bar's reading at all), the discrete, actionable events built on top of them — a cross above Q75, a cross below Q25, a tap into the Q90 euphoria zone or the Q10 capitulation zone, a squeeze starting, or a confirmed divergence — are a different matter, because these are the events a trader is most likely to treat as an entry trigger or an alert. For that reason, the Signal Confirmation & Alerts group includes a Wait for Bar Close Before Signals switch, on by default. With it on, every one of those discrete events additionally requires that the triggering bar be fully closed (technically, that Pine's barstate.isconfirmed flag be true) before the corresponding marker, label, or alert is allowed to fire. This guarantees that once you see a breakout marker, a euphoria tap, a squeeze-start highlight, or a divergence circle, that signal is permanent: it will never silently appear and then vanish again because price reversed before the candle closed. Turning the switch off restores the faster, intrabar-reactive behaviour, where a marker can appear while the bar is still forming and then disappear again if price moves back the other way before the close — useful for traders who specifically want the earliest possible intrabar notice and understand the trade-off, but off by default because the confirmed behaviour is the one consistent with a non-repainting signal.
スナップショット

It is スナップショット
worth being explicit about the scope of this switch: it governs the discrete event markers, labels and alerts only. The continuous heat-map candle coloring, the background tint, and the live dashboard figures (current price, current quantile score, current bandwidth) are always real-time, because they describe the current state of the market rather than asserting that a specific tradeable event has occurred. This separation between "live descriptive state" and "confirmed discrete signal" is a deliberate design choice, and understanding it is the single most important thing for using this indicator correctly: watch the live numbers to understand where you currently are, but only treat the confirmed markers and alerts as events.

THE VISUAL LAYER
Heat Candles recolor every bar's body, wick and border according to which of the four zones the close currently sits in relative to the bands: red at or above Q90, a darker red/orange between Q50 and Q90, green between Q10 and Q50, and bright green at or below Q10. This turns the ordinary candlestick chart into an immediate visual valuation map without needing to read the exact band values. Zone Shading fills the area between Q75 and Q90 (premium zone) and between Q10 and Q25 (discount zone) with a light color wash, and separately shades the entire Q25–Q75 range (the Value Zone) — the region where price has historically spent roughly half of its time — with its own soft highlight. Breakout Markers plot small triangles at a cross above Q75, a tap into the Q90 zone, and a cross below Q25; Breakout Labels and Divergence Labels provide the same information as explicit text for traders who prefer labels over shapes. All of these visual elements can be toggled independently, which matters because a cluttered chart defeats the purpose of a valuation tool meant to be read at a glance.
スナップショット
THE DASHBOARD
The on-chart table (toggle: Show Dashboard Table; position and text size independently configurable) condenses the entire indicator state into twelve rows: the current 0–99.5 quantile score with its colored regime background, the plain-language regime label, the live price, the current cost basis (labelled with whichever moving-average type is selected), the fast cost basis (colored to show whether it sits above or below the main cost basis), the current bandwidth percentage with a [SQUEEZE] tag appended when active, the most recent divergence and how many bars ago it occurred, the Q75 trigger price, the percentage distance remaining to that Q75 trigger, the Q90 euphoria price, how much of the Quantile Window's history is currently filled (and whether the statistics are therefore considered reliable yet — a genuinely useful honesty check, since percentile statistics computed from a half-full sample are less trustworthy than ones computed from a full one), and finally a highlighted "potential cycle target" range spanning Q75 to Q90, shown as a visual reference zone rather than a price prediction.
スナップショット
スナップショット
HOW TO USE IT IN PRACTICE
Because everything above is a statistical description of where price sits relative to its own recent behaviour, the indicator is best used as a context and timing layer around a trader's own thesis, not as a standalone entry-and-exit system. A few concrete usage patterns:

Cycle-position awareness: on the Daily or Weekly timeframe, watch the Regime label and the band-position score to understand whether Bitcoin currently sits in a historically stretched premium (EUPHORIA / +Q75 OVERHEATED) or a historically stretched discount (CAPITULATION / WEAK) relative to its own recent cost basis. This is a framework for sizing conviction and risk, not a mechanical buy/sell signal — a market can remain in EUPHORIA for an extended period during a strong trend, and a market can remain in CAPITULATION for an extended period during a prolonged decline.

Squeeze-to-expansion setups: when Highlight Squeeze Bars shows a sustained compression, and especially when that compression occurs with price sitting near the Value Zone (Q25–Q75) rather than at an extreme, a trader might watch for the eventual directional break out of that compression rather than fading it, consistent with how volatility compressions have historically behaved across many markets, not just Bitcoin.
スナップショット
Divergence as an early-warning layer: a confirmed bullish or bearish Quantile Momentum Divergence does not by itself constitute a trade signal, but it flags that the most recent price extreme was not accompanied by equivalent statistical stretch, which historically has preceded a number of meaningful reversals and is a reasonable input into tightening risk or looking for confirmation from price structure.

Fast-vs-main cost-basis cross as a short-term positioning read: watching whether the fast cost-basis line sits above or below the main cost basis, and whether it has recently crossed, gives a simple read on whether short-term participants are, on average, paying a premium or a discount to the longer-run base — useful as a secondary filter alongside the main bands rather than as a standalone trigger.

WHAT MAKES THIS INDICATOR ORIGINAL
The specific combination of techniques used here is not a repackaging of a single well-known public-domain indicator. It is an original synthesis of several distinct ideas, built specifically around Bitcoin's known cycle behaviour: (1) a volume-sensitive moving average used as a cost-basis proxy; (2) measuring deviation from that proxy in log-space so that premiums and discounts of equal magnitude are treated symmetrically across Bitcoin's full multi-order-of-magnitude price history; (3) estimating the full empirical distribution of that deviation via a rolling, sorted sample and genuine percentile interpolation — rather than assuming a Normal distribution and using a fixed standard-deviation multiple, as most banded indicators (Bollinger Bands, Keltner Channels, and their many derivatives) do; (4) converting those percentiles back into live, continuously updating price bands; (5) deriving a single normalized band-position score from those bands and running a dedicated pivot-based divergence detector against that score specifically, rather than against RSI, MACD or raw price; and (6) wrapping all of it in a bandwidth-squeeze detector and a cost-basis-pair comparison (fast versus main) that are purpose-built around the same percentile engine rather than bolted on from unrelated indicators. None of the individual mathematical building blocks (moving averages, ATR, pivot detection, percentiles) are novel in isolation — they are standard, publicly documented techniques — but the way they are assembled into a self-contained, blockchain-data-free reconstruction of a cost-basis valuation framework for a single, specific asset is the original contribution of this script, and is also the reason its source is protected: the specific weighting, log-transform, percentile-interpolation and floor-adjustment logic, together with how the bandwidth-squeeze and divergence modules are derived from the same underlying distribution rather than computed independently, is the proprietary part worth protecting, not the use of moving averages or percentiles as concepts, which are standard and freely available techniques.

LIMITATIONS AND DISCLAIMER
This script is a technical analysis and context tool. It does not access, and does not attempt to approximate, actual blockchain transaction data, exchange order-book depth, or any form of non-public information; everything it computes is derived solely from the OHLCV price and volume series supplied by your charting platform for the symbol you have selected. Percentile bands computed from a finite rolling sample are, by definition, descriptions of recent historical behaviour, not guarantees of future behaviour — Bitcoin's statistical distribution of deviation from its cost basis can and does shift across different market cycles, and a sample that includes only one kind of regime (e.g. a single multi-year bull run) will produce different thresholds than a sample that spans a full cycle including a bear market. The dashboard's "History" row is provided specifically so you can see, at a glance, how much of the configured Quantile Window is actually filled before placing weight on the percentile readings. Nothing in this script, its outputs, its labels (including "EUPHORIA," "CAPITULATION," or "POTENTIAL CYCLE TARGET"), or this description constitutes financial advice or a recommendation to buy or sell any asset; it is a decision-support tool, and all trading decisions and their outcomes remain the sole responsibility of the user.

SUITABLE MARKETS, TIMEFRAMES AND TRADING STYLE
The script is restricted, by design, to Bitcoin pairs against any quote or settlement currency on any exchange supported by your charting platform (spot and perpetual/futures markets alike), and to timeframes of 4 hours and above. Within that scope, it is built for swing trading and position-style trading and for longer-horizon macro cycle analysis of Bitcoin — contexts where a trader is reasoning in terms of days-to-months holding horizons and wants a statistically grounded read on whether current price is historically cheap, historically expensive, or inside its normal trading range relative to its own recent cost basis. It is not designed for, and the 4-hour minimum timeframe lock specifically prevents, scalping or very short-term intraday use, because the underlying premise — price's statistical relationship to a cost basis built up over a holding horizon of weeks to months — does not have a meaningful equivalent on 1-minute to 1-hour charts, where price action is dominated by short-term order flow rather than by the kind of holding-horizon dynamics this script is measuring.

A WORKED NUMERICAL WALKTHROUGH
It helps to see the math run once with concrete numbers rather than only in the abstract. Suppose the selected Cost Basis Type is VWMA with a 155-bar lookback, and on a given Daily bar the VWMA cost basis works out to 60,000 while the close is 78,000. The log-deviation for that bar is ln(78,000 / 60,000), which is ln(1.30), approximately 0.262. That single number — 0.262 — is pushed into the rolling array of the last 365 such log-deviation readings (assuming the Quantile Window default of 365 and no auto-scaling). Once the array is sorted, the script asks: what value sits at the 90th percentile of this sorted list of 365 log-deviations? Suppose that comes out to 0.300. Converting back into price terms, Q90 = CB × exp(0.300) = 60,000 × 1.3499 ≈ 80,994. If the 10th percentile of the same sorted list came out to −0.280, then Q10 = 60,000 × exp(−0.280) = 60,000 × 0.7558 ≈ 45,350. With Q50 (the median deviation, which in a reasonably symmetric sample will sit close to zero) at, say, 0.01, Q50 = 60,000 × exp(0.01) ≈ 60,603. Bandwidth in this example is (80,994 − 45,350) / 60,603 × 100 ≈ 58.8%. If, two weeks later, the same calculation produced a bandwidth of 31%, approaching the lowest reading of the last 100 bars, the squeeze detector would flag that compression, because the gap between the euphoria and capitulation rails has visibly tightened relative to its own recent range — not because any fixed numeric threshold like "30%" was hard-coded anywhere in the script.

This example also illustrates why the percentile approach behaves differently from a fixed-width band. A classic Bollinger Band assumes the underlying deviations are approximately Normally distributed and sets its width as a multiple of one standard deviation; two assets, or the same asset in two different volatility regimes, that happen to share the same standard deviation will get identically shaped bands even if their actual historical distribution of outcomes is skewed or fat-tailed. The percentile approach used here makes no assumption about the shape of the distribution at all — it simply asks the data directly "where did the most extreme 10% and 25% of outcomes actually fall, historically, within this window," which is a more honest description of an asset like Bitcoin whose distribution of deviations from its own cost basis has historically been asymmetric (sharper, faster moves to the downside during capitulation events than the equivalent move during the build-up phase of a rally) rather than a clean bell curve.

READING THE BANDS TOGETHER: FOUR ILLUSTRATIVE SCENARIOS
Scenario one — statistically cheap with early stabilization. Price is trading below Q25 (the discount band), the Regime label on the dashboard reads WEAK or CAPITULATION, the heat candles are green to bright green, and the bandwidth has been contracting for a number of bars without yet triggering a squeeze flag. In this scenario, a trader watching for a mean-reversion-style long setup would typically wait for one of two confirming events rather than buying the discount in isolation: either a confirmed Bullish Quantile Divergence (price making a deeper low while the band-position score does not confirm it), or a confirmed cross back above the fast cost-basis line, both of which are explicit, loggable events with their own alert conditions rather than subjective chart reading.

Scenario two — statistically expensive with momentum still intact. Price is above Q75, the Regime label reads +Q75 OVERHEATED or EUPHORIA, heat candles are red, and the fast cost-basis line sits comfortably above the main cost basis with no bearish divergence present. This is a context in which a trader already holding a position might use the "To +Q75" and Q90 Euphoria dashboard rows to gauge how much further price is from the next statistical extreme, rather than assuming the overheated reading by itself calls for an immediate exit — Bitcoin's own multi-year trading history includes extended stretches where price continued higher for weeks or months after first touching the Q75 band.

Scenario three — a squeeze resolving while price sits inside the Value Zone. Highlight Squeeze Bars shows sustained yellow background, the bandwidth row carries the [SQUEEZE] tag, and price is between Q25 and Q75 rather than at either extreme. This is the textbook volatility-contraction-before-expansion setup: the trader does not know in advance which direction the eventual expansion will favor, so the squeeze flag by itself is a "pay attention" signal, not a directional one; direction is typically read from which band price actually breaks through once the expansion begins (a confirmed cross above Q75 versus a confirmed cross below Q25).

Scenario four — divergence at a statistical extreme. Price taps the Q90 euphoria band, triggering the Euphoria Zone Tapped alert, and shortly afterward a confirmed Bearish Quantile Divergence prints at a subsequent, slightly higher price pivot where the band-position score was, in fact, lower than at the prior high. This combination — a prior statistical extreme followed by a confirmed loss-of-momentum divergence — is the single strongest multi-module confluence the indicator can produce, because it combines three independently computed pieces of evidence (the extreme-zone tap, the band-position score's own divergence, and the pivot-confirmed price structure) rather than relying on any one of them in isolation.

FREQUENTLY MISUNDERSTOOD POINTS
"The bands moved after I saw them — is this repainting?" The five percentile bands, the band-position score, the bandwidth reading, and every dashboard number are intentionally live: they are recalculated on every price update of the currently forming bar, exactly the same way any moving average, RSI, or Bollinger Band recalculates on an unclosed bar. This is standard, expected behaviour for any indicator that reports a "current value," and it is not what the term repainting refers to in the sense that matters for compliance: repainting, properly defined, is when a script's historical plots change retroactively after bars have already closed, or when a signal is shown as having fired in the past at a time it could not actually have been detected in real time. Neither of those things happens here. Once a bar closes, its percentile band values, its band-position score, and any signal computed from it are permanent and will never change again on a bar reload or chart refresh. The discrete signals — breakouts, taps, squeeze starts, divergences — additionally respect the Wait for Bar Close switch described earlier, so that even the appearance of those specific markers is deferred until their triggering bar is closed when that switch is on, removing the one place where intrabar fluctuation could otherwise cause a marker to flicker on and off before settling.

"Why does the dashboard say WARMING UP?" The percentile engine needs a full Quantile Window of historical deviation samples before its percentile estimates are drawn from a complete, as-configured sample size. If you load the script on a symbol or timeframe combination with less chart history available than the configured Quantile Window, the History row will show how many samples are currently available out of the target and will flag WARMING UP rather than READY. The bands will still plot during this period, computed from whatever sample is available, but with a visibly smaller, less statistically mature sample behind them, and you should weight them accordingly until the row reads READY.

"Why does this look similar to Bollinger Bands but behave differently at the extremes?" Both approaches produce an envelope around a central line, which is why they look superficially similar, but a Bollinger Band's width is a fixed multiple of the standard deviation of price around its moving average, which implicitly assumes outcomes are symmetric and roughly Normally distributed. This indicator does not make that assumption: by sorting the actual historical log-deviations and reading off the empirical 10th, 25th, 75th and 90th percentiles directly, it lets the data itself define the width and the skew, which is the more statistically appropriate choice for an asset like Bitcoin that has historically shown asymmetric, fat-tailed behaviour rather than clean, symmetric dispersion.

SETTINGS QUICK REFERENCE BY GROUP
Group 0, Market Lock, contains the single Minimum Allowed Timeframe input and the underlying symbol/timeframe validation logic; it exists purely to enforce the Bitcoin-only, 4-hour-minimum scope explained above and is not intended for routine adjustment.

Group 1, Cost Basis Engine, is where the core statistical model is configured: the source price series, the choice of SMA/EMA/VWMA for the cost-basis proxy, the main and fast lookback lengths, the size of the rolling quantile sample, the optional smoothing pass, and the optional calendar-day auto-scaling switch. These are the settings most likely to meaningfully change the character of the bands, and conservative, infrequent adjustment is recommended over frequent re-tuning, since the whole point of a percentile-based model is to describe a stable, representative historical sample rather than to be curve-fit to recent price action.

Group 2, Volatility & Bandwidth Squeeze, governs how tightly the script watches for compression in the gap between the euphoria and capitulation bands, including the rolling comparison window, the sensitivity threshold, the optional background highlight, and the optional ATR-based floor that stops the extreme bands from becoming unrealistically narrow during abnormally quiet stretches.

Group 3, Quantile Momentum Divergence, governs the pivot-based divergence detector built on top of the band-position score: whether it is active at all, and how far left and right a swing point must look before it is accepted as a confirmed pivot.

Group 4, Signal Confirmation & Alerts, contains the single Wait for Bar Close Before Signals switch that determines whether discrete events require a fully closed bar before they are allowed to fire, as explained in detail above; this is also where you will find and configure the seven available alertcondition triggers once you open TradingView's native Create Alert dialog.

Group 5, Visuals & Display, contains every purely cosmetic toggle: which of the five bands are drawn, whether the fast cost-basis line is shown, whether the premium/discount/value zones are shaded, whether candles are recolored by valuation zone, whether a background tint reinforces the current zone, and whether breakout and divergence events are shown as small shapes, explicit text labels, or both.

Group 6, Dashboard Table, contains the three controls for the on-chart summary panel: whether it is shown at all, which corner of the chart it is anchored to, and its text size.

CLOSING NOTE ON SCOPE
Everything described in this publication reflects exactly what is computed inside the script: a self-contained, OHLCV-only reconstruction of a cost-basis valuation framework for Bitcoin, expressed as live empirical percentile bands, with a bandwidth squeeze detector and a pivot-confirmed divergence detector built on top of the same underlying distribution, and a signal-confirmation layer that lets you choose between the fastest possible intrabar notice and a strictly non-repainting, bar-close-confirmed notice for every discrete event. No part of the script connects to external data sources, blockchain explorers, or paid data feeds; everything you see updates from the same price and volume series your chart is already displaying.

This is a tool for reading context, not a signal generator to be followed blindly. Used as intended — on Bitcoin, on 4-hour and higher timeframes, by traders and investors reasoning in days-to-months horizons — it gives a statistically grounded, continuously updating answer to one specific question: relative to its own recent cost basis, is Bitcoin currently cheap, expensive, or somewhere in between, and how confident should that read be given how much history currently backs it. Everything else in the script exists to make that one answer easier to see, verify, and act on with discipline.

SUMMARY OF ALERTS
Seven alert conditions are available from the TradingView Create Alert dialog once the script is on your chart: Price Crossed Above Q75, Price Crossed Below Q25, Euphoria Zone Tapped, Capitulation Zone Tapped, Bandwidth Squeeze Started, Bullish Quantile Divergence, and Bearish Quantile Divergence. All seven respect the Wait for Bar Close Before Signals switch described above, so when that switch is on (the default), none of these alerts can fire until their triggering bar has fully closed.

免責事項

これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。