OPEN-SOURCE SCRIPT

Long-Term VWAP Mean Reversion SDCA

274
Core Idea:

This indicator is designed to support Strategic Dollar Cost Averaging (SDCA) for Bitcoin using a cumulative VWAP-based mean reversion model. It helps long-term investors identify high-conviction buy zones and overbought conditions using statistical deviation from the cumulative VWAP. This indicator evaluates how much price is stretched from the true market average price, weighted by cumulative volume over time.

Core Concepts and Formulas:

Cumulative VWAP (Volume Weighted Average Price):

VWAPcumulative = ∑(Price×Volume) / ∑Volume
A long-term anchor that reflects the average dollar cost of all market participants across all candles. This version does not reset daily, unlike intraday VWAP.

VWAP Deviation %:

Deviation% = Price - VWAPcumulative / VWAPcumulative x 100
Shows how far current price has diverged from the long-term fair value.

Z-Score of VWAP Deviation:

Z= (Price−VWAP)−μ / σ (lookback period: default 200)


SDCA Multiplier Mapping:

*Keep in mind in my Z-Score system, -2 represents the overbought level (white horizontal line) and +2 represents oversold (cyan horizontal line) conditions. So the scores on the Y axis and Z-score in the table are reversed.

| Z-Score Range | SDCA Multiplier |
---------------------------------------------
| ≤ -2 | 0.25×
| -1 to +1 | 1.0×
| > +2 | 2.0×

The pink line plots this multiplier. It’s meant to control buy weight at each time step.

How to Use This for SDCA:

-Buy normally when the multiplier is 1.0× (Z-score between -1 and +1)
-Accelerate buying when Z-score is deeply negative (price far below VWAP)
-Slow or pause buying when Z-score is high (price far above VWAP)
-Use the stats panel to track current Z-score, VWAP level, deviation %, and multiplier
-Watch the red/blue backgrounds as visual confirmation of oversold/overbought zones

Inputs:

Z-Score Lookback Length:

Default: 200 but can be adjusted.


Visuals:

Z-Score Line (cyan): shows current standardized deviation from VWAP


Multiplier Line (bright pink): your SDCA intensity signal


Background Zones: cyan = oversold, white = overbought


Horizontal Lines: +2 and -2 standard deviation thresholds


Stats Panel (bottom right): live values for Z-score, multiplier, price, VWAP, and the deviation formula



Suited For:

-Long-term Bitcoin investors
-SDCA Systems
-Mean reversion systems
-Macro-level buy/sell planning

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.