- MQL5 100%
| Article-22469-Candlestick-Alphabetical-Encoding-System.mq5 | ||
| Article-22469-Candlestick-Alphabetical-Encoding-System.mqproj | ||
| README.md | ||
Article-22469-Candlestick-Alphabetical-Encoding-System
This repository is an article-derived reference project based on the original MQL5 article. It does not claim to reproduce the full original source code unless files are explicitly attached.
Overview
This project documents an MQL5-based approach for converting candlestick price action into an objective symbolic encoding system. Instead of using subjective labels such as long candle, pin bar, or spinning top, the article defines deterministic body-to-wick ratio rules and maps candles into letter codes such as A/a, H/h, E/e, G/g, and D.
The article also presents a simple two-candle pattern detection workflow built around these encoded symbols, using MQL5 functions to classify candles, combine adjacent symbols into strings, and report recognized bullish or bearish pattern permutations.
Original Article
- Article ID: 22469
- Author: Daniel Opoku
- Publication date: 2026.05.12
- Category: Indicators
- URL: https://www.mql5.com/en/articles/22469
Repository Purpose
This repository should be treated as a reference or reconstruction project derived from the article content provided.
Its purpose is to preserve the article’s core technical ideas:
- objective candlestick classification using measurable ratios
- symbolic candle encoding for algorithmic processing
- deterministic two-candle pattern recognition
- reproducible signal generation through MQL5 indicator logic
Key Concepts
- Candlestick anatomy:
- body =
abs(close - open) - upper wick =
high - max(open, close) - lower wick =
min(open, close) - low - Directional encoding:
- uppercase for bullish candles
- lowercase for bearish candles
- Candle classes described in the article:
A/a= long, short, or marubozu-style candlesH/h= pin barE/e= inverted pin barG/g= spinning topD= doji- Rule-based classification via
CandleType(int shift) - Two-candle pattern construction using ordered symbol pairs
- Pattern checking through string comparison
- Historical scanning using a configurable lookback inside
OnCalculate()
Algorithm / Architecture Summary
The article describes the following indicator workflow:
- Per-candle feature extraction
- Read OHLC data using
iOpen,iClose,iHigh, andiLow. - Compute body, upper wick, and lower wick.
- Candle encoding
- Use ratio thresholds to classify each candle.
- Bullish candles return
A,G,H, orE. - Bearish candles return
a,g,h, ore. - Exact open-close equality returns
Dfor doji. - Unmatched candles return an empty string.
- Two-candle pattern generation
- Concatenate the previous candle code and the current candle code.
- Example form:
AH,ge, etc.
- Bullish pattern validation
- Check uppercase ordered pairs from the bullish set:
AH, AE, AG, HA, HE, HG, EA, EH, EG, GA, GH, GE
- Bearish pattern validation
- Check lowercase ordered pairs from the bearish set:
ah, ae, ag, ha, he, hg, ea, eh, eg, ga, gh, ge
- Signal output
- Report detections through
Print()andAlert().
- Execution control
- Run scanning inside
OnCalculate(). - Use a lookback limit for historical analysis.
- Avoid repeated execution on the same bar by tracking time.
Mentioned or Attached Files
Explicitly attached files
No attached source files were available in the processed input.
Files or code units mentioned in the article text
CandleType(int shift)functionCheckBullishPattern(int shift)functionCheckBearishPattern(int shift)functionOnCalculate(...)indicator iteration function
Statistics
- Encoding classes: 5 symbolic candle groups (
A/a,H/h,E/e,G/g,D) - Bullish two-candle permutations listed: 12
- Bearish two-candle permutations listed: 12
- Example lookback value mentioned: 500 bars
- Detection outputs mentioned:
Print(),Alert(), optionalSendNotification()
Tags
MQL5, MetaTrader 5, candlestick analysis, price action, pattern encoding, algorithmic trading, indicator, permutation, pattern detection
Difficulty
Intermediate
Limitations
- The full original source code is unavailable in the processed input.
- No actual repository file tree or attached
.mq5/.mqhfiles were provided. - Article metadata such as article ID, author, publication date, and category were not included in the input.
- The README is based only on the article text and embedded code excerpts.
- The article describes detection and alerting logic, but it does not provide enough confirmed material here to document a complete production-ready indicator package.
Reference
Original article source: https://www.mql5.com/en/articles/22469