AI agents around MT5 — where should the execution boundary be?

I'm experimenting with something a bit different around MetaTrader 5 and I'd really like to hear how other MT5 developers would approach it.

I'm building a local multi-agent setup where different agents have different jobs.

For example:

  • one watches financial news;

  • another tries to judge whether a headline may matter for a specific instrument;

  • a Trader agent monitors the MT5 account and open positions;

  • another agent helps with MQL5 / MT5-Python development.

The part I'm still thinking carefully about is execution.

I don't want to give an LLM direct unrestricted access to MetaTrader 5.

So right now the Trader has two separate capabilities:

mt5_query — read-only access to account state, positions and orders.

mt5_signal — it can submit a trade request, but it doesn't directly decide whether that request is allowed to reach MT5.

There is a separate deterministic execution layer between the agent and the terminal.

That layer checks things like spread, daily loss limits, position limits, stop loss requirements and current account state.

If the request fails one of those checks, it is rejected and the agent is not allowed to just keep retrying it.

At the moment I'm also keeping actual execution human-triggered. The agents can monitor, analyse and reason on their own, but a trade still needs an explicit human request.

I'm only testing this on demo accounts for now.

The rough flow looks like this:

Financial news
→ News Watcher
→ News Analyzer
→ Trader
→ risk/execution layer
→ MetaTrader 5

What I'm curious about is how people here would design the boundary.

Would you keep all risk and execution logic completely deterministic and outside the AI layer?

Would you ever let the agent submit trade proposals automatically if the deterministic layer still has final authority?

And for those of you who have built serious MT5 automation, what checks would you consider absolutely mandatory before allowing an external agent system anywhere near an account?

I'm more interested in architecture and failure modes here than in trading strategy or profitability.

Iliya Nedelchev:
Would you keep all risk and execution logic completely deterministic and outside the AI layer?

Yes without a doubt.

Iliya Nedelchev:
Would you ever let the agent submit trade proposals automatically if the deterministic layer still has final authority?

Why not ? That's the right pattern.

Why would anyone let a non deterministic system automatically control a trading account in any way ? 

Iliya Nedelchev:

I'm experimenting with something a bit different around MetaTrader 5 and I'd really like to hear how other MT5 developers would approach it.

I'm building a local multi-agent setup where different agents have different jobs.

For example:

  • one watches financial news;

  • another tries to judge whether a headline may matter for a specific instrument;

  • a Trader agent monitors the MT5 account and open positions;

  • another agent helps with MQL5 / MT5-Python development.

The part I'm still thinking carefully about is execution.

I don't want to give an LLM direct unrestricted access to MetaTrader 5.

So right now the Trader has two separate capabilities:

mt5_query — read-only access to account state, positions and orders.

mt5_signal — it can submit a trade request, but it doesn't directly decide whether that request is allowed to reach MT5.

There is a separate deterministic execution layer between the agent and the terminal.

That layer checks things like spread, daily loss limits, position limits, stop loss requirements and current account state.

If the request fails one of those checks, it is rejected and the agent is not allowed to just keep retrying it.

At the moment I'm also keeping actual execution human-triggered. The agents can monitor, analyse and reason on their own, but a trade still needs an explicit human request.

I'm only testing this on demo accounts for now.

The rough flow looks like this:

Financial news
→ News Watcher
→ News Analyzer
→ Trader
→ risk/execution layer
→ MetaTrader 5

What I'm curious about is how people here would design the boundary.

Would you keep all risk and execution logic completely deterministic and outside the AI layer?

Would you ever let the agent submit trade proposals automatically if the deterministic layer still has final authority?

And for those of you who have built serious MT5 automation, what checks would you consider absolutely mandatory before allowing an external agent system anywhere near an account?

I'm more interested in architecture and failure modes here than in trading strategy or profitability.

Agree with Alain, and the boundary you describe is the right one. From building a similar setup, a few checks turned out to matter more than I expected, beyond spread, loss limits and SL:

1. Idempotency. Agents retry. Give every signal an ID and have the execution layer refuse an ID it has already seen, otherwise one timeout becomes two positions.
2. Staleness. Stamp each signal with the price and time it was based on. Reject it if it is older than a few seconds or the price has moved more than X points since. An agent that thinks for 20 seconds is trading an old market.
3. The risk numbers come from the terminal, not the agent. Equity, open risk and daily P/L should be read by the execution layer itself (AccountInfoDouble, PositionsTotal) at the moment of the order, never taken from what the agent reports.
4. A kill switch the agent cannot reach. If the daily limit is hit, the layer stops accepting signals until the next session, no matter what the agent sends.
5. Log every rejection with its reason. That log is what tells you whether the agent or the rules need changing.

Keeping the agent able to read and propose but never send was the single best decision in mine.