OPEN-SOURCE SCRIPT
Price Exhaustion Envelope [BackQuant]

Price Exhaustion Envelope [BackQuant]
Visual preview of the bands:
What it is
The Price Exhaustion Envelope (PEE) is a multi‑factor overextension detector wrapped inside a dynamic envelope framework. It measures how “tired” a move is by blending price stretch, volume surges, momentum and acceleration, plus optional RSI divergence. The result is a composite exhaustion score that drives both on‑chart signals and the adaptive width of three optional envelope bands around a smoothed baseline. When the score spikes above or below your chosen threshold, the script can flag exhaustion, paint candles, tint the background and fire alerts.
How it works under the hood
Exhaustion score
Price component: distance of close from its mean in standard deviation units.
Volume component: normalized volume pressure that highlights unusual participation.
Momentum component: rate of change and acceleration of price, scaled by their own volatility.
RSI divergence (optional): bullish and bearish divergences gently push the score lower or higher.
Mode control: choose Price, Volume, Momentum or Composite. Composite averages the main pieces for a balanced view.
Energy scale (0 to 100)
The composite score is pushed through a logistic transform to create an “energy” value. High energy (above 70 to 80) signals a move that may be running hot, while very low energy (below 20 to 30) points to exhaustion on the downside.
Envelope engine
Baseline: EMA of price over the main lookback length.
Width: base width is standard deviation times a multiplier.
Type selector:
• Static keeps the width fixed.
• Dynamic expands width in proportion to the absolute exhaustion score.
• Adaptive links width to the energy reading so bands breathe with market “heat.”
Smoothing: a short EMA on the width reduces jitter and keeps bands pleasant to trade around.
Band architecture
You can toggle up to three symmetric bands on each side of the baseline. They default to 1.0, 1.6 and 2.2 multiples of the smoothed width. Soft transparent fills create a layered thermograph of extension. The outermost band often maps to true blow‑off extremes.
On‑chart elements
Baseline line that flips color in real time depending on where price sits.
Up to three upper and lower bands with progressive opacity.
Triangle markers at fresh exhaustion triggers.
Tiny warning glyphs at extreme upper or lower breaches.
Optional bar coloring to visually tag exhausted candles.
Background halo when energy > 80 or < 20 for instant context.
A compact info table showing State, Score, Energy, Momentum score and where price sits inside the envelope (percent).
How to use it in trading
Mean reversion plays
When price pierces the outer band and an exhaustion marker prints, look for reversal candles or lower‑timeframe confirmation to fade the move back toward the baseline.
For conservative entries, wait for the composite score to roll back under the threshold or for energy to drop from extreme to neutral.
Set stops just beyond the extreme levels (use extreme_upper and extreme_lower as natural invalidation points). Targets can be the baseline or the opposite inner band.
Trend continuation with smart pullbacks
In strong trends, the first tag of Band 1 or Band 2 against the dominant direction often offers low‑risk continuation entries. Use energy readings: if energy is low on a pullback during an uptrend, a bounce is more likely.
Combine with RSI divergence: hidden bullish divergence near a lower band in an uptrend can be a powerful confirmation.
Breakout filtering
A breakout that occurs while the composite score is still moderate (not exhausted) has a higher chance of follow‑through. Skip signals when energy is already above 80 and price is punching the outer band, as the move may be late.
Watch env_position (Envelope %) in the table. Breakouts near 40 to 60 percent of the envelope are “healthy,” while those at 95 percent are stretched.
Scaling out and risk control
Use exhaustion alerts to trim positions into strength or weakness.
Trail stops just outside Band 2 or Band 3 to stay in trends while letting the envelope expand in volatile phases.
Multi‑timeframe confluence
Run the script on a higher timeframe to locate exhaustion context, then drill down to a lower timeframe for entries.
Opposite signals across timeframes (daily exhaustion vs. 5‑minute breakout) warn you to reduce size or tighten management.
Key inputs to experiment with
Alert set included
Hook these to TradingView notifications so you get pinged the moment a move hits exhaustion.
Best practices
Always pair exhaustion signals with structure. Support and resistance, liquidity pools and session opens matter.
Avoid blindly shorting every upper signal in a roaring bull market. Let the envelope type help you filter.
Use the table to sanity‑check: a very high score but mid‑range env_position means the band may still be wide enough to absorb more movement.
Backtest threshold combinations on your instrument. Different tickers carry different volatility fingerprints.
Final note
Price Exhaustion Envelope is a flexible framework, not a turnkey system. It excels as a context layer that tells you when the crowd is pressing too hard or when a move still has fuel. Combine it with sound execution tactics, risk limits and market awareness. Trade safe and let the envelope breathe with the market.
Visual preview of the bands:
What it is
The Price Exhaustion Envelope (PEE) is a multi‑factor overextension detector wrapped inside a dynamic envelope framework. It measures how “tired” a move is by blending price stretch, volume surges, momentum and acceleration, plus optional RSI divergence. The result is a composite exhaustion score that drives both on‑chart signals and the adaptive width of three optional envelope bands around a smoothed baseline. When the score spikes above or below your chosen threshold, the script can flag exhaustion, paint candles, tint the background and fire alerts.
How it works under the hood
Exhaustion score
Price component: distance of close from its mean in standard deviation units.
Volume component: normalized volume pressure that highlights unusual participation.
Momentum component: rate of change and acceleration of price, scaled by their own volatility.
RSI divergence (optional): bullish and bearish divergences gently push the score lower or higher.
Mode control: choose Price, Volume, Momentum or Composite. Composite averages the main pieces for a balanced view.
Energy scale (0 to 100)
The composite score is pushed through a logistic transform to create an “energy” value. High energy (above 70 to 80) signals a move that may be running hot, while very low energy (below 20 to 30) points to exhaustion on the downside.
Envelope engine
Baseline: EMA of price over the main lookback length.
Width: base width is standard deviation times a multiplier.
Type selector:
• Static keeps the width fixed.
• Dynamic expands width in proportion to the absolute exhaustion score.
• Adaptive links width to the energy reading so bands breathe with market “heat.”
Smoothing: a short EMA on the width reduces jitter and keeps bands pleasant to trade around.
Band architecture
You can toggle up to three symmetric bands on each side of the baseline. They default to 1.0, 1.6 and 2.2 multiples of the smoothed width. Soft transparent fills create a layered thermograph of extension. The outermost band often maps to true blow‑off extremes.
On‑chart elements
Baseline line that flips color in real time depending on where price sits.
Up to three upper and lower bands with progressive opacity.
Triangle markers at fresh exhaustion triggers.
Tiny warning glyphs at extreme upper or lower breaches.
Optional bar coloring to visually tag exhausted candles.
Background halo when energy > 80 or < 20 for instant context.
A compact info table showing State, Score, Energy, Momentum score and where price sits inside the envelope (percent).
How to use it in trading
Mean reversion plays
When price pierces the outer band and an exhaustion marker prints, look for reversal candles or lower‑timeframe confirmation to fade the move back toward the baseline.
For conservative entries, wait for the composite score to roll back under the threshold or for energy to drop from extreme to neutral.
Set stops just beyond the extreme levels (use extreme_upper and extreme_lower as natural invalidation points). Targets can be the baseline or the opposite inner band.
Trend continuation with smart pullbacks
In strong trends, the first tag of Band 1 or Band 2 against the dominant direction often offers low‑risk continuation entries. Use energy readings: if energy is low on a pullback during an uptrend, a bounce is more likely.
Combine with RSI divergence: hidden bullish divergence near a lower band in an uptrend can be a powerful confirmation.
Breakout filtering
A breakout that occurs while the composite score is still moderate (not exhausted) has a higher chance of follow‑through. Skip signals when energy is already above 80 and price is punching the outer band, as the move may be late.
Watch env_position (Envelope %) in the table. Breakouts near 40 to 60 percent of the envelope are “healthy,” while those at 95 percent are stretched.
Scaling out and risk control
Use exhaustion alerts to trim positions into strength or weakness.
Trail stops just outside Band 2 or Band 3 to stay in trends while letting the envelope expand in volatile phases.
Multi‑timeframe confluence
Run the script on a higher timeframe to locate exhaustion context, then drill down to a lower timeframe for entries.
Opposite signals across timeframes (daily exhaustion vs. 5‑minute breakout) warn you to reduce size or tighten management.
Key inputs to experiment with
- Lookback Period: larger values smooth the score and envelope, ideal for swing trading. Shorter values make it reactive for scalps.
- Exhaustion Threshold: raise above 2.0 in choppy assets to cut noise, drop to 1.5 for smooth FX pairs.
- Envelope Type: Dynamic is great for crypto spikes, Adaptive shines in stocks where volume and volatility wave together.
- RSI Divergence: turn off if you prefer a pure price/volume model or if divergence floods the score in your asset.
Alert set included
- Fresh upper exhaustion
- Fresh lower exhaustion
- Extreme upper breach
- Extreme lower breach
- RSI bearish divergence
- RSI bullish divergence
Hook these to TradingView notifications so you get pinged the moment a move hits exhaustion.
Best practices
Always pair exhaustion signals with structure. Support and resistance, liquidity pools and session opens matter.
Avoid blindly shorting every upper signal in a roaring bull market. Let the envelope type help you filter.
Use the table to sanity‑check: a very high score but mid‑range env_position means the band may still be wide enough to absorb more movement.
Backtest threshold combinations on your instrument. Different tickers carry different volatility fingerprints.
Final note
Price Exhaustion Envelope is a flexible framework, not a turnkey system. It excels as a context layer that tells you when the crowd is pressing too hard or when a move still has fuel. Combine it with sound execution tactics, risk limits and market awareness. Trade safe and let the envelope breathe with the market.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Check out whop.com/backquant for Access to Invite Only Scripts!
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Check out whop.com/backquant for Access to Invite Only Scripts!
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.