Discussing the article: "From Signal to Trade via a Chain of Agents: LangChain Architecture on Top of MQL5"

Check out the new article: From Signal to Trade via a Chain of Agents: LangChain Architecture on Top of MQL5.

The article describes an architecture in which the MQL5 Expert Advisor (EA) handles only data collection and execution, while the logic is moved to a Python server with three LangChain agents: a signal agent, a news agent, and a risk manager. Agents process the WebSocket request sequentially; if any agent rejects it, "hold" is returned. Decisions and actual PnL are stored in SQLite, forming memory and statistics. The reader will receive an interaction diagram, a command protocol, and a feedback approach.

Integrating an LLM with MetaTrader usually boils down to a simple scenario: the Expert Advisor (EA) asks the model for a "BUY/SELL" answer and executes it. This decision-making scheme falls apart under the first non-standard conditions — a widened spread, the release of important economic data in 10 minutes, already open positions, or a drawdown exceeding the acceptable limit.

The requirements for a practical algorithmic trader are specific here: trade on the M15–H1 timeframes while accounting for the delay in LLM calls (the chain may take 30–90 seconds), check for news within the next 10 minutes, allow no more than 3 open positions with risk per trade at ≈1%, and maintain a history of decisions and their outcomes.

The decision is to separate "thinking" from "execution," pass each decision through three independent filters (Signal → News → Risk), record every decision in SQLite with decision_id and close the loop via the command RESULT. This requirement defines the architecture and verification criteria; it is not merely an abstraction.


Author: Yevgeniy Koshtenko