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: Operator Overloading (V)

From Basic to Intermediate: Operator Overloading (V)

In this article, we will look at how to modify the code to implement a solution entirely unlike what many consider possible in MQL5. Important note: To fully understand this material, you must have a solid grasp of the concepts covered in the previous articles.
preview
From Basic to Intermediate: Queues, Lists, and Trees (VII)

From Basic to Intermediate: Queues, Lists, and Trees (VII)

In this article, we will clearly and simply demonstrate and explain how to remove a node from a tree. This process usually confuses beginners rather than helping them understand how it's done and why it needs to be done that way.
preview
From Basic to Intermediate: Queues, Lists, and Trees (VIII)

From Basic to Intermediate: Queues, Lists, and Trees (VIII)

In this article, we will examine how to implement a tree balancing algorithm. Here, I will present my own version of an implementation of this algorithm. There are many other algorithms that serve the same purpose. Nevertheless, each of them has its own advantages and disadvantages. You, my dear reader, will need to explore them and find the one that best suits your needs.
preview
From Basic to Intermediate: Operator Overloading (III)

From Basic to Intermediate: Operator Overloading (III)

In this article, we will examine how to implement overloading for both logical operators and comparison operators. This requires a certain amount of caution and a fair amount of attention. Even a minor oversight when implementing the overloading of these operators can render the entire code completely unusable. If any problems arise in the overloading, the entire database created from the results generated by the code will have to be either discarded completely or, at the very least, reviewed in full.
preview
How MQL5 Lite MCP AI Assistant Changed My Debugging Approach on Generated MQL5 Codes

How MQL5 Lite MCP AI Assistant Changed My Debugging Approach on Generated MQL5 Codes

This article presents a practical debugging workflow with MetaEditor's integrated AI Assistant and a comparison to the previous external approach. We fix a controlled set of syntax and API errors in a D1 PriceMarker EA, inspect modifications, and recompile. The result is validated in the Strategy Tester, with clear boundaries between compilation success and required runtime checks.
preview
Developing Smart Chart Objects in MQL5 (Part 2): Automating Trendline Discovery and Lifecycle Management

Developing Smart Chart Objects in MQL5 (Part 2): Automating Trendline Discovery and Lifecycle Management

Learn how Smart Trendline Manager separates creation from lifecycle control while handling both manual and auto-generated trendlines. It demonstrates discovery, registration, proximity and touch handling, bounce/break confirmation, post-break resurrection, expiration, and state-driven visualization. This gives you a consistent, configurable way to manage multiple lines through one orchestrated update process.
preview
Meta-Labeling the Classics (Part 4): Filtering and Sizing MACD Trades

Meta-Labeling the Classics (Part 4): Filtering and Sizing MACD Trades

MACD signal-line crossovers often reflect range noise rather than true momentum shifts, producing whipsaws. We apply a two-layer meta-labeling pipeline with an Optuna-optimized regime gate to filter entries on EURUSD H1, turning a gross-losing rule into a positive but not statistically significant track. A secondary Random Forest adds no lift due to too few gated samples, clarifying when filtering helps and when the ML layer is data-starved.
preview
Inside MetaEditor's AI Assistant: Writing, Repairing and Testing MQL5 with an Agent

Inside MetaEditor's AI Assistant: Writing, Repairing and Testing MQL5 with an Agent

We use the MetaTrader 5 AI Assistant to execute the full workflow end to end: create an EA from a natural‑language prompt, compile it, break and watch it self‑correct from compiler output, backtest it, and compare a controlled re‑run. The article details the underlying MCP extensions, configuration and safety limits, and how to connect external AI clients. Readers get a repeatable process for building and testing EAs inside the platform.