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
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 2): Building the Covariance Matrix: Eigenvalue Decomposition and Risk Factor Analysis in MQL5

Measuring What Matters (Part 2): Building the Covariance Matrix: Eigenvalue Decomposition and Risk Factor Analysis in MQL5

In Part 2, we introduce a reusable CCovarianceMatrix class that computes and stores a covariance matrix from raw return series using MQL5's native Cov() method. We verify symmetry, print a labeled matrix grid, and call Eig() to obtain eigenvalues and eigenvectors. Readers see how symbols co-move and which factors drive variance, enabling clearer portfolio diagnostics and reuse in scripts or EAs.
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
From Basic to Intermediate: Working with Files in the MetaTrader 5 Sandbox

From Basic to Intermediate: Working with Files in the MetaTrader 5 Sandbox

Do you know what a sandbox is? Do you know how to work with it? If the answer to either of these questions is “no”, read this article to understand the basic operating principle of a sandbox. You will also understand why MetaTrader 5 uses a sandbox to protect the integrity of some of its internal data. The material presented here is purely instructional. Under no circumstances should you treat the application as a final product whose purpose is anything other than studying the concepts presented.
preview
How to Test and Customize Built-in MQL5 Programs:  Custom BullishBearish MeetingLines Stoch Expert Advisor

How to Test and Customize Built-in MQL5 Programs: Custom BullishBearish MeetingLines Stoch Expert Advisor

We demonstrate a practical customization path for a built-in MetaTrader 5 EA using BullishBearish MeetingLines Stoch. The workflow covers baseline testing in the Strategy Tester, parameter optimization, and code-level changes. Two modifications are implemented: exposing Stochastic thresholds as inputs and adding an optional Moving Average filter to limit counter‑trend signals. The article includes the full modified code for replication.
preview
From Basic to Intermediate: Object Events (IV)

From Basic to Intermediate: Object Events (IV)

In this article, we will complete what was started in the previous one: a fully interactive way to resize objects directly on the chart. Although many people imagine that creating something like this would require much deeper knowledge of MQL5, you will see that, using simple concepts and basic knowledge, we can implement a way to work with objects directly on the chart. This leads to a very interesting and quite compelling result.
preview
Beyond the Clock (Part 4): Efficacy of Bars on Trending and Mean-Reversion Strategies

Beyond the Clock (Part 4): Efficacy of Bars on Trending and Mean-Reversion Strategies

Does better return conditioning buy strategy performance? We hold bar count fixed across time, tick, tick-imbalance, and tick-runs on 60.5 million EURUSD ticks, then meta-label RSI, Bollinger, and ADX/DI entries and score with purged cross-validation. No family delivers a consistent edge; efficacy varies narrowly and the best case fails a permutation test. Readers learn how to control overlap, leakage, and multiple testing in bar studies.
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
From Basic to Intermediate: Object Events (III)

From Basic to Intermediate: Object Events (III)

In this article, we will prepare the foundation for what will be covered in the next publication. We will also look at how to make an OBJ_LABEL object fully interactive for editing and moving. In other words, we can change both the text and the position of the OBJ_LABEL object without opening the Object Properties dialog.
preview
From Basic to Intermediate: FileSave and FileLoad

From Basic to Intermediate: FileSave and FileLoad

In today’s article, we will look at several ways to work with the FileSave and FileLoad library functions. Although many people consider them of limited use because of certain limitations or difficulties they create in specific scenarios, properly understanding how these two functions work can save us a great deal of effort at certain points. They are also an excellent way to work with log files.
preview
How to Test and Customize Built-in MQL5 Programs:  Custom BullishBearish MeetingLines Stoch Expert Advisor

How to Test and Customize Built-in MQL5 Programs: Custom BullishBearish MeetingLines Stoch Expert Advisor

We demonstrate a practical customization path for a built-in MetaTrader 5 EA using BullishBearish MeetingLines Stoch. The workflow covers baseline testing in the Strategy Tester, parameter optimization, and code-level changes. Two modifications are implemented: exposing Stochastic thresholds as inputs and adding an optional Moving Average filter to limit counter‑trend signals. The article includes the full modified code for replication.