Equilibrium Deviation Engine [LB]
Concept
The Equilibrium Deviation Engine is a session-resetting, volume-weighted equilibrium model that builds a dynamic fair value basis from accumulated price and volume since the last anchor point (daily by default). Around this basis, it constructs multiple deviation bands and an independent extreme contrarian channel whose width varies inversely with short-term volatility — expanding during quiet markets and contracting during turbulent ones.
Mathematical Foundation
At each new session (e.g., daily open), the engine resets three accumulators and recalculates them bar by bar :
PV = SUM(Price * Volume)
V = SUM(Volume)
P2V = SUM(Price^2 * Volume)
The equilibrium basis is the volume-weighted average price since reset :
Basis = PV / V
The standard deviation of price around this basis is derived from the variance :
Var = max( (P2V / V) - Basis^2 , 0 )
Dev = sqrt(Var)
Three main bands are then computed by applying adaptive multipliers to this deviation. The adaptation uses two independent weights :
TWAP Weight — compares the basis to a hidden TWAP. The larger the gap relative to the deviation, the more the bands widen, capturing potential mean-reversion targets.
HV Weight — compares current historical volatility (HV) to its own smoothed baseline. When HV expands, bands widen ; when HV contracts, bands narrow.
The final band width for level k is :
D_k = Dev * Mult_k * TWAP_Weight * HV_Weight
The Extreme Contrarian Channel
A separate channel is built using an inverse volatility weight. Instead of expanding with rising HV, it contracts :
InvWeight = clamp( 1 / (HV_contrarian / HV_contrarian_baseline) , min, max )
This creates a structural envelope that is widest during low-volatility regimes (where price tends to range) and tightens during high-volatility regimes (where price breaks through normal boundaries). The inner and outer levels use user-defined sigma multipliers.
What Problem Does It Solve ?
Traditional deviation bands (Bollinger, Keltner, VWAP bands) use fixed lookback windows and a single volatility metric. They do not reset at session boundaries, nor do they distinguish between different volatility regimes for mean-reversion versus breakout scenarios. The Equilibrium Deviation Engine solves this by :
- Resetting accumulators at each session (e.g., daily), producing a true volume-weighted equilibrium for the current period.
- Adapting band width to both the TWAP gap (directional drift) and HV regime (market excitement).
- Adding a separate contrarian channel using inverse volatility, specifically designed to identify exhaustion zones where low volatility precedes expansion, or where extreme HV signals climax conditions.
How To Interpret
Basis line (white) — the real-time volume-weighted fair value for the current session. Price above basis signals session bullishness ; price below signals session bearishness.
Deviation bands 1, 2, 3 — graduated zones of overextension from the basis. Price reaching Band 3 represents an extreme statistical deviation from the session's equilibrium, often preceding reversion.
Extreme contrarian channel — a separate envelope that behaves inversely to short-term HV. When this channel is wide (low HV, quiet market), price tends to oscillate within it, making the boundaries attractive mean-reversion levels. When the channel narrows sharply (high HV, excited market), it signals compression before a potential breakout.
Band expansion vs contraction — widening bands indicate increasing dispersion and adaptive uncertainty ; narrowing bands indicate consolidation and equilibrium tightening.
Parameters
LB Engine
Source — price field used for calculations (default HLC3).
Reset TF — timeframe at which accumulators reset (default Daily).
Hidden TWAP Length — period for the TWAP used in the TWAP gap weight.
Historical Volatility Length — period for HV calculation (main bands).
HV Smoothing — smoothing period for the HV baseline.
LB Bands
Deviation 1, 2, 3 — base multipliers for the three main deviation levels.
LB Contrarian Channel
Extreme Channel Inner/Outer — sigma multipliers for the contrarian channel.
Use Main HV Weight — applies the main HV weight to the contrarian channel.
Use Hidden TWAP Weight — applies the TWAP gap weight to the contrarian channel.
Contrarian Inverse HV Length — period for the HV used in the inverse weighting.
Contrarian Inverse HV Smooth — smoothing period for the contrarian HV baseline.
Contrarian Inverse HV Min/Max — clamping limits for the inverse weight.
LB Style
Show Basis, Show Main Fills, Color Bars — visual toggles.
Basis Width, Band Width, Extreme Channel Width — line thickness controls.
Reference
This indicator is a proprietary design by Luis Barlier. It synthesises concepts from session volume-weighted average price (VWAP), adaptive volatility bands, and inverse volatility regime detection. It does not correspond to a single academic publication.
Pine Script® 인디케이터






















