Execution Agents, Slippage, and Real Fill Quality in MetaTrader 5

Execution Agents, Slippage, and Real Fill Quality in MetaTrader 5

25 August 2026, 00:49
Michael Prescott Burney
0
11
Execution Agents, Slippage, and Real Fill Quality in MetaTrader 5

A signal can be correct and still lose money through poor execution. A strategy may identify the right direction and a valid setup, but the real result can be damaged by spread expansion, commission, slippage, latency, rejected orders, partial fills, or an entry that arrives after the opportunity has changed.

An execution agent focuses on whether, when, and how a validated trade intent should become an order under current MetaTrader 5 and broker conditions. It does not invent a new strategy, override account-risk authorization, or create unconstrained order types. It selects only from predefined tactics, such as execute now, use a limit order, reduce size, wait briefly, or cancel.

This article is an educational software-architecture guide for MQL5 developers and systematic traders. It is not financial or investment advice. Real fills, liquidity, spread, slippage, and broker execution vary by symbol, account type, broker, market session, and conditions. Test all execution policies in controlled environments before any live use.

The Role of an Execution Agent

An execution agent is not a signal generator. It receives a trade intent that has already passed strategy, portfolio, and risk authorization. Its job is to decide whether current trading conditions permit the intent to be executed according to a bounded policy.

A safe execution flow is:

VALIDATED TRADE INTENT → LIVE EXECUTION SNAPSHOT → EXECUTION POLICY → MT5 ORDER REQUEST → BROKER RESPONSE → RECONCILIATION → EXECUTION AUDIT

The execution agent should never be allowed to:

  • Change the approved symbol or direction.
  • Increase risk beyond the authorized maximum.
  • Remove or widen an approved stop-loss.
  • Ignore daily loss, portfolio exposure, or kill-switch limits.
  • Invent a new order type outside the strategy’s permitted tactics.
  • Chase price after the trade intent has expired.

The execution agent can only act within the bounded intent and current execution policy.

Why Fill Quality Matters

Backtests and chart reviews often show an ideal entry price. Live trading is different. The price available when a decision is made may not be the price received when the broker confirms the order.

Execution quality affects:

  • Actual entry price.
  • Actual exit price.
  • Position size that can be filled.
  • Time spent exposed before a fill.
  • Probability that a limit order is missed.
  • Risk-to-reward remaining after the entry moves.
  • Stop-loss outcome during fast or illiquid conditions.
  • Net strategy performance after real transaction costs.

A signal that is profitable at an idealized price may be unprofitable once real spread, commission, slippage, rejected orders, and decision-to-fill latency are included.

Execution Architecture

A robust system separates intent, execution assessment, order policy, and broker interaction.

Component Responsibility Must Not Do
Strategy and risk layers Create and authorize a bounded trade intent with direction, risk cap, stop logic, and expiry. Assume the intent can be filled under any market condition.
Execution snapshot Collect current bid, ask, spread, session, symbol rules, order health, and freshness data. Use stale quotes or cached execution conditions without validation.
Execution agent Select an approved execution tactic or cancel based on the live snapshot. Change strategy logic, increase risk, or create undefined tactics.
Order policy Translate the approved tactic into a broker-valid MT5 request. Silently convert a denied or expired intent into a market order.
Execution adapter Send the request, inspect broker result codes, and reconcile orders, deals, and positions. Assume a successful function call means a filled trade.
Execution audit Measure arrival price, fill quality, latency, cost, and outcome by context. Evaluate fills only against a later bar close.

Define a Bounded Trade Intent

The execution agent needs a precise contract. A vague instruction such as “buy EURUSD when conditions are good” is not enough. The trade intent should specify what has already been approved and what tactical flexibility remains.

Recommended Intent Fields

  • Unique intent ID and parent signal or decision-graph ID.
  • Strategy ID, policy version, and execution-policy version.
  • Symbol and direction.
  • Decision timestamp in UTC.
  • Arrival benchmark price or bid/ask pair at intent creation.
  • Maximum signal and intent validity window.
  • Authorized maximum risk and permitted volume range.
  • Approved stop-loss and target or exit-policy identifier.
  • Approved entry zone and maximum allowed price drift.
  • Permitted order tactics: market, limit, wait, reduce, or cancel.
  • Maximum limit-order wait period, if limit use is allowed.
  • Maximum acceptable spread and maximum expected adverse slippage.
  • Correlation ID for audit and idempotency.

The execution agent should not expand this contract. It may choose a permitted tactic, but it should not create a broader risk authorization.

What an Execution Snapshot Should Observe

The execution snapshot describes current conditions at the moment the system considers sending an order. It should be timestamped and short-lived.

Useful observations include:

  • Current bid, ask, last price where relevant, and spread in points or pips.
  • Current spread relative to fixed limits and session-specific percentile baseline.
  • Tick activity, quote frequency, and time since the last valid tick.
  • Recent adverse and favorable slippage by symbol and order type.
  • Depth of market or order-book data where available and relevant.
  • Current session, rollover condition, market open or close proximity, and holiday state.
  • Symbol trade mode, allowed order types, stops level, freeze level, and filling mode.
  • Recent broker response codes and order rejection rate.
  • Connection state and terminal trading permissions.
  • Time remaining before the trade intent expires.
  • Current price drift from the arrival benchmark and approved entry zone.
  • Current account margin and any updated portfolio or risk-state restriction.

Not every broker or symbol provides depth data. Do not make the architecture depend on unavailable information. Use only fields that are observable, reliable, and appropriate for the instrument.

Execution Tactics Must Be Predefined

The execution agent may select among tactics already approved by the strategy and risk policy. This creates controlled flexibility without letting the system improvise.

Tactic When It May Be Allowed Key Trade-Off
Execute now Spread, price drift, freshness, and execution conditions are within the approved bounds. Prioritizes participation but may accept slippage.
Use limit order Price control is more important than immediate participation and the strategy allows a potential missed fill. Controls worst acceptable price but may not fill.
Reduce size A preconfigured reduced-risk state is active and the strategy permits a smaller authorized volume. Reduces exposure but does not make a poor fill acceptable.
Wait briefly Transient conditions may normalize within a defined short window and the signal remains fresh. Can reduce spread cost but increases risk of staleness and missed opportunity.
Cancel Spread, price drift, latency, market state, or broker conditions exceed policy limits. Misses the trade but avoids an uncontrolled or degraded entry.

Do not use “wait briefly” as vague discretion. Define the maximum duration, sampling interval, acceptable normalization condition, and expiration behavior. When the intent expires, cancel it rather than chasing price.

Market Orders and Limit Orders

Order selection is a trade-off between certainty of execution and certainty of price. The right choice depends on the setup, horizon, broker conditions, and strategy rules.

Market Orders

A market order seeks execution at the best available current price. It prioritizes obtaining a fill, not receiving the exact visible quote. In fast or thin conditions, the actual price can differ from the arrival benchmark.

Market orders may be appropriate when:

  • The strategy has a sufficiently wide entry tolerance.
  • The remaining reward remains acceptable after expected cost.
  • Spread and recent slippage are within configured limits.
  • The decision has a time-sensitive horizon and the model or setup is still fresh.

Limit Orders

A limit order controls the worst acceptable entry price. For a buy limit, it aims to fill at the limit price or lower; for a sell limit, it aims to fill at the limit price or higher. A limit order may not fill, especially if price moves away or touches the level without enough available liquidity.

Limit orders may be appropriate when:

  • The strategy is designed around pullback or retest location.
  • Price control is more important than participation.
  • The system can tolerate missed trades.
  • The limit price, expiration, and stop-loss are valid under broker rules.

A limit order is not automatically cheaper or safer. A missed fill can be a real opportunity cost, and a fill after a changed market condition may no longer be desirable. Use a validity window and cancel or revalidate pending orders according to policy.

Arrival Price Is the Core Benchmark

Evaluate execution against an arrival benchmark: the price available when the validated order intent was created. For a buy intent, the relevant arrival price is normally the ask. For a sell intent, it is normally the bid.

The arrival benchmark captures the real decision point. It answers: how much did the system pay or give up between deciding to trade and receiving the fill?

Do not compare a fill only with the next bar’s close. The next close includes market movement after the decision and can hide or exaggerate actual execution cost.

Implementation Shortfall

Implementation shortfall measures the difference between the arrival benchmark and the actual execution result, plus relevant direct costs. It turns execution into a measurable component rather than an invisible source of variance.

For a buy entry, a simplified adverse price shortfall is:

Buy entry shortfall = actual fill price - arrival ask price.

For a sell entry, a simplified adverse price shortfall is:

Sell entry shortfall = arrival bid price - actual fill price.

Positive values in these examples represent a worse fill relative to the arrival quote. To estimate a fuller implementation shortfall, add commission, fees, and relevant financing or conversion costs.

For an order that is not filled, record the outcome separately as an opportunity or non-fill metric rather than pretending the system received a zero-cost fill.

Example: Buy Intent and Adverse Slippage

Suppose a validated EURUSD buy intent is created when the ask is 1.08010. The execution agent checks conditions and sends a market order. The broker fills at 1.08018.

  • Arrival ask: 1.08010.
  • Actual fill: 1.08018.
  • Adverse price difference: 0.00008, or 0.8 pips in this simplified example.

If the strategy has a small target, 0.8 pips of shortfall can materially affect profitability. The system should also record the spread, commission, execution time, order type, session, and current volatility so the result can be grouped later.

Measure the Whole Decision Path

Execution cost is not only the difference between a request and a fill. The complete path includes time and state changes between decision and broker response.

Measure:

  • Time of validated trade intent.
  • Arrival bid and ask at intent creation.
  • Time execution snapshot was collected.
  • Time the execution tactic was selected.
  • Time the MT5 order request was sent.
  • Time broker response was received.
  • Actual fill time, where available.
  • Requested versus actual price.
  • Requested versus actual volume.
  • Final order, deal, and position status.

Then calculate decision-to-fill latency, request-to-response latency, and price movement during each interval. A strategy may be slow because of model inference, bridge messaging, risk checks, terminal scheduling, or broker execution. Each component should be visible.

Key Execution Metrics

Track execution quality by symbol, session, order type, volatility condition, strategy, and broker account. A single average can hide conditions where a system is consistently weak.

Metric What It Measures Why It Matters
Implementation shortfall Difference between arrival benchmark and realized fill, including relevant costs. Measures the real cost of turning an intent into a trade.
Fill rate Percentage of eligible intents that receive a fill. Important for limit-order and wait policies.
Partial-fill rate Frequency and size of orders not fully filled as requested. Shows whether volume assumptions are realistic.
Rejection rate Percentage of order requests rejected by broker or policy. May reveal invalid request construction, weak broker conditions, or strategy mismatch.
Adverse slippage Worse-than-arrival price movement at fill. Can remove a small historical edge.
Favorable slippage Better-than-arrival price movement at fill. Should be recorded too; do not analyze only adverse events.
Decision-to-fill latency Elapsed time between validated intent and confirmed fill. Indicates whether the system fits the strategy horizon.
Cancel rate Percentage of intents canceled because policy conditions were not met. Shows how often live execution conditions invalidate the theoretical setup.

Track Metrics by Context

Execution quality changes with context. Record and group metrics by:

  • Symbol and broker-specific symbol name.
  • Direction: buy or sell.
  • Order type and execution tactic.
  • Trading session and hour of day.
  • Day of week, rollover period, market open, and market close.
  • Spread percentile at decision time.
  • Volatility regime and tick-activity state.
  • Scheduled event or news proximity.
  • Intent age and decision-to-fill latency.
  • Requested volume and actual volume.
  • Strategy version, execution-policy version, and broker account type.

For example, an execution policy may be acceptable on EURUSD during a liquid overlap but unreliable during rollover or a major release. The data should reveal that distinction.

Spread Is Only One Cost

Spread is visible, but it is not the only execution cost. A strategy should be evaluated after:

  • Bid-ask spread.
  • Opening and closing commission.
  • Adverse and favorable slippage.
  • Partial fills and missed fills.
  • Rejections and the cost of delayed or abandoned entries.
  • Overnight financing or swap where positions are held past rollover.
  • Currency conversion and operational fees where applicable.
  • Latency between decision and fill.

The core metric is simple:

Model edge must be measured after spread, commission, slippage, rejected orders, and the latency between decision and fill.

Execution Agent Decision Rules

Execution-agent behavior should be deterministic, versioned, and easy to audit. A policy can combine several observable conditions without becoming open-ended.

Example decision rules:

  • If signal is expired, cancel the intent.
  • If current price has moved beyond the approved entry zone, cancel the intent.
  • If spread exceeds the configured maximum, cancel or wait only if waiting is explicitly allowed.
  • If risk state is reduced, use only the pre-approved reduced volume cap.
  • If current margin or portfolio state has changed, return the intent to the risk gate or cancel it.
  • If a limit order remains unfilled beyond its expiry, cancel it and do not convert it to market execution automatically.
  • If recent rejection rate exceeds the execution-health threshold, block new orders.
  • If broker conditions do not support the required stop or order type, cancel the intent.

The policies should be based on historical and forward testing. Do not add a rule merely because one trade had a poor fill.

Execution Policy Pseudocode

function SelectExecutionTactic(intent, execution_snapshot, risk_state, config): if !IntentIsFresh(intent, execution_snapshot.time, config): return Cancel("INTENT_EXPIRED") if !PriceWithinAuthorizedZone(intent, execution_snapshot, config): return Cancel("PRICE_DRIFT_EXCEEDED") if risk_state == ENTRIES_BLOCKED || risk_state == EMERGENCY_FLATTEN: return Cancel("RISK_STATE_BLOCK") if !MarketIsTradable(execution_snapshot): return Cancel("MARKET_NOT_TRADABLE") if SpreadExceedsPolicy(execution_snapshot, config): if intent.AllowsBriefWait() && TimeRemaining(intent) > config.min_wait_time: return Wait("SPREAD_TOO_WIDE") return Cancel("SPREAD_TOO_WIDE") if RecentExecutionHealthDegraded(execution_snapshot, config): return Cancel("EXECUTION_HEALTH_BLOCK") if intent.PermitsLimit() && LimitTacticPreferred(intent, execution_snapshot, config): return UseLimit(intent.limit_price, intent.limit_expiry) if intent.PermitsMarket() && ExpectedShortfallWithinLimit(intent, execution_snapshot, config): return ExecuteMarket(AuthorizedVolumeForState(intent, risk_state)) return Cancel("NO_APPROVED_EXECUTION_TACTIC")

The output should be a bounded tactic plus a reason code. It should not be a general instruction such as “try to get a better fill.”

Fallback When the Execution Model Is Unavailable

If an execution model or adaptive execution component is unavailable, do not silently revert to market execution. The fallback must be deterministic and conservative.

For example:

  • If the execution service is unavailable, cancel new order intents.
  • If live spread data is unavailable, block new entries.
  • If the broker connection is uncertain, block new entries and reconcile existing exposure.
  • If the order-policy configuration is missing or incompatible, disable new entries.
  • If a limit-order policy cannot validate expiration or price, cancel rather than convert to market.

Log the reason for every canceled or modified intent. This turns execution from an invisible source of variance into a measurable component of the system.

Order Rejections Are Data

Order rejections should not be treated as random annoyances. They can reveal a mismatch between strategy assumptions, request construction, broker constraints, and market conditions.

Common categories to record include:

  • Invalid price.
  • Invalid stop-loss or take-profit distance.
  • Invalid volume or volume step.
  • Unsupported filling mode.
  • Market closed or symbol trading disabled.
  • Insufficient margin.
  • Requote, off quote, or price change.
  • Trade context busy or terminal connection issue.
  • Duplicate intent or duplicate request.
  • Policy cancellation before transmission.

Group rejections by symbol, session, order type, EA build, and policy version. A rising rejection rate may be a risk event that should move the system to reduced or blocked state.

Partial Fills and Reconciliation

Some instruments, brokers, or order types can result in partial fills. A partial fill changes actual risk, margin, and exposure. Do not assume the requested volume equals the filled volume.

After every request, reconcile:

  • Whether an order was accepted, rejected, or remains pending.
  • Actual filled volume.
  • Actual fill price or average fill price.
  • Remaining unfilled volume, if any.
  • Resulting position volume and direction.
  • Actual stop-loss and take-profit attached to the position.
  • Incremental portfolio risk after the fill.
  • Whether a follow-up action is required by deterministic policy.

If execution state is uncertain after a timeout or connection interruption, do not resend blindly. Query the platform, orders, deals, and positions first. Blind retries can create duplicate exposure.

Limit-Order Lifecycle

A limit order needs its own lifecycle management. It should not remain active indefinitely after the market context changes.

Define:

  • Creation time and expiration time.
  • Maximum validity based on strategy horizon.
  • Conditions that require cancellation before expiry.
  • Whether the order is canceled before scheduled high-impact news.
  • Whether a regime change invalidates the pending entry.
  • Whether a related position or correlated exposure makes the order invalid.
  • How unfilled, partially filled, and canceled orders are logged.

A pending order is potential exposure. The risk system and execution agent must include it in total-risk calculations and emergency controls.

Slippage at Stop-Losses

Stop-losses are essential risk controls, but they do not guarantee exact exit price during fast, gapping, or illiquid conditions. Stop orders can fill at a worse price than the intended stop level when available prices move through that level quickly.

Execution analysis should record stop-loss behavior separately from normal market-entry behavior. Track:

  • Planned stop price.
  • Trigger time.
  • Actual exit price.
  • Adverse or favorable stop slippage.
  • Spread and volatility at trigger.
  • News, session, and liquidity context.
  • Result in planned R versus realized R.

If stop-loss slippage is consistently large during certain conditions, adjust the strategy’s event policy, spread policy, risk buffer, or trading schedule based on evidence. Do not simply remove stops.

Arrival Benchmark for Exits

Execution quality matters at exit as well as entry. For a planned exit, use the price available when the decision to close was made as the arrival benchmark. For an emergency or stop-driven exit, record the triggering condition and the first available executable price context where possible.

Different exit types should be analyzed separately:

  • Take-profit exit.
  • Stop-loss exit.
  • Time-based exit.
  • Manual or policy-driven exit.
  • Emergency flatten exit.
  • Partial exit.

A system that enters well but exits poorly can still have weak net performance.

Session and Liquidity Effects

Execution conditions vary across the trading day. Liquidity, spread, quote frequency, and volatility can differ significantly between sessions, rollovers, market open, market close, holidays, and major scheduled releases.

Before automating additional symbols, make sure the strategy’s market-schedule and liquidity assumptions are understood. The guide to the best times to trade forex introduces session effects that remain relevant even in advanced execution systems.

Your execution journal should make it possible to compare fill quality by session. A strategy that appears strong in aggregate may be weak during one low-liquidity period because costs consume its expected edge.

Execution Health State

Execution conditions can be treated as a component of the independent risk system. A compact execution-health state may be:

Execution Health State Typical Conditions Action
HEALTHY Normal spread, valid quotes, acceptable latency, low rejection rate, and current tradeability. Allow approved tactics.
DEGRADED Spread elevated, fill quality worsening, or temporary latency increase without hard failure. Use reduced tactics only if policy allows; otherwise cancel new intents.
BLOCKED Missing quotes, major spread anomaly, invalid broker state, repeated rejections, or stale execution data. Cancel new intents and notify the risk layer.
UNCERTAIN Unknown order state, disconnection, incomplete reconciliation, or time-sync failure. Block new entries; reconcile before further action.

Do not allow a strategy to bypass a blocked or uncertain execution state because its signal is strong.

Audit Log for Execution Quality

Execution should be fully auditable. Each intent needs a correlation ID that links strategy decision, arrival benchmark, tactic, broker request, result, and final position state.

Log:

  • Intent ID, signal ID, strategy version, and execution-policy version.
  • Intent creation time, expiry time, and arrival bid/ask benchmark.
  • Execution snapshot, including spread, tick activity, session, and market tradeability.
  • Selected tactic and reason code.
  • Any wait, modification, reduction, cancellation, or limit-order expiration.
  • Final MT5 request fields.
  • Broker response, retcode, order ticket, deal ticket, position ticket, and actual fill.
  • Requested versus filled volume and price.
  • Latency measurements for every decision stage.
  • Implementation shortfall, commission, swap, and other direct costs.
  • Subsequent stop or exit slippage and realized R.

Log canceled intents as carefully as filled intents. A cancellation may be correct risk management or evidence that the strategy’s assumed execution conditions are rarely available.

MQL5 Component Layout

Keep execution logic modular and separate from signal generation and portfolio risk. This makes fill-quality testing and policy changes easier to control.

/ExecutionAgentMT5
  /Core
    TradeIntent.mqh
    ExecutionSnapshot.mqh
    ExecutionConditions.mqh
    ExecutionPolicy.mqh
    ArrivalBenchmark.mqh
    ImplementationShortfall.mqh
    OrderPolicy.mqh
    ExecutionAdapter.mqh
    TradeReconciliation.mqh
    ExecutionHealthState.mqh
    AuditLogger.mqh
  /Infrastructure
    TimeUtils.mqh
    SymbolUtils.mqh
    LatencyMetrics.mqh
    BrokerRetcodes.mqh
  /Config
    ExecutionPolicyConfig.mqh
  ExecutionAgentEA.mq5 

The order adapter should be the only component that communicates with  OrderSend()  or a trading wrapper. It should receive only an approved bounded request.

Conceptual MQL5 Execution Loop

OnTimer(): intent = IntentQueue.GetNextValidatedIntent() if intent == NONE: return if IntentLedger.AlreadyProcessed(intent.id): Audit.LogCancel(intent, "DUPLICATE_INTENT") return snapshot = ExecutionSnapshotBuilder.Create(intent.symbol) if !snapshot.IsReliable(): Audit.LogCancel(intent, "UNRELIABLE_EXECUTION_STATE") return tactic = ExecutionPolicy.Select(intent, snapshot, CurrentRiskState()) Audit.LogTactic(intent, snapshot, tactic) if tactic.type == CANCEL: IntentLedger.MarkCanceled(intent.id, tactic.reason) return if tactic.type == WAIT: IntentQueue.Reschedule(intent, tactic.next_check_time) return request = OrderPolicy.BuildRequest(intent, tactic, snapshot) result = ExecutionAdapter.SendAndReconcile(request) Audit.LogExecution(intent, snapshot, tactic, request, result) IntentLedger.MarkFinal(intent.id, result.final_state)

Every branch must be idempotent. A timer retry, terminal restart, or network interruption must not turn one intent into several orders.

Test Execution Under Stress

Execution policies should be tested under conditions that expose real failure modes, not only during calm market hours.

Test:

  • Spread expansion before and after scheduled high-impact events.
  • Fast price movement and price drift beyond entry zones.
  • Limit orders that fill, do not fill, or partially fill.
  • Market-order slippage at different sessions and volumes.
  • Invalid stops, invalid volumes, and unsupported filling modes.
  • Broker rejections, requotes, off quotes, and connection interruptions.
  • Unknown execution state after a timeout.
  • EA restart during an active limit-order or reconciliation lifecycle.
  • Risk-state transition while an intent is waiting.
  • Cancel and flatten behavior when pending orders and open positions coexist.

Forward demo testing is especially important because historical tests may not reproduce broker-specific spread, rejection, slippage, and fill behavior.

Common Execution Mistakes

Measuring Only the Next Bar Close

The next close reflects later market movement, not the cost of execution. Use the arrival benchmark at validated intent creation and actual fill data.

Ignoring Canceled and Rejected Intents

A canceled or rejected order is part of real system performance. Track it by reason code and context.

Silently Falling Back to Market Orders

If a limit tactic or execution model fails, cancel the intent unless a separate deterministic fallback explicitly allows another action. Do not default to an uncontrolled market order.

Using Stale Signals

A valid signal can become invalid after price, spread, or volatility changes. Use intent expiry and price-drift limits.

Letting Execution Increase Risk

The execution layer may reduce or cancel within policy, but it should never increase volume, widen stops, or ignore account restrictions to obtain a fill.

Not Reconciling Partial Fills

Actual volume can differ from requested volume. Recalculate exposure and risk from broker-reported state after every result.

Assuming a Stop Guarantees Exact Exit

Stop-losses can experience slippage in fast markets. Track planned versus actual stop exits and incorporate realistic risk buffers.

Ignoring Session Effects

Execution quality can vary by session, rollover, holiday, and event condition. Group results by context rather than relying on one average cost.

Implementation Checklist

Use this checklist when building an MT5 execution agent:

  • Receive only validated, bounded trade intents from strategy and risk layers.
  • Record the arrival bid or ask when the intent is created as the execution benchmark.
  • Collect a fresh execution snapshot with spread, tick activity, session, broker rules, and signal expiry.
  • Use only predefined tactics: execute, limit, reduce, wait, or cancel.
  • Do not allow execution logic to change direction, exceed risk authorization, widen stops, or chase expired signals.
  • Measure implementation shortfall, fill rate, partial fills, rejection rate, slippage, and decision-to-fill latency.
  • Track execution quality by symbol, session, order type, volatility, spread percentile, and policy version.
  • Include spread, commission, slippage, rejected orders, and latency in strategy-performance evaluation.
  • Use deterministic, conservative fallback when execution data or the execution model is unavailable.
  • Cancel rather than silently reverting to unapproved market execution.
  • Reconcile every MT5 request against actual orders, deals, positions, volume, and fill price.
  • Include pending orders in risk, expiry, cancellation, and emergency-control processes.
  • Persist intent state and processed IDs so restarts cannot duplicate orders.
  • Log every tactic, modification, cancellation, rejection, fill, and final outcome with reason codes.
  • Test under spread expansion, rapid movement, partial fills, disconnections, rejections, and restarts before live deployment.

Final Thoughts

Execution is not a minor technical detail after a signal is generated. It is part of the strategy’s real performance. A correct market view can still lose money when the system pays too much to enter, fills too late, misses a valid limit, or continues trading while broker conditions are degraded.

Use arrival benchmarks, implementation shortfall, fill-rate analysis, and complete order reconciliation to make fill quality visible. Keep execution tactics bounded, treat canceled intents as data, and default to cancellation when execution state is uncertain. A model edge is only meaningful after the cost of turning a decision into a real fill is measured.

Risk disclaimer: Automated trading, execution agents, Expert Advisors, foreign exchange, CFDs, commodities, indices, stocks, cryptocurrencies, and other leveraged products involve substantial risk and may not be suitable for all investors. This article is for educational and software-architecture purposes only and does not constitute financial, investment, legal, tax, cybersecurity, or regulatory advice. Spread, commission, slippage, liquidity, margin requirements, order handling, and execution quality vary by broker, account type, instrument, session, and market conditions. Stop-loss orders do not guarantee exact execution price in fast or gapping markets. Past performance, backtests, forward tests, and demo results do not guarantee future results. Test all systems carefully and use robust independent risk controls before considering live deployment.