* Add comprehensive README documentation * Describe the EA purpose and architecture * Document supported trading intents and workflow * Explain configuration requirements and input parameters * Outline current limitations and future extension points
90 lines
3.7 KiB
Markdown
90 lines
3.7 KiB
Markdown
# AI Telegram Signal Copier Expert Advisor
|
|
|
|
## Overview
|
|
|
|
The AI Telegram Signal Copier is a MetaTrader 5 Expert Advisor that automatically retrieves AI-parsed trading signals from a Flask backend and executes them on a trading account.
|
|
|
|
The Expert Advisor forms the execution layer of the system. It periodically polls the backend for new trading signals, converts the received trading intent into the appropriate MetaTrader 5 order type, executes the trade, notifies the user of the outcome, and reports the execution status back to the backend.
|
|
|
|
The Expert Advisor is designed to work with a backend that has already processed Telegram messages using the OpenAI API and converted them into a structured JSON format.
|
|
|
|
## Features
|
|
|
|
* Periodically polls a Flask REST API for pending trading signals.
|
|
* Parses structured JSON responses.
|
|
* Supports market and pending orders.
|
|
* Resolves broker-specific symbol names automatically.
|
|
* Executes trades using the MetaTrader 5 Trade library.
|
|
* Reports execution status back to the backend.
|
|
* Displays execution information using Print(), Alert(), and SendNotification().
|
|
* Prevents duplicate execution of previously processed signals.
|
|
|
|
## Supported Trading Intents
|
|
|
|
The Expert Advisor currently supports the following trading intents:
|
|
|
|
* BUY_MARKET
|
|
* SELL_MARKET
|
|
* BUY_LIMIT
|
|
* SELL_LIMIT
|
|
* BUY_STOP
|
|
* SELL_STOP
|
|
|
|
The backend determines the trading intent, while the Expert Advisor converts it into the appropriate MetaTrader 5 order type based on current market conditions.
|
|
|
|
## Input Parameters
|
|
|
|
| Parameter | Description |
|
|
| ------------- | ------------------------------------------------------- |
|
|
| InpApiBaseUrl | Base URL of the Flask backend. |
|
|
| InpLotSize | Fixed lot size used for every trade. |
|
|
| InpTimerSec | Polling interval, in seconds, for checking new signals. |
|
|
| InpVerboseLog | Enables detailed logging in the Experts tab. |
|
|
|
|
## Processing Workflow
|
|
|
|
The Expert Advisor performs the following steps repeatedly:
|
|
|
|
1. Poll the backend for the next pending signal.
|
|
2. Parse the returned JSON response.
|
|
3. Ignore duplicate signals that have already been processed.
|
|
4. Resolve the broker-specific trading symbol.
|
|
5. Determine the appropriate MetaTrader 5 order type.
|
|
6. Execute the trade.
|
|
7. Notify the user of the execution result.
|
|
8. Send the execution status back to the backend.
|
|
|
|
## Requirements
|
|
|
|
Before using the Expert Advisor:
|
|
|
|
* Enable WebRequest in MetaTrader 5.
|
|
* Add the backend URL to the list of allowed URLs.
|
|
* Ensure the Flask backend is running and accessible.
|
|
* Configure MetaTrader push notifications if mobile notifications are required.
|
|
|
|
## Current Limitations
|
|
|
|
This Expert Advisor is intended as a reference implementation accompanying an educational article series.
|
|
|
|
The current version does not include:
|
|
|
|
* Dynamic position sizing.
|
|
* Spread validation.
|
|
* Trading session filtering.
|
|
* Duplicate signal detection across backend restarts.
|
|
* Retry logic for failed network requests.
|
|
* Advanced broker symbol mapping rules.
|
|
* Risk management based on account balance or equity.
|
|
|
|
These features can be added without changing the overall architecture of the Expert Advisor.
|
|
|
|
## Purpose
|
|
|
|
The purpose of this project is to demonstrate how MetaTrader 5 can communicate with external AI services through a REST API to automate trade execution from natural language trading signals.
|
|
|
|
The implementation prioritizes clarity, maintainability, and extensibility, making it a suitable foundation for developers who wish to build more advanced AI-assisted trading systems.
|
|
|
|
## License
|
|
|
|
This project is provided for educational purposes. Always test the Expert Advisor thoroughly on a demo account before using it in a live trading environment.
|