Skip to content
All library documents

Rule-Based Detection of Recurring Price Patterns

Article Quant Q&A · Author: user52902

Summary

The response proposes representing chart patterns as sequences of numerical movements and scanning a rolling window of volume-weighted average price candles for matches. It illustrates the representation with examples such as a double top, head and shoulders, and a rising wedge. A conversion step maps the pattern sequence into returns between consecutive VWAP values, after which rules can detect similar historical or live sequences.

Because exact matches in observed returns are unlikely, the response suggests rounding or allowing a tolerance around each sequence value. A detected pattern can trigger an action, such as proposing or placing an entry with stop loss and take profit levels. The document presents a rules-engine design rather than an AI method, but it provides no test results, probability estimates, or evidence that these patterns predict profitable outcomes. Pattern definitions and tolerances would need validation to avoid arbitrary matches and overfitting.

Key ideas

  • Represent visual chart patterns as numeric sequences of price movements.
  • Scan a sliding window of VWAP candles and compare their returns with encoded patterns.
  • Use rounding or tolerances because exact return-sequence matches are improbable.
  • A matched rule can trigger a signal or an order workflow with risk controls.
  • The proposed architecture does not establish that recurring patterns have predictive value.

Tags

Full text
# Designing scanning logic of past history for probability of common market pattern re-occurrences in single timeframe


# Designing scanning logic of past history for probability of common market pattern re-occurrences in single timeframe












How should I go about designing algorithm that would collect VWAP from all "candles" in a timeframe and determine common patterns like the once in the image. I'm not sure if the logic design would require AI based approach or if there is already library design for this purpose. I'm not looking for proprietary solutions that are already out there since they will not share how they accomplished overall architecture of the solution.

I'm just curious to see if there is value in calculating probability of pattern recurrence in specific market based on past history. Not sure if this was attempted on any marked out there, but if it was I would also appreciate any links or references pointing me to reading materials I could study from.

## Answer by Sergei Rodionov (score 1)

https://quant.stackexchange.com/a/61445

This type of reaction functions can be automated using a Rules Engine.

- Translate pictures into numeric sequences, for example:

- Double Top = `3,-1,1,-1`

- Head and Shoulders = `4,-1,2,-2,1,-1`

- Rising Wedge = `3,-1,1.1,-0.9,1.0,-0.8,0.9`

- etc

- Create a rule for each sequence, configuring the rule to maintain a sliding window of `N+1` vwap candles, where N is the sequence length. For example, the Double Top rule needs 5 candles.

- Write a function to convert user-friendly sequence numbers into units of return, so that the `3,-1,1,-1` sequence for instance is translated into something like `1.003,0.999,1.001,0.999`. Return is `VWAPt/VWAPt-1`. The likelihood of actual returns matching sequences exactly is nil, so either round returns to significant digits or allow for a small deviation from each sequence.

- Configure response actions to execute when the sequence is matched. This would be the step where entry orders and SL/TP stops are initiated, either automatically or as a recommendation for a human to confirm.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

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