Skip to content
All library documents

Testing Whether Recent Candle Patterns Predict the Next Move

Article Strategy library · Author: ianzeng123

Summary

This example tests whether the direction of recent candles is associated with the direction of the next candle. It maintains a rolling window of six candle outcomes, counts upward candles among the previous five, and records how often a chosen pattern is followed by an upward sixth candle. It also accumulates the next candle’s open-to-close difference and logs the pattern frequency and hit proportion. The pattern threshold and expected direction can be changed.

The author reports that behavior looked acceptable over a few days but became confusing over longer periods, without identifying a cause. The example therefore illustrates a basic conditional-frequency experiment, not evidence of predictive performance. It does not establish statistical significance, account for transaction costs, or separate calibration from evaluation data. The code also updates the rolling window repeatedly while polling records, which may count the same current candle more than once unless polling aligns with completed bars; the sleep interval is noted as needing alignment with the chosen candle period.

Key ideas

  • A rolling set of candle directions is used to test whether a recent pattern precedes a chosen next-candle direction.
  • The script reports pattern occurrences, successful outcomes, their ratio, and cumulative price differences.
  • The author notes that longer backtests produced confusing behavior and offers no explanation.
  • Repeated polling may process the same unfinished candle more than once, complicating the counts.
  • The example provides no statistical testing, cost model, or out-of-sample validation.

Tags

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