Using the Wald–Wolfowitz Runs Test to Flag Intrabar Nonrandomness
Summary
This indicator applies the Wald–Wolfowitz runs test to the signs of lower-timeframe price changes within each chart bar. It compares the observed number of positive and negative sequences with the expected count under a randomness assumption, then scales the difference by its standard deviation. Readings beyond configurable critical values flag possible nonrandomness; fewer-than-expected runs may be consistent with clustering or mean-reverting behavior, while the test itself gives no directional forecast.
Users can select an approximate intrabar sample density and a confidence threshold, and the display can mark flagged bars. The explanation presents the statistical rationale but supplies no trading performance study. It cautions that the test does not identify why a pattern occurred, cannot predict future returns, and can produce false positives. The script also requires enough intrabar observations and reports an error when the available average sample is below its stated minimum, making data availability a practical constraint.
Key ideas
- The indicator counts runs in the signs of lower-timeframe returns and compares them with a randomness-based expectation.
- A standardized deviation beyond either critical boundary flags possible nonrandomness, without indicating direction.
- Too few runs can sometimes align with mean-reverting behavior, but the test does not establish a cause or trade.
- Confidence thresholds and intrabar density are configurable, and insufficient intrabar history limits operation.
- The document offers statistical rationale rather than evidence of profitable trading, and false positives are possible.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.