Articles with MQL5 programming examples

icon

Access a huge collection of articles with code examples showing how to create indicators and trading robots for the MetaTrader platform in the MQL5 language. Source codes are attached to the articles, so you can open them in MetaEditor and run them to see how the applications work.

These articles will be useful both for those who have just started exploring automated trading and for professional traders with programming experience. They feature not only examples, but also contain new ideas.

Add a new article
latest | best
preview
From Basic to Intermediate: Struct (III)

From Basic to Intermediate: Struct (III)

In this article, we will explore what structured code is. Many people confuse structured code with organized code, but there is a difference between these two concepts. This is exactly what will be discussed in this article. Despite the apparent complexity you may feel when first encountering this type of code writing, I have tried to approach the topic as simply as possible. However, this article is just the first step toward something greater.
preview
From Basic to Intermediate: Function Pointers

From Basic to Intermediate: Function Pointers

You have probably already heard about pointers when it comes to programming. But did you know that we can use this kind of data here in MQL5? Of course, this must be done in a way that keeps us in control and avoids strange program behavior during execution. Still, because this is a feature with a very specific purpose and aimed at particular kinds of tasks, it is rare to hear anyone discuss what a pointer is and how to use it in MQL5.
preview
From Basic to Intermediate: Struct (V)

From Basic to Intermediate: Struct (V)

In this article, we will explore how to overload structural code. I know it can be quite challenging to understand at first, especially if you're seeing it for the first time. It is very important that you grasp these concepts and understand them well before attempting to delve into more complex and elaborate topics.
preview
From Basic to Intermediate: Handling Mouse Events

From Basic to Intermediate: Handling Mouse Events

This article belongs to the category of materials where simply looking through and studying the code is definitely not enough to understand the processes involved. In fact, you need to create an executable application and run it on any chart. This is done so that you can understand small details that would otherwise be extremely difficult to grasp, such as using the keyboard and mouse together to create certain elements.
preview
How to Detect and Normalize Chart Objects in MQL5 (Part 2): Collecting and Structuring Data from Complex Analytical Objects

How to Detect and Normalize Chart Objects in MQL5 (Part 2): Collecting and Structuring Data from Complex Analytical Objects

Manually drawn analytical object tools like Fibonacci tools, and Andrews Pitchforks are invisible to automated trading logic. This article extends a base detector to extract anchor points, level arrays, and geometric offsets from complex objects. You will implement a reusable collector that normalizes the raw chart data into structured memory arrays, ready for strategy decisions.
preview
From Basic to Intermediate: Objects (III)

From Basic to Intermediate: Objects (III)

In today's article, we will look at how to implement a very attractive and interesting interaction system, especially for those who are just beginning to practice programming in MQL5. There is nothing fundamentally new here. Thanks to my approach to the topic, it will be much easier to understand everything, because we will see in practice how to develop a program using a structured approach with a practical and engaging goal.
preview
Code, Tears, and Algo Forge

Code, Tears, and Algo Forge

This article discusses the transition to MQL5 Algo Forge as a modern and convenient format for publishing program code and article attachments. Using repositories instead of traditional ZIP archives and source code allows you to keep projects up-to-date, make edits quickly, and professionally interact with your readers. Recommendations are provided for quickly migrating developments to the cloud environment via the MetaEditor interface.
preview
Overcoming Accessibility Problems in MQL5 Trading Tools (Part V): Gesture-Based Trading With Computer Vision

Overcoming Accessibility Problems in MQL5 Trading Tools (Part V): Gesture-Based Trading With Computer Vision

This article shows how to build a hands-free trading workflow for MetaTrader 5 by translating webcam-tracked hand gestures into MQL5 trade commands. We cover the architecture (MediaPipe/OpenCV in Python plus an MQL5 EA), gesture-to-action mapping, and interprocess communication via Global Variables or HTTP polling. You will implement the EA, execute BUY/SELL/CLOSE actions, and validate latency and reliability under real‑time conditions.
preview
Measuring What Matters (Part 1) : Portfolio Risk Decomposition in MQL5

Measuring What Matters (Part 1) : Portfolio Risk Decomposition in MQL5

The article establishes a reproducible method to measure portfolio risk for multiple symbols using MQL5 matrices and OpenBLAS. It covers computing log returns, building a covariance matrix, and evaluating wᵀΣw instead of summing individual variances. A complete script prints naive versus true volatility and the cross‑term contribution, enabling you to detect when correlated instruments inflate exposure beyond single‑asset estimates.
preview
From Basic to Intermediate: Object Events (I)

From Basic to Intermediate: Object Events (I)

In this article, we will look at three of the six events that MetaTrader 5 can generate when some change occurs to an object on the chart. These events are very useful from the standpoint of user interaction. This is because, without understanding these events, we would have to put in much more effort to maintain a specific chart configuration when trying to manage objects for particular purposes.
preview
Automating Classic Market Methods in MQL5 (Part 2): Wyckoff Cause and Effect—Point and Figure Price Targets

Automating Classic Market Methods in MQL5 (Part 2): Wyckoff Cause and Effect—Point and Figure Price Targets

This article builds a self-contained MQL5 Expert Advisor that completes the Wyckoff cycle: it detects accumulation/distribution with a finite state machine, enters at the last point of support/supply, and calculates exit point-and-figure counts under Wyckoff's Cause and Effect. We detail the box size from range ATR, a 1-box reversal, target validation, and a 2R fallback. Readers get runnable code without external dependencies.
preview
From Basic to Intermediate: Object Events (II)

From Basic to Intermediate: Object Events (II)

In this article, we will look at how the last three types of events generated by an object work. Understanding this will be very interesting, because in the end we will do something that may seem crazy to many people, but it is entirely possible and produces a very surprising result.
preview
Building Volatility Models in MQL5 (Part IV): Implementing Long Memory Volatility Processes, FIGARCH, and HARCH

Building Volatility Models in MQL5 (Part IV): Implementing Long Memory Volatility Processes, FIGARCH, and HARCH

The article delivers MQL5 implementations of FIGARCH and HARCH and updates the volatility library for long‑memory processes. It provides code for Hurst and GPH testing, parameter setup (truncation and horizons), and scripts for fitting, forecasting, and simulations. Readers learn how to apply and compare the models on market data to select an appropriate specification.
preview
Building a Viewport SnR Volume Profile Indicator in MQL5

Building a Viewport SnR Volume Profile Indicator in MQL5

We build a Support and Resistance Volume Profile indicator that adapts to the current viewport in MetaTrader 5. You will learn viewport detection, dynamic SnR identification, zoom‑driven bin sizing, min‑max volume scaling, and fast on‑chart rendering controlled by OnChartEvent. This approach expresses the relative strength of SnR levels with volume, keeping the chart focused on actionable reaction zones.