Direct answer: what a worked example means
A worked example of an MT5 Expert Advisor is a transparent, step-by-step scenario showing how the advisor’s rules would be processed by the MetaTrader 5 environment. “Worked” means you can follow the logic from inputs (like parameters and risk settings) to outputs (like order requests and state changes), using stated assumptions instead of real-time market data.
Because real markets, execution, and costs vary, a worked example is not a promise of results. It is a verification exercise: it helps you explain how the EA computes decisions and how trades could be affected by fills and transaction costs.
Mechanism or definition: what an MT5 Expert Advisor does
An Expert Advisor (EA) in MT5 is an automated program that reacts to market events and then submits trading requests according to its programmed rules. In a conceptual workflow, an EA typically:
- Reads configuration parameters (strategy inputs).
- Evaluates conditions using available data (for example, recent prices or indicator calculations).
- Decides whether to place a new order, modify an order, close a position, or do nothing.
- Tracks positions and orders to avoid duplicate actions and to apply management rules.
A worked example must separate two things:
- Stable mechanics: the EA’s control flow (if conditions are met, submit an order; if a time stop is reached, close; if a position exists, manage it).
- Variable conditions: the market prices, execution timing, spread, slippage, and any broker or platform settings that affect fills.
Evidence or example: a transparent numerical scenario (with assumptions)
Below is one simplified worked scenario. It is intentionally not a recommendation of any trade, pair, or strategy—only a demonstration of calculation and decision processing.
Assumptions (state everything)
- Account currency and quote/base currency details are ignored for simplicity; assume the position size is already translated into a “trade value” that produces a proportional profit/loss.
- The EA is configured to use:
- Entry rule: when a “signal” flag is true at evaluation time, open a position.
- Stop distance: fixed distance of 20 price units from entry.
- Take-profit distance: fixed distance of 40 price units from entry.
- One position at a time: if a position is open, do not open another.
- Costs: assume a total round-trip cost of 2 price units equivalent (spread + commission) for the closed trade.
- No slippage: assume fills occur exactly at the assumed entry and exit prices (this is a simplification; limitations below explain why this often fails in practice).
- Price path for this scenario is hypothetical and fully specified:
- Evaluation time: entry condition is true.
- Entry fill price: 100.
- Price then moves: reaches 120 before reaching 140.
- The EA’s take-profit and stop levels are defined as:
- Stop = 100 - 20 = 80
- Take-profit = 100 + 40 = 140
Step-by-step processing
- EA evaluation at time of decision: the signal flag is true and there is no open position.
- EA computes order levels from entry price 100:
- Stop at 80
- Take-profit at 140
- EA submits an order to open at 100 (assumed fill at exactly 100).
- EA monitors the position. In this scenario, price reaches 120. Because 120 is not the take-profit level (140) and not the stop level (80), the position remains open.
- Assumed outcome for demonstration: suppose later the price reverses and hits the stop level at 80 before any take-profit at 140.
- Profit/loss computation (simplified):
- Gross move = Stop - Entry = 80 - 100 = -20 price units.
- Net after costs = -20 - 2 = -22 price units equivalent.
What this example teaches
- The EA’s numeric outcomes come from: (a) rule logic (open only when signal true; manage one position), (b) parameter math (stop/take distances), and (c) the assumed price path and execution assumptions.
- If you change any assumption—like slippage, spread widening, or the order of price touching levels—the result can change even when the EA logic is unchanged.
Limitations and risks: where a worked example can fail
A worked example is only as trustworthy as its assumptions. Common failure modes include:
- Execution mismatch: real fills can differ from assumed prices due to slippage, partial fills, and spread changes. 2.