- MQL5 100%
| Article-22540-Chart-Object-Detection-MQL5.mqproj | ||
| ChartObjectDetector.mqh | ||
| ObjectDetectionTestEA.mq5 | ||
| README.md | ||
Article-22540-Chart-Object-Detection-MQL5
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
Reference repository for an MQL5 chart-object detection framework that converts manually drawn analytical objects into structured data consumable by Expert Advisors.
The article describes a lightweight detector built around raw MQL5 chart-object APIs such as ObjectsTotal(), ObjectName(), ObjectGetInteger(), and ObjectGetDouble(). It focuses on detecting analytical objects like trendlines, rectangles, channels, horizontal lines, vertical lines, and selected Fibonacci objects, then normalizing their coordinates into a single structure.
Original Article
- Article ID: 22540
- Author: Clemence Benjamin
- Publication date: 2026.05.17
- Category: Trading Systems
- URL: https://www.mql5.com/en/articles/22540
Repository Purpose
- Preserve the article’s described implementation as a reusable reference.
- Provide a compact reconstruction target for:
CChartObjectDetectorSChartObjectInfo- a simple polling-based test EA
- Help developers integrate manually drawn chart objects into algorithmic logic for alerts, validation, or trading decisions.
Key Concepts
- Iteration over all chart objects via object index
- Filtering analytical objects from non-analytical UI/chart elements
- Normalization of heterogeneous object geometries into one structure
- Use of indexed properties:
OBJPROP_TIMEOBJPROP_PRICE- Support for multiple object classes:
OBJ_TRENDOBJ_RECTANGLEOBJ_CHANNELOBJ_HLINEOBJ_VLINEOBJ_FIBOand related Fibonacci variants in extraction logic- Periodic polling from an EA using
OnTick()with throttling
Algorithm / Architecture Summary
The article presents a three-stage pipeline:
- Filter
- Enumerate all chart objects on a target chart.
- Keep only supported analytical object types.
- Extract
- Read time/price anchors using raw property access.
- Use indexed access for multi-point objects.
- Handle object-type-specific extraction rules:
- trend/channel/rectangle: two anchors
- horizontal line: price only
- vertical line: time only
- Fibonacci: anchor points only in this version
- Store
- Populate a normalized
SChartObjectInforecord with: - object name
- numeric type
- readable type name
time1,time2price1,price2
The detector is encapsulated in CChartObjectDetector, with an Init() method for chart binding and a Detect() method returning an array of normalized objects.
The test EA initializes the detector on the current chart and logs detected objects every 5 seconds.
Mentioned or Attached Files
Explicitly attached files
ChartObjectDetector.mqh— include file containing the detection class and normalized object structureObjectDetectionTestEA.mq5— test Expert Advisor that polls detection results and prints them to the Experts log
Files mentioned in text
MQL5/Include/ChartObjectsAlgorithms/ChartObjectDetector.mqh— target include path referenced by the articleMQL5/Experts/ObjectDetectionTestEA.mq5— target EA path referenced by the article
Statistics
- Sections: 5
- Main implementation artifacts described: 2
- Supported analytical object categories discussed: 6+
- Detection cadence in test EA: every 5 seconds
- Public detector methods shown:
Init(),Total(),Detect()
Tags
mql5, expert-advisor, chart-objects, object-detection, trendline, fibonacci, technical-analysis, automation
Difficulty
Intermediate
Limitations
- The full original repository structure is not available unless the article attachments are separately provided in this project.
- This is an article-derived reference/reconstruction project.
- Fibonacci handling is incomplete in the described version:
- anchor points are read
- level extraction is deferred to a later part
- The detector uses polling and does not yet react to chart object events automatically.
- Non-analytical objects such as labels, buttons, and other UI elements are intentionally ignored.
- The article text shows a minor inconsistency between extraction logic and filtering scope for some Fibonacci variants; implementation should follow the actual attached code if present.
Reference
Original MQL5 article: https://www.mql5.com/en/articles/22540