OPEN-SOURCE SCRIPT

Dual Shock SPMA | NAL

919
1. Overview

Dual Shock SPMA | NAL is a dual-memory trend indicator designed to separately track how significant bullish and bearish price shocks are developing through time.

Unlike the standard Shock Percentile Moving Average, the Dual Shock SPMA maintains two independent adaptive baselines. Positive shocks update the Bull Shock SPMA, while negative shocks update the Bear Shock SPMA.

This creates two separate memories of where statistically stronger directional moves have occurred, allowing the indicator to evaluate the relationship between bullish and bearish shock structure rather than treating all large movements as one stream.

2. Calculation

The indicator begins by calculating the percentage return of the selected source and ranking the absolute magnitude of that return against recent history.

Pine Script®


Because the percentile calculation uses the absolute return, bullish and bearish shocks are ranked against the same magnitude distribution.

The direction of the return then determines which baseline is allowed to update.

Pine Script®


A qualifying positive shock updates only the Bull Shock SPMA. A qualifying negative shock updates only the Bear Shock SPMA. Otherwise, each baseline retains its previous value.

Pine Script®


Each shock stream then maintains its own directional memory.

A rising Bull SPMA means significant positive shocks are occurring at progressively higher price levels. A rising Bear SPMA means significant negative shocks are also occurring at progressively higher levels. The inverse applies when either baseline is declining.

Pine Script®


The final state requires agreement between both shock memories.

For a bullish regime, both baselines must be trending upward and the Bull SPMA must remain above the Bear SPMA. For a bearish regime, both must be trending downward and their ordering must reverse.

An optional midpoint gate can additionally require price to remain aligned with the center of the dual-shock structure.

Pine Script®


3. Key Features

  1. Separate bullish and bearish shock-memory baselines.
  2. Absolute-return percentile ranking for directly comparable shock magnitude.
  3. Event-driven updates restricted to statistically stronger price movements.
  4. Independent directional memory for positive and negative shocks.
  5. Dual-baseline agreement and relative-position logic.
  6. Optional price midpoint confirmation.
  7. Optional neutral state during unresolved shock structure.
  8. Shock-memory spread visualization and state-based candle coloring.


4. Use

Dual Shock SPMA is designed to analyze how significant positive and negative price events are evolving relative to one another.

Rather than treating volatility as a single undifferentiated stream, the indicator preserves separate memories for each side of the market. This makes the relationship between bullish and bearish shock structure itself part of the signal.

The spread between the two baselines visually represents this evolving relationship, while the midpoint provides a central reference for the combined shock structure.

Dual Shock SPMA is designed as a specialized structural component within a complete strategy framework. Its role is to identify when independently maintained bullish and bearish shock memories begin establishing directional agreement, providing a distinct layer of information about the underlying development of larger price movements.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.