This repository is an article-derived reference project based on the original MQL5 article. It does not claim to reproduce the full original source code unless files are explicitly attached.
## Overview
This project documents a semi-automated remote voice-command trading pipeline for MetaTrader 5. The architecture links a Telegram voice message to a local Python middleware, which transcribes and parses the message, exposes commands over HTTP, and lets an MQL5 Expert Advisor poll, execute, and return results.
The design targets low-bandwidth remote control and accessibility use cases, especially when the trader is away from the desktop terminal.
## Original Article
- **Article ID:** 22388
- **Author:** Clemence Benjamin
- **Publication date:** 2026.05.26
- **Category:** Python / Experts
- **URL:** https://www.mql5.com/en/articles/22388
## Repository Purpose
This repository serves as a reference reconstruction of the solution described in the article:
- a **Python middleware** that combines:
- Telegram bot polling
- voice-note download and conversion
- speech-to-text transcription
- natural-language command parsing
- local HTTP server endpoints
- an **MQL5 Expert Advisor** that:
- polls the middleware with `WebRequest`
- parses JSON commands
- executes trades through `CTrade`
- posts execution results back to the middleware
It is useful as a study reference for:
- Telegram-to-MT5 integration
- pull-based command delivery in MQL5
- low-bandwidth remote trade control
- accessibility-oriented trading workflows
## Key Concepts
- Pull-based HTTP polling from MQL5
- Telegram voice-note handling
- Speech recognition via Python
- Audio conversion with `ffmpeg` and `pydub`
- JSON-based command exchange
- Cross-language integration between Python and MQL5
- Remote order execution with `CTrade`
- Simple in-memory queueing and result synchronization
- Risk reduction through default micro-lot sizing
## Algorithm / Architecture Summary
1. A user sends a Telegram voice message.
2. The Python bot downloads the `.ogg` file.
3. The middleware converts audio to 16 kHz mono WAV.
4. Speech is transcribed using Python speech recognition.
5. Parsed text is converted into a JSON command such as:
-`BUY`
-`SELL`
-`CLOSE_ALL`
-`BALANCE`
6. The command is placed into an in-memory queue.
7. The MQL5 EA polls `GET /get_command` every 2 seconds.
8. If a command is available, the EA:
- parses JSON using `JAson.mqh`
- executes the requested action
- builds a JSON response
9. The EA sends the result to `POST /post_response`.
10. The Telegram bot returns the outcome to the user.
Important implementation note highlighted in the article:
-`StringToCharArray` in MQL5 appends a null terminator, which must be stripped before POSTing JSON to Python.