Articles with examples of trading robots developed in MQL5

icon

An Expert Advisor is the 'pinnacle' of programming and the desired goal of every automated trading developer. Read the articles in this section to create your own trading robot. By following the described steps you will learn how to create, debug and test automated trading systems.

The articles not only teach MQL5 programming, but also show how to implement trading ideas and techniques. You will learn how to program a trailing stop, how to apply money management, how to get the indicator values, and much more.

Add a new article
latest | best
preview
MetaTrader 5 Machine Learning Blueprint (Part 14): Transaction Cost Modeling for Triple-Barrier Labels in MQL5

MetaTrader 5 Machine Learning Blueprint (Part 14): Transaction Cost Modeling for Triple-Barrier Labels in MQL5

The article replaces hardcoded cost assumptions in triple-barrier labeling with measured inputs. An MQL5 script captures spread distribution, swap rates, and symbol metadata from your broker, and a Python model converts them into a broker-calibrated min ret you can pass to get events. Labels then reflect the actual round-trip friction for your instrument and holding period.
preview
The MQL5 Standard Library Explorer (Part 6): Optimizing a generated Expert Advisor

The MQL5 Standard Library Explorer (Part 6): Optimizing a generated Expert Advisor

In this discussion, we follow up on the previously developed multi-signal Expert Advisor with the objective of exploring and applying available optimization methods. The aim is to determine whether the trading performance of the EA can be meaningfully improved through systematic optimization based on historical data.
preview
MQL5 Trading Tools (Part 15): Canvas Blur Effects, Shadow Rendering, and Smooth Mouse Wheel Scrolling

MQL5 Trading Tools (Part 15): Canvas Blur Effects, Shadow Rendering, and Smooth Mouse Wheel Scrolling

In this article, we enhance the MQL5 canvas dashboard with advanced visual effects, including blur gradients for fog overlays, shadow rendering for headers, and antialiased drawing for smoother lines and curves. We add smooth mouse wheel scrolling to the text panel that does not interfere with the chart zoom scale, technically an upgrade.
preview
MQL5 Trading Tools (Part 25): Expanding to Multiple Distributions with Interactive Switching

MQL5 Trading Tools (Part 25): Expanding to Multiple Distributions with Interactive Switching

In this article, we expand the MQL5 graphing tool to support seventeen statistical distributions with interactive cycling via a header switch icon. We add type-specific data loading, discrete and continuous histogram computation, and theoretical density functions for each model, with dynamic titles, axis labels, and parameter panels that adapt automatically. The result lets you overlay distribution models on the same sample and compare fit across families without reloading the tool.
preview
Overcoming Accessibility Problems in MQL5 Trading Tools (Part III): Bidirectional Speech Communication Between a Trader and an Expert Advisor

Overcoming Accessibility Problems in MQL5 Trading Tools (Part III): Bidirectional Speech Communication Between a Trader and an Expert Advisor

Build a local, bidirectional voice interface for MetaTrader 5 using MQL5 WebRequest and two Python services. The article implements offline speech recognition with Vosk, wake‑word detection, an HTTP command endpoint, and a text‑to‑speech server on localhost. You will wire an Expert Advisor that fetches commands, executes trades, and returns spoken confirmations for hands‑free operation.
preview
MQL5 Trading Tools (Part 27): Rendering Parametric Butterfly Curve on Canvas

MQL5 Trading Tools (Part 27): Rendering Parametric Butterfly Curve on Canvas

In this article, we explore the butterfly curve, a parametric mathematical equation, and render it visually on a MQL5 canvas. We build an interactive display with a draggable, resizable canvas window, supersampled curve rendering, gradient backgrounds, and a color-segmented legend. By the end, we have a fully functional visual tool that plots the butterfly curve directly on the MetaTrader 5 chart.
preview
MQL5 Trading Tools (Part 18): Rounded Speech Bubbles/Balloons with Orientation Control

MQL5 Trading Tools (Part 18): Rounded Speech Bubbles/Balloons with Orientation Control

This article shows how to build rounded speech bubbles in MQL5 by combining a rounded rectangle with a pointer triangle and controlling orientation (up, down, left, right). It details geometry precomputation, supersampled filling, rounded apex arcs, and segmented borders with an extension ratio for seamless joins. Readers get configurable code for size, radii, colors, opacity, and thickness, ready for alerts or tooltips in trading interfaces.
preview
File-Based Versioning of EA Parameters in MQL5

File-Based Versioning of EA Parameters in MQL5

This article explains how to implement parameter versioning in MQL5 using binary files and packed structures. It shows how to write and read fixed-size records with FileWriteStruct and FileReadStruct in FILE_BIN mode, including version numbers, timestamps, and a checksum. You will also see how to detect changes via checksums, append records safely, and load the latest configuration without overwriting prior settings.
preview
Overcoming Accessibility Problems in MQL5 Trading Tools (Part I): How to Add Contextual Voice Alerts in MQL5 Indicators

Overcoming Accessibility Problems in MQL5 Trading Tools (Part I): How to Add Contextual Voice Alerts in MQL5 Indicators

This article explores an accessibility-focused enhancement that goes beyond default terminal alerts by leveraging MQL5 resource management to deliver contextual voice feedback. Instead of generic tones, the indicator communicates what has occurred and why, allowing traders to understand market events without relying solely on visual observation. This approach is especially valuable for visually impaired traders, but it also benefits busy or multitasking users who prefer hands-free interaction.
preview
Building a Trade Analytics System (Part 2): How to Capture Closed Trades and Send JSON in MQL5

Building a Trade Analytics System (Part 2): How to Capture Closed Trades and Send JSON in MQL5

We build a lightweight bridge that captures closed trades in MetaTrader 5 and sends them to an external backend over HTTP as JSON. It uses OnTradeTransaction for event detection, reads details from deal history, assembles a JSON payload, and posts it via WebRequest. A local Flask API is used to test the flow, delivering a working path to move trade data outside the terminal.
preview
Introduction to MQL5 (Part 37): Mastering API and WebRequest Function in MQL5 (XI)

Introduction to MQL5 (Part 37): Mastering API and WebRequest Function in MQL5 (XI)

In this article, we show how to send authenticated requests to the Binance API using MQL5 to retrieve your account balance for all assets. Learn how to use your API key, server time, and signature to securely access account data, and how to save the response to a file for future use.
preview
MQL5 Trading Tools (Part 29): Step-by-Step Butterfly Animation on Canvas

MQL5 Trading Tools (Part 29): Step-by-Step Butterfly Animation on Canvas

In this article, we expand our butterfly animation program with a four-stage animation pipeline: sequential curve drawing, smooth wing fill fading, detailed body rendering, and continuous flight. We implement a timer-driven state machine, four oscillators for wing flapping, vertical bobbing, horizontal sway, and tilt, as well as a neon glow around the wing outlines and a cyclical color change based on hue. You will learn how to structure these effects on the MetaTrader 5 canvas for clean and controlled playback.
preview
MQL5 Trading Tools (Part 28): Filling Sweep Polygons for Butterfly Curve in MQL5

MQL5 Trading Tools (Part 28): Filling Sweep Polygons for Butterfly Curve in MQL5

We expand the capabilities of the MetaTrader 5 butterfly curve canvas by adding multi-layered wing fills, vein lines, scale dots, and a full body (abdomen, thorax, head, eyes, antennae). This article implements polygon fills with vertical and radial gradients, as well as filled circles and ellipses, all using supersampling antialiasing. You will also receive reusable MQL5 helper functions and a rendering order that transforms a simple curve into a customizable, detailed chart illustration.
preview
MQL5 Trading Tools (Part 30): Class-Based Tool Palette Sidebar

MQL5 Trading Tools (Part 30): Class-Based Tool Palette Sidebar

We refactor the Tools Palette from a flat, function-based panel into a modular, class-driven sidebar in MQL5. The design introduces supersampled canvas rendering for anti-aliased shapes, theme control, a category registry, snap alignment, and selective corner rounding. The result is a reusable, scalable sidebar foundation that you can extend with tool selection, dragging, and fly-out menus in future steps.
preview
Event-Driven Architecture in MQL5: How to Turn an Expert Advisor into a Full-Fledged Trading System

Event-Driven Architecture in MQL5: How to Turn an Expert Advisor into a Full-Fledged Trading System

The article is dedicated to the event-driven architecture in MQL5 and describes the transition from the monolithic OnTick model to distributed processing. We will consider predefined and custom events, services and messaging between programs, as well as common architectural errors. A practical example demonstrates how to organize interactions between indicators and an EA to reduce load, improve readability, and simplify maintenance.
preview
Creating a Custom Tick Chart in MQL5

Creating a Custom Tick Chart in MQL5

Learn how to implement a tick-based chart in MQL5 where each bar is built from a fixed number of ticks instead of time. The article covers creating and configuring a custom symbol, capturing real-time ticks, forming OHLC values, and pushing data with CustomRatesUpdate. This approach produces activity-driven candles that better reflect market intensity and short-term momentum for precise intraday analysis.