The article demonstrates the practical implementation of CandleCode for MetaTrader 5: calculating candlestick codes using the Likhovidov method with thresholds adapted to volatility (Bollinger Bands) and histogram visualization. An Expert Advisor is also presented that builds a database of historical patterns using ZigZag, compares them with the current "snapshot" using ATR, and displays match statistics on a panel.
Candlestick analysis always leaves room for debate: where one person sees a reversal setup, another might consider the shadow too short and the body too large. The problem is not a difference of opinion, but the fact that it's not easy to test any trading hypothesis against historical data. A trader cannot instantly determine how many times over the past ten years the exact candlestick pattern he is seeing right now has actually led to a trend reversal.
As early as 1999–2001, Viktor Likhovidov proposed the CandleCode concept in the magazine "Stocks & Commodities" as a way to represent chart structure as a number. In March 2001, the second part of the study (Coding Candlesticks II) was published, developing the topic further with an optimized algorithm that combines calculations of candlestick body and shadow parameters in a single function.
The method is based on the numerical classification of each bar. Each candlestick is assigned a numerical code based on the weighting factors of three components:
body color (closing direction),
relative body size (based on threshold values),
configuration of the upper and lower shadows.
The combined weight of these characteristics forms a unique code that makes it possible to replace subjective visual searches for patterns with rigorous algorithmic calculations. While early implementations of the method — for example, for TradeStation (EasyLanguage) or MetaStock — confirmed its applicability to statistical analysis, today's computing power makes it possible to integrate this approach into complex neural network and pattern-search systems.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Check out the new article: CandleCode Indicator: Formalization of Candlestick Patterns in MQL5.
Candlestick analysis always leaves room for debate: where one person sees a reversal setup, another might consider the shadow too short and the body too large. The problem is not a difference of opinion, but the fact that it's not easy to test any trading hypothesis against historical data. A trader cannot instantly determine how many times over the past ten years the exact candlestick pattern he is seeing right now has actually led to a trend reversal.
As early as 1999–2001, Viktor Likhovidov proposed the CandleCode concept in the magazine "Stocks & Commodities" as a way to represent chart structure as a number. In March 2001, the second part of the study (Coding Candlesticks II) was published, developing the topic further with an optimized algorithm that combines calculations of candlestick body and shadow parameters in a single function.
The method is based on the numerical classification of each bar. Each candlestick is assigned a numerical code based on the weighting factors of three components:The combined weight of these characteristics forms a unique code that makes it possible to replace subjective visual searches for patterns with rigorous algorithmic calculations. While early implementations of the method — for example, for TradeStation (EasyLanguage) or MetaStock — confirmed its applicability to statistical analysis, today's computing power makes it possible to integrate this approach into complex neural network and pattern-search systems.
Author: Artyom Trishkin