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.


  • $\begingroup$ I can think of one problem with such an algorithm. You need some way to quantify these patterns, so they match your perspective (or a standard perspective). These patterns will look differently through time and across assets (ie. the magnitude of the oscillations defining the patterns will be different). Therefore, there will be no "proper" (optimal) way of tuning your algorithm. The algorithm might be sensitive and thus recognize too many spurious patterns or conservative and exclude a proportion of "proper-defined" patterns. Just food for thought. $\endgroup$ – Pleb Mar 1 at 7:24
  • $\begingroup$ this is a duplicate of quant.stackexchange.com/a/55463/2299 $\endgroup$ – lehalle Mar 2 at 6:32

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

  1. 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
  1. 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.

  2. 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.

  3. 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.

  • 1
    $\begingroup$ Depending on how strict you want to interpret the rules, you might want to collect only moves beyond a certain magnitude (say abs(return)>0.1% or so) and then translate to runs instead of moves. A run is something like "5 times up in a row" or such. Then, using @Sergei's method, you filter on assets whose runs pattern follows your target pattern. Of course, this requires some careful padding and testing, but allows the stocks to perform these movements at different speeds. $\endgroup$ – Kermittfrog Mar 1 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.