Discussing the article: "Encoding Candlestick Patterns (Part 2): Modeling Price Action as an Ordered Sequence"

 

Check out the new article: Encoding Candlestick Patterns (Part 2): Modeling Price Action as an Ordered Sequence.

Developing permutation-based tools in MQL5 provides a systematic way to analyze candlestick pattern combinations for trading strategies. This article introduces a permutation calculator and generator designed to compute and enumerate all possible ordered candlestick sequences from bullish and bearish sets, with or without repetition. By generating exhaustive pattern combinations, traders can perform data-driven analysis to identify high-probability market patterns and improve decision-making in automated trading systems.

In this installment, our goal is to develop a permutation calculator in MQL5. This tool will compute the total expected number of unique patterns that can be generated from a given input set, such as "AHEGD" (bullish set) or "ahegd" (bearish set). For example, if we take a subset of three letters from the five available, how many distinct ordered sequences (permutations) can we form? The calculator will answer such questions, accounting for whether repetition is allowed (e.g., the same candlestick type can appear consecutively) or not allowed (each type used at most once).

Additionally, we will construct a function that generates all ordered sequences (permutations) for a given set of candlestick types. This function will produce an array of strings, each representing a valid pattern sequence. This exhaustive list enables data-driven analysis. Traders can compare real-time sequences with all theoretical patterns and identify those most associated with specific outcomes (eg, continuation or reversal).

Author: Daniel Opoku