Skip to content
All library documents

Z-Score Mean Reversion with Threshold Entries and Fixed Stops

Article TradingView scripts

Summary

This strategy estimates a rolling price mean and standard deviation over a configurable lookback, then calculates a z-score to identify unusually low or high closes. It opens a long when the score falls below the negative entry threshold and a short when it rises above the positive threshold. Positions close as the score returns toward the center, with separate conditions for long and short exits, or when a fixed point-based stop is reached. The source includes inputs for lookback, entry and exit thresholds, scaling, and stop distance, although the scaling input is not used in the shown order logic.

The accompanying description presents the method as most suitable for range-bound or mean-reverting instruments and names the VIX as an example, while cautioning that many assets behave more like random walks. It mentions an assumed trading cost and a one-hour use case, but offers no performance statistics or test results. The document also contains conflicting stop and threshold figures in its prose and code; the implemented defaults should therefore be distinguished from the narrative. Mean reversion and stop execution are not guaranteed.

Key ideas

  • The strategy measures price deviation from a rolling average using a standardized z-score.
  • It enters long below a negative threshold and short above a positive threshold.
  • Exit conditions close positions as the z-score moves back toward the center, with fixed point-based stops as an additional exit.
  • The accompanying discussion emphasizes that the approach depends on the traded asset actually exhibiting mean reversion.
  • The prose and code disagree on some parameter values, and no performance evidence is supplied.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.