AI trading bot with MetaTrader 4/5: MQL scripts, Python API, and ZeroMQ bridge

Manual order placement cannot keep up with the market: while a human makes a decision, the price has already moved. We develop and configure trading bots turnkey — from analyzing your strategy to handing over a working setup. Our engineers reduce event reaction latency and keep risk under control.

AI Development Areas

Frequently Asked Questions

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1359
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1330
  • B2B Advance company logo design
    B2B Advance company logo design
    776
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1077
  • AIDER company logo development
    AIDER company logo development
    1022
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1113

MetaTrader AI Bot Integration: Where Manual Logic Breaks

MetaTrader AI bot integration doesn't break on the model — it breaks at the junction. The signal is computed, but time passes between its appearance and the order being placed: the expert advisor cycle, the call to an external module, the broker's response.

In a volatile stretch, order execution delay of fractions of a second shifts the entry price, and the strategy's calculated return stops matching the actual one.

The second failure point is less visible — desynchronization of trading logic. Position size is calculated against one account state but executed against another; stop, take, and multiplier are set in two places and drift after a connection drop.

The error accumulates quietly: individual trades look correct, while the total diverges from expectations.

Slippage finishes off the result across a series: each trade loses a little, but over a long sample it eats away the entire edge of the strategy.

And almost always there is no trading decision log — reconstructing what the signal was and why the bot entered right there becomes impossible a day later.

Separately, there's the risk of manual input. An operator sees a drawdown, intervenes, and changes the strategy's statistics, while no trace of the intervention remains: the model and the live account start living separate lives. Let's break down how this gets closed.

The Effect of Automation: Event Response and Risk Control

Event response stops depending on whether a human is at the screen.

The expert advisor in MetaTrader takes the signal from the model and places the order within the first seconds after the candle closes, whereas manual confirmation took tens of seconds and filled at a noticeably worse price. In a volatile market, that's a direct difference in the strategy's result.

Manual operations are the main source of divergence between intent and fact. A missed entry, a miscalculated size, a forgotten protective order — each such case distorts the statistics, and decisions are then made on that distorted data.

We move the entire cycle into code: signal, size calculation, and protective order placement run along a single execution branch, so the share of manual errors goes to zero rather than "to an acceptable level."

Risk control is set at trade entry, not based on the day's results.

Size is calculated from the current balance and the allowable drawdown per position, stop and target are placed together with the order, and a cap on the number of simultaneous positions keeps the strategy from overheating. Change the risk profile and the parameters change; the entry logic stays the same.

Execution predictability matters more than peak profits: the same signal is processed identically regardless of who is watching the chart. Position state is restored from the journal after a terminal restart, and duplicate orders are not created.

This removes an entire class of failures — a connection drop or terminal crash no longer leaves a position unattended.

Taken together, this is a managed drawdown instead of a hope for discipline.

Divergences between a historical run and live trading are explained by market conditions rather than the human factor, so strategy tuning rests on measurable values: reaction time, share of automated trades, deviation of actual risk from the specified one.

Bot Connection Options: Comparing Operating Modes

The connection mode determines where the bot's logic executes, who is responsible for the link to the broker, and what happens when the channel drops. In practice, the choice is between three schemes — from a fully client-side perimeter to a dedicated service on our side.

Mode When it fits Limitations
Client's trading terminal The terminal is already deployed on your server, full control over the account, history, and settings is required Everything depends on a single channel and a single node: a terminal restart or loss of connection halts the signal flow, and updates and log analysis fall on your side
Dedicated service on our side Multiple strategies and accounts, round-the-clock monitoring and a clear point of responsibility are needed The client's trading terminal is not directly involved — account access is granted via keys with agreed permissions and limits
Hybrid with channel redundancy Downtime is unacceptable: two independent channels, automatic failover, continuity of trades More complex setup and position state synchronization; every failover must be logged and reconciled with the broker

The choice is dictated by the allowable downtime and the requirements for where the keys are stored. We start from how many minutes without signals is acceptable to you, and select the mode and depth of redundancy accordingly.

Implementation Stages: From Strategy Review to Handover

The order of stages here matters more than speed: an error in entry rules is cheaper to find on a diagram than on a live account. That's why we don't start writing code until the strategy logic, failure points, and the criteria by which the result is deemed correct are locked in. Each step closes with an artifact — without it, the next one doesn't begin.

  1. Trading strategy audit. We break down entry and exit rules, position size calculation, and trading halt conditions. Ambiguous wording goes into a decision protocol: divergences from expectations usually come from there.
  2. System interaction diagram. We determine who is the source of truth for a position, how commands travel between the MetaTrader terminal and the external service, and what happens when the channel drops and a command is resent.
  3. Logic implementation. We move the agreed rules into code with a log of every decision and its reason. Orders are made idempotent: a repeated command does not open a second position.
  4. Test perimeter. We assemble a separate perimeter on a demo account — the same code, but with emulated delays, connection drops, and reconnects.
  5. Historical validation. A run that accounts for spread, commission, and slippage: we look at drawdown and the distribution of trades. History shows where the rules break on rare scenarios.
  6. Launch on a small volume. Minimal volume, reconciliation of actual behavior against the model, divergences analyzed via logs until the cause is found.
  7. Handover. We deliver configurations, the interaction diagram, the halt procedure, and documentation, and we train your team to operate it.

What We Hand Over: Configurations, Diagrams, Procedures

A working bot without documentation is a black box that's frightening to touch. That's why at acceptance we hand over not just the code but a set of artifacts your team can use to configure, halt, and restore trading on its own.

  • Logic documentation: how the signal is formed, which filters cut it off, what the position size depends on, and what happens when market data is missed.
  • Interaction diagram: trading terminal — expert advisor — server-side service — brokerage account; failure points, behavior on a connection break, and the resynchronization procedure.
  • Access policies: roles and rights on the trading account, key storage and rotation, rules for manual intervention in open positions.
  • Halt and recovery procedure: correct withdrawal of the bot from trading, the fate of unclosed positions, service startup, and state verification after a failure.
  • Operations manual: typical operations, where to look at logs, which metrics to check at the start of the day, and what to react to immediately.
  • Configurations: risk parameters, instrument list, and "demo / live" modes — in separate files, changed without editing code.
  • State monitoring and alerts: the list of tracked metrics, trigger thresholds, and notification recipients.
  • Change protocol: how a logic edit is run against history and by which metrics the decision to roll back a version is made.

We walk through each item at handover and record it in the acceptance report — after acceptance, day-to-day operation requires no contact with us.

Case Study: How Order Execution Delay Was Reduced

The client ran a portfolio of several strategies in MetaTrader 5 and made decisions manually: a signal arrived, the trader checked it against the market, and only then placed the order.

In a calm market this worked, but on news spikes seconds passed between signal and order, and some entries were lost between the terminal and the trade log.

Where Exactly the Result Was Lost

A review of one month's records showed: up to a quarter of signals never reached the broker, and another portion filled at a price noticeably different from the calculated one.

Nobody measured the divergence between what the strategy "decided" and what actually made it into a position — reproducing a good day on history was impossible. The result depended on human reaction, not on rules.

What Was Changed and What Came Out of It

The signal evaluation logic was moved out of the terminal into a separate Python service, and the link to the trading terminal was built through a message-exchange bridge: the terminal provides quotes and position statuses, the service returns ready orders.

Before placing an order, checks were added for price deviation, position size, and duplicates, and every decision is written to a log with its reason — from it, a trade can be reconstructed step by step.

After the migration, reaction time dropped from seconds to fractions of a second, and the share of missed signals fell to isolated cases per month.

A control run on the same data shows trade-to-actual matches above 95% — changes to the rules are now validated on history before going live.

What If the Bot Is Already Running Manually?

Working logic isn't rewritten from scratch — it's wrapped.

The expert advisor in MetaTrader keeps computing signals and placing orders by the previous rules, while a service stands up alongside it that reads these events through the bridge and gradually takes over decision-making.

The terminal remains the execution point and the position store, so trading isn't interrupted at any iteration.

The fate of open positions is decided separately: they are neither closed nor reopened. On startup, the new logic reads the position table and order history straight from the terminal, reconciles them with its own state log, and marks each one as inherited or its own.

Order tags and separate ID ranges keep the two versions from duplicating an entry or fighting over the same instrument.

The transition is done gradually. First, the new perimeter works as an observer: it computes signals and logs where its decision matched the manual one and where it diverged — divergences are analyzed before the switch, not after.

Then handover proceeds by symbol and chart timeframe: one instrument is run by the new logic, the rest by the old one; any perimeter may close positions, but only the designated owner may open them.

Rollback takes a single operation: a flag returns control to the old expert advisor, and the terminal trades autonomously even when the bridge is unavailable.

This removes the main risk of transition — not data loss, but two opposing positions opening simultaneously on the same instrument.

Describe your current logic and its weak points — we'll come back with a migration plan and an estimate.

Technical Doubts: Access, Tests, Responsibility

Before the start, we lock in the boundaries: the MQL expert advisor runs on the MetaTrader terminal side, the analytical perimeter runs as a separate Python service, and the exchange goes through a local bridge.

Access is granted in the minimal scope needed for trading, and any divergence is analyzed through logs, where every model decision is visible together with the broker's response.

What scope of access to the terminal is needed?

Only launching the expert advisor, reading order history, and trading access within the account. Withdrawals, password changes, and account settings remain with you: the service doesn't need those rights either during debugging or in operation.

What happens if the connection to the broker or the bridge drops?

The expert advisor keeps a local state log and does not open new positions until the connection is restored. Protective stops are already on the broker's side, so open trades remain covered.

After the connection is back up, we reconcile positions by order number and clear the desync — trades closed on one side are not duplicated.

How are keys transferred and what happens to them afterward?

Secrets are stored in a secure vault and never end up in code or in the repository. Transfer goes over a secure channel, access is granted for a specific perimeter, and it is revoked immediately after the work is accepted; key rotation is a routine procedure, not a one-off event.

Where is the boundary of responsibility and how are incidents analyzed?

We are responsible for the correctness of the logic, the availability of the perimeter, and recovery after failures. Market risk and strategy decisions remain with you.

Analysis is done through logs: time, order number, broker response, and configuration version — they show whether it was an execution failure or a market move, and what exactly we fix.

Let's Discuss the Task: A Validation Perimeter and a Work Plan

So that the estimate and work plan rest on facts rather than guesses, we start with a short review of the current setup: how entry and exit decisions are made, where the terminal runs, what the broker constrains.

From this data we assemble a diagram of how the expert advisor links to the model and lock in the order of work.

The input data to start — what you already have and that needs no separate preparation:

  • the list of instruments and timeframes the strategy runs on;
  • the current entry and exit logic: rules, indicators, points of manual intervention;
  • where the terminal is hosted — a workstation, a rented server, or a separate node, and whether remote access exists;
  • account type and broker constraints: minimum step, holds, cap on the number of orders per unit of time;
  • which data streams are needed beyond quotes — news, macro statistics, volume profile;
  • the trade log for the past period: it shows where the stated rules diverge from actual execution.

In response comes a work plan: stages, artifacts at each of them, timelines, and the points where your decision is needed.

The order is this: review of data and rules, a prototype of the logic on history, a test run on a demo account in a live quote stream, and only after the results match — going live on the working account with written-in risk limits.

The test run is a separate stage: on it we check not profitability but the behavior of the perimeter — order execution, connection drops, correct restart after a failure.

Describe the task in free form — we'll come back with an estimate, a work plan, and a clear order of stages.