Direct answer: what “calculated” means for an MT5 Expert Advisor
An MT5 Expert Advisor (EA) is not calculated by one fixed, platform-wide math formula. Instead, the EA’s behavior is produced by running the EA’s program (your strategy logic) step by step. Each step computes new decisions (for example, when to place orders) from:
- Market data available to the EA at that moment (historical bars and/or incoming ticks)
- The EA’s input parameters (numbers you configure)
- The EA’s internal state (variables it remembers between runs)
- The rules you coded for indicators, risk logic, and order handling
So “How is MT5 Expert Advisors calculated?” is best answered as: the EA is calculated by executing its code on received data, using its parameters and state to generate signals and order requests.
Mechanics: the calculation pipeline inside an EA
Think of an EA as a repeated loop. The exact loop depends on how it is programmed, but a typical educational model looks like this:
- Data acquisition
- Historical bars: OHLCV-style data used to compute values over time.
- Ticks: streaming price updates used for event-driven logic.
- The EA may process one or both, depending on whether it’s written to react to new ticks, new bars, or both.
- Indicator-style computations (if used) If the EA uses indicators, it is computing functions such as moving averages, RSI-like oscillators, or custom transforms. These are mathematical operations over the input series (for example, closing prices over the last N bars).
A general form is:
- Let the EA create a time series x(t) from market data (for example, x(t)=close price at bar time t).
- It then computes an indicator value I(t) using some rule (for example, a windowed average, or a recurrence).
- Decision logic The EA combines its computed values and parameters into conditions. A generic example pattern is:
- If condition C(parameters, I(t), EA_state) is true → prepare an action.
- Otherwise → do nothing or update state.
Here, EA_state means values the EA stored earlier (for example, whether it already has an open position, or a counter tracking consecutive events).
- Order sizing and request construction If the EA sends orders, it “calculates” what to request using trade-related inputs and constraints. This commonly includes:
- Order side (buy/sell)
- Volume (lot size), often derived from parameters and/or a risk sizing rule
- Stop-loss / take-profit levels (if your code sets them)
- Allowed slippage or price references (how you map “desired price” to actual execution)
It’s important to separate:
- The EA’s internal calculations (pure math based on parameters and data)
- The broker/execution outcome (how orders fill in real market conditions)
- State update after execution After an order is accepted or filled (or rejected/partially filled), the EA updates internal variables. That state then affects later calculations.
A simple universal “formula” (conceptual, not product-specific)
Because EAs differ, there is no single numeric equation that always applies. But you can use a conceptual formula that fits any EA design:
EA_output(t) = Logic(parameters, Market_data(t), EA_state(t))
Where:
- EA_output(t) represents decisions and requests the EA produces at time t.
- Market_data(t) is whatever price series the EA reads at t.
- EA_state(t) is the current memory of the EA.
If you want to “verify” how it’s calculated, you check the EA code and map each variable to one of these inputs.
Evidence or example: tracing a real calculation path (assumptions stated)
Below is an educational example that shows how an EA’s calculation can be traced. This is not a specific EA; it’s a template.
Assume:
- The EA runs on every new bar.
- It computes a windowed average of the last N closes.
- It uses a threshold K and stores whether it currently has an open position.
Example conceptual steps at bar time t:
- Build x(t) = close price at each of the last N bars.
- Compute I(t) = average(x(t−N+1) … x(t)).
- Use parameters (N, K) and state (hasPosition) to compute a condition:
- C = (I(t) > K) AND (hasPosition == false)
- If C is true:
- Request a buy order with volume V derived from parameters.
- Optionally compute stop-loss/take-profit levels from other parameter distances.
- After the order is filled, set hasPosition = true.
The key verification idea: you can reproduce the same intermediate numbers (like the average I(t)) from the same bar history, then check whether your code’s conditions would evaluate to the same actions.
Limitations and risks: why results differ from expectations
Even with careful calculations, outcomes can diverge because market and execution conditions affect what ultimately happens.
Material limitation 1: “calculation” vs execution
The EA may calculate an intended action, but the broker/execution layer determines the actual fill. That introduces uncertainty such as:
- Spread differences between when the EA computes and when it submits
- Slippage (difference between requested and filled price)
- Order-filling behavior (full vs partial fills)
Therefore, “what the EA calculated” is not always “what you got.”
Material limitation 2: missing or delayed data events
If the EA expects tick-driven updates but tick flow is interrupted, it may:
- Skip evaluations
- Use stale prices
- Trigger delayed logic
This is a failure mode created by the mismatch between your code’s assumptions and the environment’s event timing.
Material limitation 3: parameterization and data window issues
Wrong or inconsistent settings can break the calculation chain. Examples include:
- Using a larger N than the available historical bars (indicator values may be undefined or unstable early on)
- Timeframe mismatches (EA expects one bar series but reads another)
- Overly strict conditions that rarely become true, making the EA appear “inactive”
Material limitation 4: internal logic and state bugs
Because EAs rely on internal state, coding errors can cause incorrect decisions, such as:
- State not resetting on position close
- Double-order submission due to missing guards
- Handling of partial fills not reflected in state updates
These are calculation-level issues, not market-level ones.
How to independently verify the calculation
To verify how an MT5 EA is “calculated,” you can use a repeatable method:
-
Identify the input data sources Check whether the EA uses ticks, new bars, or both, and which symbols/timeframes it reads.
-
List the parameters Write down each input parameter and where it influences calculations (indicator windows, thresholds, sizing, stop distances).