130 lines
4.8 KiB
Markdown
130 lines
4.8 KiB
Markdown
# Article-22388-Telegram-Voice-Trading-MT5-Accessibility
|
|
|
|
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.
|
|
|
|
## Mentioned or Attached Files
|
|
|
|
### Explicitly attached files
|
|
|
|
- `telegram_trading_bot.py` — Python 3 middleware script
|
|
- `OvercomingAccessibilityIV.mq5` — MQL5 Expert Advisor
|
|
- `JAson.mqh` / `Jason.mqh` — third-party JSON parser referenced from MQL5 CodeBase
|
|
|
|
### Mentioned in text
|
|
|
|
- `MQL5\Include\OvercomingAccessibilityIV\JAson.mqh`
|
|
- `MQL5\Experts\OvercomingAccessibilityIV.mq5`
|
|
|
|
## Statistics
|
|
|
|
- **Polling interval:** 2 seconds
|
|
- **Typical round-trip latency:** 1.5-4.2 seconds
|
|
- **HTTP round-trip + trade execution:** 50-200 ms
|
|
- **Bandwidth per poll request:** ~200 bytes
|
|
- **Empty queue response size:** ~20 bytes
|
|
- **Full trade cycle bandwidth:** less than 30 KB
|
|
- **Voice download size:** ~10-30 KB
|
|
- **Python version:** 3.10+
|
|
- **HTTP server bind address:** `127.0.0.1:8082`
|
|
|
|
## Tags
|
|
|
|
`MQL5` `MetaTrader5` `Telegram` `Python` `WebRequest` `Voice-Control` `Accessibility` `JSON` `CTrade` `Speech-Recognition`
|
|
|
|
## Difficulty
|
|
|
|
**Intermediate**
|
|
|
|
Requires familiarity with:
|
|
- MQL5 Expert Advisor development
|
|
- Python environment setup
|
|
- HTTP/JSON communication
|
|
- Telegram bot configuration
|
|
- Windows dependency setup for `ffmpeg`
|
|
|
|
## Limitations
|
|
|
|
- This is an article-derived reference project; the README reflects the article content and attached file list.
|
|
- Full original repository structure is not available unless the attached files are actually present in this processed input.
|
|
- The solution depends on a continuously running Windows machine with MetaTrader 5 open.
|
|
- The architecture uses polling, so execution latency includes the polling interval.
|
|
- The speech recognition path described in the article uses external Google STT through Python libraries.
|
|
- The JSON parser include is third-party and must be obtained separately if not bundled.
|
|
- If no attached source files are present in this repository snapshot, then no attached source files were available in the processed input.
|
|
|
|
## Reference
|
|
|
|
- MQL5 article: https://www.mql5.com/en/articles/22388
|
|
- MQL5 CodeBase reference for JSON parser: https://www.mql5.com/en/code/13663
|
|
|