MQL5 Programming Articles

icon

Study the MQL5 language for programming trading strategies in numerous published articles mostly written by you - the community members. The articles are grouped into categories to help you quicker find answers to any questions related to programming: Integration, Tester, Trading Strategies, etc.

Follow our new publications and discuss them on the Forum!

Add a new article
latest | best
preview
Generative Adversarial Networks (GANs) for Synthetic Data in Financial Modeling (Part 1): Introduction to GANs and Synthetic Data in Financial Modeling

Generative Adversarial Networks (GANs) for Synthetic Data in Financial Modeling (Part 1): Introduction to GANs and Synthetic Data in Financial Modeling

This article introduces traders to Generative Adversarial Networks (GANs) for generating Synthetic Financial data, addressing data limitations in model training. It covers GAN basics, python and MQL5 code implementations, and practical applications in finance, empowering traders to enhance model accuracy and robustness through synthetic data.
preview
Price Action Analysis Toolkit Development (Part 3): Analytics Master — EA

Price Action Analysis Toolkit Development (Part 3): Analytics Master — EA

Moving from a simple trading script to a fully functioning Expert Advisor (EA) can significantly enhance your trading experience. Imagine having a system that automatically monitors your charts, performs essential calculations in the background, and provides regular updates every two hours. This EA would be equipped to analyze key metrics that are crucial for making informed trading decisions, ensuring that you have access to the most current information to adjust your strategies effectively.
preview
MQL5 Wizard Techniques you should know (Part 50): Awesome Oscillator

MQL5 Wizard Techniques you should know (Part 50): Awesome Oscillator

The Awesome Oscillator is another Bill Williams Indicator that is used to measure momentum. It can generate multiple signals, and therefore we review these on a pattern basis, as in prior articles, by capitalizing on the MQL5 wizard classes and assembly.
preview
Trading with the MQL5 Economic Calendar (Part 3): Adding Currency, Importance, and Time Filters

Trading with the MQL5 Economic Calendar (Part 3): Adding Currency, Importance, and Time Filters

In this article, we implement filters in the MQL5 Economic Calendar dashboard to refine news event displays by currency, importance, and time. We first establish filter criteria for each category and then integrate these into the dashboard to display only relevant events. Finally, we ensure each filter dynamically updates to provide traders with focused, real-time economic insights.
preview
Neural Networks Made Easy (Part 94): Optimizing the Input Sequence

Neural Networks Made Easy (Part 94): Optimizing the Input Sequence

When working with time series, we always use the source data in their historical sequence. But is this the best option? There is an opinion that changing the sequence of the input data will improve the efficiency of the trained models. In this article I invite you to get acquainted with one of the methods for optimizing the input sequence.
preview
Mastering Log Records (Part 1): Fundamental Concepts and First Steps in MQL5

Mastering Log Records (Part 1): Fundamental Concepts and First Steps in MQL5

Welcome to the beginning of another journey! This article opens a special series where we will create, step by step, a library for log manipulation, tailored for those who develop in the MQL5 language.
preview
Creating a Trading Administrator Panel in MQL5 (Part VII): Trusted User, Recovery and Cryptography

Creating a Trading Administrator Panel in MQL5 (Part VII): Trusted User, Recovery and Cryptography

Security prompts, such as those triggered every time you refresh the chart, add a new pair to the chat with the Admin Panel EA, or restart the terminal, can become tedious. In this discussion, we will explore and implement a feature that tracks the number of login attempts to identify a trusted user. After a set number of failed attempts, the application will transition to an advanced login procedure, which also facilitates passcode recovery for users who may have forgotten it. Additionally, we will cover how cryptography can be effectively integrated into the Admin Panel to enhance security.
preview
MQL5 Wizard Techniques you should know (Part 49): Reinforcement Learning with Proximal Policy Optimization

MQL5 Wizard Techniques you should know (Part 49): Reinforcement Learning with Proximal Policy Optimization

Proximal Policy Optimization is another algorithm in reinforcement learning that updates the policy, often in network form, in very small incremental steps to ensure the model stability. We examine how this could be of use, as we have with previous articles, in a wizard assembled Expert Advisor.
preview
Trading Insights Through Volume: Moving Beyond OHLC Charts

Trading Insights Through Volume: Moving Beyond OHLC Charts

Algorithmic trading system that combines volume analysis with machine learning techniques, specifically LSTM neural networks. Unlike traditional trading approaches that primarily focus on price movements, this system emphasizes volume patterns and their derivatives to predict market movements. The methodology incorporates three main components: volume derivatives analysis (first and second derivatives), LSTM predictions for volume patterns, and traditional technical indicators.
preview
Developing a Replay System (Part 53): Things Get Complicated (V)

Developing a Replay System (Part 53): Things Get Complicated (V)

In this article, we'll cover an important topic that few people understand: Custom Events. Dangers. Advantages and disadvantages of these elements. This topic is key for those who want to become a professional programmer in MQL5 or any other language. Here we will focus on MQL5 and MetaTrader 5.
preview
Creating a Trading Administrator Panel in MQL5 (Part VI):Trade Management Panel (II)

Creating a Trading Administrator Panel in MQL5 (Part VI):Trade Management Panel (II)

In this article, we enhance the Trade Management Panel of our multi-functional Admin Panel. We introduce a powerful helper function that simplifies the code, improving readability, maintainability, and efficiency. We will also demonstrate how to seamlessly integrate additional buttons and enhance the interface to handle a wider range of trading tasks. Whether managing positions, adjusting orders, or simplifying user interactions, this guide will help you develop a robust, user-friendly Trade Management Panel.
preview
Price Action Analysis Toolkit Development (Part 2):  Analytical Comment Script

Price Action Analysis Toolkit Development (Part 2): Analytical Comment Script

Aligned with our vision of simplifying price action, we are pleased to introduce another tool that can significantly enhance your market analysis and help you make well-informed decisions. This tool displays key technical indicators such as previous day's prices, significant support and resistance levels, and trading volume, while automatically generating visual cues on the chart.
preview
Mutual information as criteria for Stepwise Feature Selection

Mutual information as criteria for Stepwise Feature Selection

In this article, we present an MQL5 implementation of Stepwise Feature Selection based on the mutual information between an optimal predictor set and a target variable.
preview
Data Science and ML (Part 32): Keeping your AI models updated, Online Learning

Data Science and ML (Part 32): Keeping your AI models updated, Online Learning

In the ever-changing world of trading, adapting to market shifts is not just a choice—it's a necessity. New patterns and trends emerge everyday, making it harder even the most advanced machine learning models to stay effective in the face of evolving conditions. In this article, we’ll explore how to keep your models relevant and responsive to new market data by automatically retraining.
preview
Neural Networks Made Easy (Part 93): Adaptive Forecasting in Frequency and Time Domains (Final Part)

Neural Networks Made Easy (Part 93): Adaptive Forecasting in Frequency and Time Domains (Final Part)

In this article, we continue the implementation of the approaches of the ATFNet model, which adaptively combines the results of 2 blocks (frequency and time) within time series forecasting.
preview
Automating Trading Strategies in MQL5 (Part 1): The Profitunity System (Trading Chaos by Bill Williams)

Automating Trading Strategies in MQL5 (Part 1): The Profitunity System (Trading Chaos by Bill Williams)

In this article, we examine the Profitunity System by Bill Williams, breaking down its core components and unique approach to trading within market chaos. We guide readers through implementing the system in MQL5, focusing on automating key indicators and entry/exit signals. Finally, we test and optimize the strategy, providing insights into its performance across various market scenarios.
preview
Connexus Observer (Part 8): Adding a Request Observer

Connexus Observer (Part 8): Adding a Request Observer

In this final installment of our Connexus library series, we explored the implementation of the Observer pattern, as well as essential refactorings to file paths and method names. This series covered the entire development of Connexus, designed to simplify HTTP communication in complex applications.
preview
Chemical reaction optimization (CRO) algorithm (Part I): Process chemistry in optimization

Chemical reaction optimization (CRO) algorithm (Part I): Process chemistry in optimization

In the first part of this article, we will dive into the world of chemical reactions and discover a new approach to optimization! Chemical reaction optimization (CRO) uses principles derived from the laws of thermodynamics to achieve efficient results. We will reveal the secrets of decomposition, synthesis and other chemical processes that became the basis of this innovative method.
preview
Visualizing deals on a chart (Part 2): Data graphical display

Visualizing deals on a chart (Part 2): Data graphical display

Here we are going to develop a script from scratch that simplifies unloading print screens of deals for analyzing trading entries. All the necessary information on a single deal is to be conveniently displayed on one chart with the ability to draw different timeframes.
preview
Developing a Replay System (Part 52): Things Get Complicated (IV)

Developing a Replay System (Part 52): Things Get Complicated (IV)

In this article, we will change the mouse pointer to enable the interaction with the control indicator to ensure reliable and stable operation.
preview
MQL5 Wizard Techniques you should know (Part 48): Bill Williams Alligator

MQL5 Wizard Techniques you should know (Part 48): Bill Williams Alligator

The Alligator Indicator, which was the brain child of Bill Williams, is a versatile trend identification indicator that yields clear signals and is often combined with other indicators. The MQL5 wizard classes and assembly allow us to test a variety of signals on a pattern basis, and so we consider this indicator as well.
preview
Developing a multi-currency Expert Advisor (Part 13): Automating the second stage — selection into groups

Developing a multi-currency Expert Advisor (Part 13): Automating the second stage — selection into groups

We have already implemented the first stage of the automated optimization. We perform optimization for different symbols and timeframes according to several criteria and store information about the results of each pass in the database. Now we are going to select the best groups of parameter sets from those found at the first stage.
preview
Client in Connexus (Part 7): Adding the Client Layer

Client in Connexus (Part 7): Adding the Client Layer

In this article we continue the development of the connexus library. In this chapter we build the CHttpClient class responsible for sending a request and receiving an order. We also cover the concept of mocks, leaving the library decoupled from the WebRequest function, which allows greater flexibility for users.
preview
Creating a Trading Administrator Panel in MQL5 (Part VI): Multiple Functions Interface (I)

Creating a Trading Administrator Panel in MQL5 (Part VI): Multiple Functions Interface (I)

The Trading Administrator's role goes beyond just Telegram communications; they can also engage in various control activities, including order management, position tracking, and interface customization. In this article, we’ll share practical insights on expanding our program to support multiple functionalities in MQL5. This update aims to overcome the current Admin Panel's limitation of focusing primarily on communication, enabling it to handle a broader range of tasks.
preview
MQL5 Wizard Techniques you should know (Part 47): Reinforcement Learning with Temporal Difference

MQL5 Wizard Techniques you should know (Part 47): Reinforcement Learning with Temporal Difference

Temporal Difference is another algorithm in reinforcement learning that updates Q-Values basing on the difference between predicted and actual rewards during agent training. It specifically dwells on updating Q-Values without minding their state-action pairing. We therefore look to see how to apply this, as we have with previous articles, in a wizard assembled Expert Advisor.
preview
Price Action Analysis Toolkit Development (Part 1): Chart Projector

Price Action Analysis Toolkit Development (Part 1): Chart Projector

This project aims to leverage the MQL5 algorithm to develop a comprehensive set of analysis tools for MetaTrader 5. These tools—ranging from scripts and indicators to AI models and expert advisors—will automate the market analysis process. At times, this development will yield tools capable of performing advanced analyses with no human involvement and forecasting outcomes to appropriate platforms. No opportunity will ever be missed. Join me as we explore the process of building a robust market analysis custom tools' chest. We will begin by developing a simple MQL5 program that I have named, Chart Projector.
preview
Trading with the MQL5 Economic Calendar (Part 2): Creating a News Dashboard Panel

Trading with the MQL5 Economic Calendar (Part 2): Creating a News Dashboard Panel

In this article, we create a practical news dashboard panel using the MQL5 Economic Calendar to enhance our trading strategy. We begin by designing the layout, focusing on key elements like event names, importance, and timing, before moving into the setup within MQL5. Finally, we implement a filtering system to display only the most relevant news, giving traders quick access to impactful economic events.
preview
Reimagining Classic Strategies (Part XI): Moving Average Cross Over (II)

Reimagining Classic Strategies (Part XI): Moving Average Cross Over (II)

The moving averages and the stochastic oscillator could be used to generate trend following trading signals. However, these signals will only be observed after the price action has occurred. We can effectively overcome this inherent lag in technical indicators using AI. This article will teach you how to create a fully autonomous AI-powered Expert Advisor in a manner that can improve any of your existing trading strategies. Even the oldest trading strategy possible can be improved.
preview
Neural Networks Made Easy (Part 92): Adaptive Forecasting in Frequency and Time Domains

Neural Networks Made Easy (Part 92): Adaptive Forecasting in Frequency and Time Domains

The authors of the FreDF method experimentally confirmed the advantage of combined forecasting in the frequency and time domains. However, the use of the weight hyperparameter is not optimal for non-stationary time series. In this article, we will get acquainted with the method of adaptive combination of forecasts in frequency and time domains.
preview
From Python to MQL5: A Journey into Quantum-Inspired Trading Systems

From Python to MQL5: A Journey into Quantum-Inspired Trading Systems

The article explores the development of a quantum-inspired trading system, transitioning from a Python prototype to an MQL5 implementation for real-world trading. The system uses quantum computing principles like superposition and entanglement to analyze market states, though it runs on classical computers using quantum simulators. Key features include a three-qubit system for analyzing eight market states simultaneously, 24-hour lookback periods, and seven technical indicators for market analysis. While the accuracy rates might seem modest, they provide a significant edge when combined with proper risk management strategies.
preview
Feature Engineering With Python And MQL5 (Part II): Angle Of Price

Feature Engineering With Python And MQL5 (Part II): Angle Of Price

There are many posts in the MQL5 Forum asking for help calculating the slope of price changes. This article will demonstrate one possible way of calculating the angle formed by the changes in price in any market you wish to trade. Additionally, we will answer if engineering this new feature is worth the extra effort and time invested. We will explore if the slope of the price can improve any of our AI model's accuracy when forecasting the USDZAR pair on the M1.
preview
MQL5 Wizard Techniques you should know (Part 46): Ichimoku

MQL5 Wizard Techniques you should know (Part 46): Ichimoku

The Ichimuko Kinko Hyo is a renown Japanese indicator that serves as a trend identification system. We examine this, on a pattern by pattern basis, as has been the case in previous similar articles, and also assess its strategies & test reports with the help of the MQL5 wizard library classes and assembly.
preview
Stepwise feature selection in MQL5

Stepwise feature selection in MQL5

In this article, we introduce a modified version of stepwise feature selection, implemented in MQL5. This approach is based on the techniques outlined in Modern Data Mining Algorithms in C++ and CUDA C by Timothy Masters.
preview
Multiple Symbol Analysis With Python And MQL5 (Part II): Principal Components Analysis For Portfolio Optimization

Multiple Symbol Analysis With Python And MQL5 (Part II): Principal Components Analysis For Portfolio Optimization

Managing trading account risk is a challenge for all traders. How can we develop trading applications that dynamically learn high, medium, and low-risk modes for various symbols in MetaTrader 5? By using PCA, we gain better control over portfolio variance. I’ll demonstrate how to create applications that learn these three risk modes from market data fetched from MetaTrader 5.
preview
News Trading Made Easy (Part 5): Performing Trades (II)

News Trading Made Easy (Part 5): Performing Trades (II)

This article will expand on the trade management class to include buy-stop and sell-stop orders to trade news events and implement an expiration constraint on these orders to prevent any overnight trading. A slippage function will be embedded into the expert to try and prevent or minimize possible slippage that may occur when using stop orders in trading, especially during news events.
preview
How to view deals directly on the chart without weltering in trading history

How to view deals directly on the chart without weltering in trading history

In this article, we will create a simple tool for convenient viewing of positions and deals directly on the chart with key navigation. This will allow traders to visually examine individual deals and receive all the information about trading results right on the spot.
preview
Requesting in Connexus (Part 6): Creating an HTTP Request and Response

Requesting in Connexus (Part 6): Creating an HTTP Request and Response

In this sixth article of the Connexus library series, we will focus on a complete HTTP request, covering each component that makes up a request. We will create a class that represents the request as a whole, which will help us bring together the previously created classes.
preview
Developing a Replay System (Part 51): Things Get Complicated (III)

Developing a Replay System (Part 51): Things Get Complicated (III)

In this article, we will look into one of the most difficult issues in the field of MQL5 programming: how to correctly obtain a chart ID, and why objects are sometimes not plotted on the chart. The materials presented here are for didactic purposes only. Under no circumstances should the application be viewed for any purpose other than to learn and master the concepts presented.
preview
Self Optimizing Expert Advisor With MQL5 And Python (Part VI): Taking Advantage of Deep Double Descent

Self Optimizing Expert Advisor With MQL5 And Python (Part VI): Taking Advantage of Deep Double Descent

Traditional machine learning teaches practitioners to be vigilant not to overfit their models. However, this ideology is being challenged by new insights published by diligent researches from Harvard, who have discovered that what appears to be overfitting may in some circumstances be the results of terminating your training procedures prematurely. We will demonstrate how we can use the ideas published in the research paper, to improve our use of AI in forecasting market returns.
preview
Elements of correlation analysis in MQL5: Pearson chi-square test of independence and correlation ratio

Elements of correlation analysis in MQL5: Pearson chi-square test of independence and correlation ratio

The article observes classical tools of correlation analysis. An emphasis is made on brief theoretical background, as well as on the practical implementation of the Pearson chi-square test of independence and the correlation ratio.