Return Distribution Drift Monitor [Pineify]

Return Distribution Drift Monitor [Pineify]
Overview
Compare recent log returns with a separate, older block. A center track, scale envelope and tail balance distinguish directional distribution shift from widening dispersion. These describe relative drift, not the next price move.
Problem Definition
A fixed z-score treats its reference center and scale as suitable for the current observations. Yet returns can move toward one tail or spread in both directions while that reference remains stale. A large individual return cannot tell these cases apart. The question is whether recent returns differ from an earlier block and whether that difference persists.
Design Rationale
The windows do not overlap, so recent returns cannot immediately dilute their own reference. Medians and median absolute deviations reduce dependence on a single extreme observation, at the cost of slower response to sparse shocks. Tail shares add evidence about where observations moved; a center threshold alone is rejected because it ignores shape. Finite memory and consecutive confirmation reduce brief state changes but add delay. These are effect thresholds, not significance tests or optimized defaults.
Key Features
How It Works
Each return is log(current close / previous close), requiring positive closes. Defaults compare the latest 24 returns with the 120 immediately before them. Each block gets a median, MAD and interpolated 20th/80th percentiles. Scale is the larger of 1.4826 times MAD and a 0.1 basis-point floor. Center effect C is the median difference divided by prior scale; scale effect D is recent/prior scale minus one.
Both blocks are counted strictly beyond the prior tail boundaries. Recent minus prior upper share gives U; the lower difference gives L. Tail balance T=U-L, while total excess E=U+L. Upward evidence needs C>=0.5 and T>=0.1; downward evidence mirrors these signs. Expansion needs D>=0.5 and E>=0.1. Direction has priority when both qualify. Quiet means absolute C, D, T and E are within half their entry thresholds.
A five-close memory needs 60% matching evidence and two consecutive candidate closes. Other cases are mixed/unconfirmed. After confirmed drift, quiet closes enter recalibrating; five quiet closes, quiet-memory support and candidate confirmation return to balanced. This ends the episode. Missing slots, nonstandard charts or equal prior tail boundaries clear memory on close. Complete windows and fresh memory must rebuild; coverage is not statistical confidence.
How Multiple Indicators Work Together
The median supplies location, MAD supplies a common scale, and prior-tail counts test the shape of the same return samples. Memory asks whether that joint evidence persists. Without tails, a center change loses its distribution context; without robust scale, effects cannot be compared. No external indicator is embedded.
Trading Ideas and Insights
An upward drift means recent returns moved higher relative to the prior block; it does not mean price must rise next. A scale-expansion state instead indicates broader dispersion with excess tail occupancy. Use either as context for reviewing assumptions behind an existing setup. A recalibration marker invites a fresh review of the baseline rather than an automatic reversal or entry.
Unique Aspects
Compared with a single rolling z-score, this implementation separates nonoverlapping samples and requires agreement between center or scale effects and empirical tail changes. An episode latch survives mixed evidence to track later convergence. Medians, MAD and quantiles are common methods; the contribution is the constrained evidence flow and finite state model.
How to Use
Apply to standard candles on a liquid symbol, preferably 15m to 1W, and allow both windows plus evidence memory to mature. Read the signed center track first, then the scale envelope and tail columns. D triangles mark directional entries, S diamonds expansion, and R circles completed relative recalibration. Use close alerts; inspect raw effects if clipped.
Customization
Adjust recent and prior lengths to change responsiveness and reference age. Tail percentile changes the boundaries; the basis-point floor controls near-flat scale sensitivity. Center, scale and tail gates set required effects. Memory length, required share, candidate closes and quiet closes set persistence and delay. Hide secondary layers as needed. Defaults are starting points.
Assumptions and Limitations
The center display clips at +/-4; envelope half-width is abs(D), capped at 2; columns show 2*T. Raw values remain in the Data Window. The envelope is not a forecast. Live metrics can change intrabar; memory, states and alerts update only on close. Overlapping successive windows remain dependent. Floors and tied returns affect sensitivity; rolling reference turnover can produce convergence without a lasting new regime. Missing bars are not synthesized. No volume, future data, trade execution or profitability estimate is used.
Conclusion
The monitor compares location, dispersion and tails in one frame. States describe persistent differences and relative convergence; direction forecasts and trading decisions remain outside the model.
Overview
Compare recent log returns with a separate, older block. A center track, scale envelope and tail balance distinguish directional distribution shift from widening dispersion. These describe relative drift, not the next price move.
Problem Definition
A fixed z-score treats its reference center and scale as suitable for the current observations. Yet returns can move toward one tail or spread in both directions while that reference remains stale. A large individual return cannot tell these cases apart. The question is whether recent returns differ from an earlier block and whether that difference persists.
Design Rationale
The windows do not overlap, so recent returns cannot immediately dilute their own reference. Medians and median absolute deviations reduce dependence on a single extreme observation, at the cost of slower response to sparse shocks. Tail shares add evidence about where observations moved; a center threshold alone is rejected because it ignores shape. Finite memory and consecutive confirmation reduce brief state changes but add delay. These are effect thresholds, not significance tests or optimized defaults.
Key Features
- Signed center shift in prior robust-scale units.
- Amber scale expansion or purple contraction envelope.
- Tail balance columns and raw quantile diagnostics.
- Closed-bar drift states, relative recalibration and three alert conditions.
How It Works
Each return is log(current close / previous close), requiring positive closes. Defaults compare the latest 24 returns with the 120 immediately before them. Each block gets a median, MAD and interpolated 20th/80th percentiles. Scale is the larger of 1.4826 times MAD and a 0.1 basis-point floor. Center effect C is the median difference divided by prior scale; scale effect D is recent/prior scale minus one.
Both blocks are counted strictly beyond the prior tail boundaries. Recent minus prior upper share gives U; the lower difference gives L. Tail balance T=U-L, while total excess E=U+L. Upward evidence needs C>=0.5 and T>=0.1; downward evidence mirrors these signs. Expansion needs D>=0.5 and E>=0.1. Direction has priority when both qualify. Quiet means absolute C, D, T and E are within half their entry thresholds.
A five-close memory needs 60% matching evidence and two consecutive candidate closes. Other cases are mixed/unconfirmed. After confirmed drift, quiet closes enter recalibrating; five quiet closes, quiet-memory support and candidate confirmation return to balanced. This ends the episode. Missing slots, nonstandard charts or equal prior tail boundaries clear memory on close. Complete windows and fresh memory must rebuild; coverage is not statistical confidence.
How Multiple Indicators Work Together
The median supplies location, MAD supplies a common scale, and prior-tail counts test the shape of the same return samples. Memory asks whether that joint evidence persists. Without tails, a center change loses its distribution context; without robust scale, effects cannot be compared. No external indicator is embedded.
Trading Ideas and Insights
An upward drift means recent returns moved higher relative to the prior block; it does not mean price must rise next. A scale-expansion state instead indicates broader dispersion with excess tail occupancy. Use either as context for reviewing assumptions behind an existing setup. A recalibration marker invites a fresh review of the baseline rather than an automatic reversal or entry.
Unique Aspects
Compared with a single rolling z-score, this implementation separates nonoverlapping samples and requires agreement between center or scale effects and empirical tail changes. An episode latch survives mixed evidence to track later convergence. Medians, MAD and quantiles are common methods; the contribution is the constrained evidence flow and finite state model.
How to Use
Apply to standard candles on a liquid symbol, preferably 15m to 1W, and allow both windows plus evidence memory to mature. Read the signed center track first, then the scale envelope and tail columns. D triangles mark directional entries, S diamonds expansion, and R circles completed relative recalibration. Use close alerts; inspect raw effects if clipped.
Customization
Adjust recent and prior lengths to change responsiveness and reference age. Tail percentile changes the boundaries; the basis-point floor controls near-flat scale sensitivity. Center, scale and tail gates set required effects. Memory length, required share, candidate closes and quiet closes set persistence and delay. Hide secondary layers as needed. Defaults are starting points.
Assumptions and Limitations
The center display clips at +/-4; envelope half-width is abs(D), capped at 2; columns show 2*T. Raw values remain in the Data Window. The envelope is not a forecast. Live metrics can change intrabar; memory, states and alerts update only on close. Overlapping successive windows remain dependent. Floors and tied returns affect sensitivity; rolling reference turnover can produce convergence without a lasting new regime. Missing bars are not synthesized. No volume, future data, trade execution or profitability estimate is used.
Conclusion
The monitor compares location, dispersion and tails in one frame. States describe persistent differences and relative convergence; direction forecasts and trading decisions remain outside the model.
🚀🚀🚀 Pineify - pineify.app
Essential Toolkit for Every Trader
- AI Pine Script Generator
- Finance AI Agent
- AI Stock Picker
- Pine Script Visual Editor
- Invited indicators
- Strategy Optimizer
- Trading Journal
- Backtest Report
Essential Toolkit for Every Trader
- AI Pine Script Generator
- Finance AI Agent
- AI Stock Picker
- Pine Script Visual Editor
- Invited indicators
- Strategy Optimizer
- Trading Journal
- Backtest Report
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.
🚀🚀🚀 Pineify - pineify.app
Essential Toolkit for Every Trader
- AI Pine Script Generator
- Finance AI Agent
- AI Stock Picker
- Pine Script Visual Editor
- Invited indicators
- Strategy Optimizer
- Trading Journal
- Backtest Report
Essential Toolkit for Every Trader
- AI Pine Script Generator
- Finance AI Agent
- AI Stock Picker
- Pine Script Visual Editor
- Invited indicators
- Strategy Optimizer
- Trading Journal
- Backtest Report
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.