PROTECTED SOURCE SCRIPT
Mass on Spring - Reversal Signals

Mass on Spring - Universal MA Edition
A comprehensive physics-based trading system combining classical mechanics (mass-spring-damper dynamics) with a variety of moving average algorithms, featuring dual-confirmation logic and Fibonacci-optimized parameters.
Overview
The Mass on Spring indicator revolutionizes mean-reversion analysis by modeling price action as a physical oscillator. Price is treated as a "mass" connected to an "equilibrium" point (moving average) via a spring. When price stretches too far (extreme potential energy) and begins returning (velocity crossover) with sufficient force (acceleration) while maintaining statistical correlation, high-probability reversal signals trigger. This "Universal MA Edition" allows independent selection of 55 different moving average types for each equilibrium calculation, creating unprecedented flexibility in defining market equilibrium.
Key Features
Moving Average Library Reference
Section 1: Built-in & Common
Section 2: Compounded & Zero-Lag
Section 3: FIR / Weighted Sum
Section 4: Adaptive & Recursive (IIR)
Section 5: Volume-Based
How It Works
1. Equilibrium Selection
Independently select MA types for four equilibrium calculations:
2. Physics Calculations
For each of the four MAs:
3. Signal Confirmation
LONG requires ALL:
SHORT requires ALL:
Settings Guide
Visual Interpretation
This indicator excels in ranging markets where price oscillates around equilibrium, but includes correlation filters to avoid false signals during strong trends when price decouples from its moving averages. For trending markets, select adaptive MAs (KAMA, FRAMA, ALBMA) that self-adjust to volatility. For pure mean reversion in stable ranges, use HMA, ALMA, or Gaussian MAs for optimal smoothness. The McGinley and Kalman Filter options provide institutional-grade tracking for algorithmic execution benchmarks.
SWMA_ Sine

VTWAP & Median

Parabolic & CMA_Corr w/1.618 threshold

A comprehensive physics-based trading system combining classical mechanics (mass-spring-damper dynamics) with a variety of moving average algorithms, featuring dual-confirmation logic and Fibonacci-optimized parameters.
Overview
The Mass on Spring indicator revolutionizes mean-reversion analysis by modeling price action as a physical oscillator. Price is treated as a "mass" connected to an "equilibrium" point (moving average) via a spring. When price stretches too far (extreme potential energy) and begins returning (velocity crossover) with sufficient force (acceleration) while maintaining statistical correlation, high-probability reversal signals trigger. This "Universal MA Edition" allows independent selection of 55 different moving average types for each equilibrium calculation, creating unprecedented flexibility in defining market equilibrium.
Key Features
- []Comprehensive MA Library: Choose from 55 distinct algorithms spanning classical, adaptive, volume-weighted, and specialized filters
[]Dual Independent Sets: Two complete calculation engines for Longs (Primary + Secondary) and Shorts (Primary + Secondary), all requiring simultaneous confirmation
[]Physics-Based Signal Logic: Four-factor confirmation required: Extreme Displacement, Velocity Reversal, Force Confirmation, and Correlation Filter
[]Pure Mathematical Implementation: Zero built-in function dependencies for core calculations—custom implementations of SMA, Standard Deviation, Pearson Correlation, and Percentile Rank
[]Fibonacci Optimization: Default lengths utilize golden ratio sequence (144, 89, 55, 34, 13, 8) for natural market resonance
[]Real-Time Diagnostics: On-chart labels display active MA types, correlation status (✓/✗), and energy percentiles
Moving Average Library Reference
Section 1: Built-in & Common
- []SMA (Simple Moving Average): Arithmetic mean of price over N periods. The standard benchmark—equal weight to all data points. Best for basic support/resistance in stable markets.
[]EMA (Exponential Moving Average): Weighted average giving higher importance to recent prices via exponential decay. More responsive than SMA while maintaining smoothness. Ideal for trending markets.
[]WMA (Weighted Moving Average): Linearly weighted average where recent bars have proportionally higher weight (N, N-1, N-2...). Faster than EMA at detecting turns but more noise-sensitive.
[]RMA (Running/Modified Moving Average): Infinite impulse response filter with equal weighting. Used in RSI calculations—smooth but lags significantly. Good for long-term bias.
[]VWMA (Volume Weighted MA): Price weighted by volume, emphasizing periods with high participation. Excellent for identifying true consensus levels where volume transacted.
[]HMA (Hull Moving Average): Weighted average of two WMAs with square root of period offset. Nearly eliminates lag while maintaining smoothness. Superior for fast-moving markets.
[]ALMA (Arnaud Legoux MA): Gaussian-weighted FIR filter with adjustable offset and sigma. Combines smoothness and responsiveness via Gaussian distribution weights. Offset 0.85 tracks price closely.
[]LSMA (Least Squares MA): Linear regression endpoint projection. Projects where price should be based on linear trend—excellent for identifying trend exhaustion when price deviates significantly.
[]Median: Middle value of sorted price array over N periods. Robust outlier filter that ignores extreme spikes. Best for noisy, whipsaw markets where mean is distorted by outliers.
[]FIBMA (Fibonacci Weighted MA): WMA variant using Fibonacci sequence weights. Emphasizes recent data with natural growth ratios—balanced between EMA responsiveness and SMA stability.
Section 2: Compounded & Zero-Lag
- []DEMA (Double EMA): 2×EMA - EMA(EMA). Reduces lag of standard EMA by compensating for cumulative delay. Faster signals than EMA but prone to whipsaws in choppy markets.
[]TEMA (Triple EMA): 3×EMA - 3×EMA(EMA) + EMA(EMA(EMA)). Further lag reduction with added smoothing. Best for short-term trend detection in volatile instruments.
[]T3 (Tillson T3): Six-pole EMA filter with volume factor (vFactor). Extremely smooth with minimal lag—"the better moving average." vFactor 0.7 balances smoothness vs responsiveness.
[]EHMA (Enhanced HMA): EMA applied to Hull MA. Double-smoothing technique that filters HMA noise while maintaining its lag-free characteristics.
[]ZLEMA (Zero Lag EMA): EMA applied to (Price + Price - Price[lag]). Eliminates delay by adding momentum term. Instant response to direction changes but amplifies noise.
[]ZLHMA (Zero Lag HMA): Hull MA applied to zero-lag adjusted data. Combines Hull's smoothing with zero-lag momentum injection.
[]DWMA (Double WMA): WMA of WMA. Extra smoothing layer for weighted averages—slower than single WMA but filters false breakouts better.
[]DSWMA (Double Smoothed WMA): RMA of RMA using Wilder's smoothing. Very heavy smoothing for long-term bias determination. - EMM (EMA of Median): Applies exponential smoothing to median values. Combines outlier resistance of median with EMA responsiveness.
Section 3: FIR / Weighted Sum
- []SWMA_Sine (Sine-Weighted MA): Weights follow sine curve distribution (bell-shaped). Natural window function reducing spectral leakage—excellent for cyclical analysis.
[]PWMA_Parabolic (Parabolic Weighted MA): Weights increase quadratically (i²) toward present. Aggressive recent-price emphasis for scalping and fast reversals.
[]GaussMA (Gaussian MA): Weights follow Gaussian (normal) distribution curve. Mathematically optimal for noise reduction while preserving edge sharpness.
[]NLMA (Non-Linear MA): Power-law weighted average (adjustable power). >1.0 emphasizes recent data more than WMA; <1.0 flattens response for stability.
[]CGMA (Center of Gravity MA): Linearly increasing weights (1, 2, 3...N). The "center of gravity" of prices over window—leads price slightly, good for early entries.
[]FSMA (Fourier Series MA): Projects price using Fourier series harmonics. Decomposes price into sine/cosine components and reconstructs trend—filters noise via spectral analysis.
Section 4: Adaptive & Recursive (IIR)
- []ITL (Integrated Trendline): Two-pole IIR filter with 0.07 alpha. Very smooth trend follower that ignores minor corrections—best for position trading.
[]McGinley: Self-adjusting average that speeds up when price separates and slows when close. Formula: Prior MA + (Price - Prior MA) / (N × (Price/Prior MA)⁴). Minimizes whipsaws.
[]VIDYA (Variable Index Dynamic Average): Volatility-adjusted EMA where smoothing constant = Standard Deviation / Sum(StdDev). Tightens in low volatility, expands in high volatility.
[]KAMA (Kaufman Adaptive MA): Adjusts smoothing based on Efficiency Ratio (direction/volatility). Fast during trends (ER→1), slow during chops (ER→0). The gold standard for adaptive MAs.
[]GMA_Geo (Geometric MA): EMA of log-prices, exponentiated back. Measures geometric mean—better for percentage-based assets (crypto, forex) than arithmetic averages.
[]Super_Smoother: Two-pole Butterworth filter removing aliasing noise above Nyquist frequency. Mathematically superior smoothing for cycle analysis—no overshoots.
[]Laguerre: Four-phase gamma filter (0-1). Orthogonal polynomial expansion that distorts time to emphasize recent data. Gamma 0.5 is balanced; higher = more responsive.
[]Laguerre_A (Adaptive Laguerre): Auto-adjusts gamma based on length (2/(N+1)). Converts Laguerre to adaptive framework matching EMA time constants.
[]Decycler: High-pass filter removing low-frequency (trend) components. Shows cyclical components only—useful for detrending price to see oscillations.
[]DCFMA (Decycler Filter MA): Smoothed decycler output. Trend-extracted signal with additional noise filtering.
[]FRAMA (Fractal Adaptive MA): Adjusts alpha based on Fractal Dimension (roughness). Smooth when price is noisy (high dimension), fast when trending (low dimension).
[]ARMA_A (Adaptive ARMA): Volatility ratio-adjusted smoothing. Uses highest/lowest volatility ratio to modulate EMA constant—similar to VIDYA with different volatility measure.
[]ASS (Adaptive Super Smoother): Super Smoother with length adjusted by volatility ratio (current/slow). Tightens bandwidth when volatility expands.
[]AZLEMA (Adaptive ZLEMA): Zero-lag EMA with volatility-adjusted length. Combines lag elimination with volatility filtering.
[]KFMA (Kalman Filter MA): Optimal state estimator minimizing variance. Process noise (Q) vs Measurement noise (R) tradeoff. 0.01/0.1 default gives smooth but responsive tracking.
[]ALBMA (ALBased MA): ATR-based adaptive EMA. Length expands with volatility (measured by ATR), contracts in calm periods. Excellent for volatility breakout systems.
[]FDIMA (Fractal Dimension Index MA): Adjusts EMA length based on fractal dimension (1-2). Higher dimension (noise) = longer length; lower (trend) = shorter.
[]NMA (Non-Lag MA): 2×MA - MA(MA). Simple zero-lag technique similar to DEMA but using SMA instead of EMA.
[]CMA_Corr (Corrected MA): Adds momentum correction factor × (Price - Price[1]). Amplifies trend by adding velocity term—tune G for aggression (0.5 moderate).
[]RFMA (Range Filter MA): Filters moves smaller than ATR×K. Only updates when price moves significantly—ignores micro-noise while capturing real moves.
[]RSDMA (Relative Standard Deviation MA): Alpha = Coefficient of Variation (StdDev/Mean). Self-adjusting based on relative volatility—statistically robust.
[]SDAMA (Standard Deviation Adaptive MA): Alpha = 1 - (Current StdDev / Highest StdDev). Pure volatility adaptation—smooth when uncertain, fast when certain. - CORMA (Correlation MA): Alpha = |Correlation(Price, External Source)|. Adapts based on correlation with another series (e.g., sector ETF or index)—useful for pair trading.
Section 5: Volume-Based
- []EVMA (Elastic Volume MA): Alpha based on volume volatility (StdDev Volume / Mean Volume). Responds to volume shocks—accelerates when volume patterns change.
[]VAMA (Volume Adjusted MA): Alpha = Current Volume / Sum(Volume). Period-weighted by participation—bars with heavy volume dominate the average.
[]IVWMA (Inverse Volume WMA): Weights by 1/Volume (low volume = high weight). Finds equilibrium during illiquid periods—opposite of standard volume weighting.
[]VROCMA (Volume ROC MA): Alpha based on Volume Rate of Change. Speeds up when volume is accelerating, slows when volume decays—momentum-based volume adaptation.
[]VTWAP (Volume TWAP): VWAP of HL/3 instead of Close. Typical Price VWAP—institutional benchmark for average execution.
[]GVWMA (Gaussian Volume WMA): Volume-smoothed prices using Gaussian weights. Combines volume participation with Gaussian noise filtering. - PVDMA (Price-Volume Dynamic MA): Alpha = Volume / Average Volume. Simple volume-ratio adaptation—faster when above-average participation.
How It Works
1. Equilibrium Selection
Independently select MA types for four equilibrium calculations:
- []Long Set 1 (Primary): Typically slower MA (e.g., KAMA 144 or Super Smoother)
[]Long Set 2 (Secondary): Faster confirmation MA (e.g., ZLEMA 89 or HMA)
[]Short Set 1 (Primary): Resistance MA (e.g., FRAMA 144 for volatility adaptation)
[]Short Set 2 (Secondary): Confirmation MA (e.g., TEMA 89 for fast response)
2. Physics Calculations
For each of the four MAs:
- []Displacement: Price - MA (spring extension)
[]Z-Score: Displacement / Standard Deviation (normalized stretch)
[]Velocity: Rate of change in displacement (first derivative)
[]Acceleration: Rate of change in velocity (second derivative/force)
[]Potential Energy: Z-score² (stored energy in the spring)
[]Kinetic Energy: Velocity² (motion energy) - Total Energy: PE + KE (system momentum)
3. Signal Confirmation
LONG requires ALL:
- []Both Long Sets show Z-score < -2.618 (extreme compression)
[]Both Velocities cross above zero (momentum turning up)
[]Both Accelerations > 0 (force pushing up)
[]Both Correlations > 0.5 (price following the MA) - Both Total Energies > 0 (system active)
SHORT requires ALL:
- []Both Short Sets show Z-score > +2.618 (extreme extension)
[]Both Velocities cross below zero (momentum turning down)
[]Both Accelerations < 0 (force pushing down)
[]Both Correlations > 0.5 - Both Total Energies > 0
Settings Guide
- []MA Selection: Independent dropdowns for all four equilibrium calculations from the 55-type library
[]Equation Lengths: Primary (144) and Secondary (89) lookback periods
[]Velocity Lengths: Momentum smoothing (13/34 for Longs, 13/8 for Shorts)
[]Acceleration Lengths: Force calculation periods (55/8 for Longs, 55/34 for Shorts)
[]Extreme Thresholds: Z-score triggers (2.618 Φ² and 2.0 Φ defaults)
[]Correlation Minimum: 0.5 default—filters signals when price decouples from the equilibrium MA - MA-Specific Params: Individual settings for ALMA offset/sigma, T3 vFactor, KAMA fast/slow, Laguerre gamma, Kalman Q/R, etc.
Visual Interpretation
- []▲ LONG Signal: Green triangle below bar with "LONG" label—requires all 10 conditions met across both Long sets
[]▼ SHORT Signal: Red triangle above bar with "SHORT" label—requires all 10 conditions met across both Short sets
[]Equilibrium Lines:- []Blue/Aqua: Long-term support levels (bright = high correlation >0.75, faded = weak correlation)
[]Orange/Red: Long-term resistance levels (bright = high correlation >0.75, faded = weak correlation)
[]Gray: Weak correlation period (caution advised—price detached from equilibrium)
[]Diagnostics Label: Top-right panel showing:- []Active MA types for all four calculations (L1, L2, S1, S2)
[]Correlation status checkmarks (✓ >0.75, ✗ <0.75)
[]Energy percentile rankings (0-100%) indicating momentum strength relative to historical readings
- []Blue/Aqua: Long-term support levels (bright = high correlation >0.75, faded = weak correlation)
This indicator excels in ranging markets where price oscillates around equilibrium, but includes correlation filters to avoid false signals during strong trends when price decouples from its moving averages. For trending markets, select adaptive MAs (KAMA, FRAMA, ALBMA) that self-adjust to volatility. For pure mean reversion in stable ranges, use HMA, ALMA, or Gaussian MAs for optimal smoothness. The McGinley and Kalman Filter options provide institutional-grade tracking for algorithmic execution benchmarks.
SWMA_ Sine
VTWAP & Median
Parabolic & CMA_Corr w/1.618 threshold
Skrip terproteksi
Skrip ini diterbitkan sebagai sumber tertutup. Namun, Anda dapat menggunakannya dengan bebas dan tanpa batasan apa pun – pelajari lebih lanjut di sini.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip terproteksi
Skrip ini diterbitkan sebagai sumber tertutup. Namun, Anda dapat menggunakannya dengan bebas dan tanpa batasan apa pun – pelajari lebih lanjut di sini.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.