How a backtest runs: tick mode, bar mode, and when your rules are evaluated
Tick mode and bar mode, when each event fires, the order of work inside one step, what a rule can see, warm-up, and how a run starts and ends.
This page gives the exact rules the backtest engine follows over time: which prices each mode uses, when each kind of rule runs, the order of events inside one step, what a rule can and cannot see, how a run starts and ends, and what can stop it. Fill rules are on Orders and fills, costs and the account on Costs and the account, live behaviour on Live execution and MetaTrader 5 on the MT5 comparison; this page covers them only where timing matters.
The two modes at a glance
| Tick by tick | Bar by bar (M1) | |
|---|---|---|
| What one step is | one recorded Dukascopy quote, for every symbol the run loads, all symbols merged in time order | one 1-minute bar of the strategy's primary symbol; a minute where only another traded symbol has a bar is a step too, with no decision |
| Market order fills at | the ask (buy) or bid (sell) held for that symbol at the moment the rule fires | the open of its symbol's next 1-minute bar (a buy adds that bar's spread) |
| Stop loss / take profit tested | on every tick of the position's symbol; fills at that tick's price | once per bar of the position's symbol, against its high and low; fills at the level |
| Gap through a stop | you pay the gap | you pay the gap: a stop the bar opens beyond fills at the bar's open |
| Stop and target inside one step | stop tested first | stop wins |
| Pending order fills at | the crossing tick's price | the order price; a stop order the bar opens beyond fills at the bar's open |
| Spread | each tick's own | the minute's average |
| A candle close above M1 acts | on the first tick of the new period | at the close of the candle's last 1-minute bar, filled at the next bar's open: the same instant |
| On Tick rules run | on every tick of the action's symbol | once per minute, at the bar's close |
| "Current price" a rule reads | the latest tick | the bar's close |
| Strategies trading more than one symbol | supported | supported: each symbol on its own 1-minute bars (see Bar mode with more than one traded symbol) |
| Product status | the fidelity reference | a structural approximation, for fast exploration |
| Availability | every plan (plans) | every plan; the default in the start dialog |
Which mode to use. Use tick mode for any result you will act on: stops, targets or pending orders that can trigger inside a minute, On Tick rules and Market Price reads. Bar mode is for quick exploration and wide parameter sweeps. A bar-mode result says nothing reliable about how a price-sensitive strategy will behave live.
1. The data each mode runs on
The data. Both modes run on the same stored Dukascopy history: a tick holds a bid, an ask and a time to the millisecond, and bars are built from the bid (market data).
Tick mode processes every stored tick of every loaded symbol whose timestamp falls between the run's start and end, both included. The ticks of all symbols are merged into one time order. Ticks of different symbols with the same timestamp are taken in a fixed order, so a run is repeatable.
Bars. A 1-minute bar holds the bids of one UTC minute, with the minute's average spread; a minute with no tick has no bar, and bar mode simply steps over it. Higher timeframes are built from the 1-minute bars on your strategy's clock. How bars are built, and where a day or a week starts: market data → bars and your strategy's clock.
Which symbols a run loads. A run loads every symbol your rules trade or read. When a traded symbol's quote currency differs from the account currency, it also loads the symbol needed for the conversion; an example is EURUSD for a USD-quoted index on an EUR account. Tick mode processes the ticks of every loaded symbol, conversion symbols included.
Report counters. "Ticks" and "Bars" on the report count what the run stepped through (report figures).
2. Prices and fills
Tick mode
What tick mode replays, and what it assumes:
- Every recorded tick of every symbol the run loads is a step, all symbols merged in time order (§1).
- A market order fills at the quote of the moment its rule fires, in the same step: no order latency is simulated. An order on a symbol that is paused at that moment waits for that symbol's next tick (paused symbols).
- Stops, targets and pending orders are checked on every tick of their own symbol and fill at the price of the tick that reaches them, so a gap is paid. A pending order placed on a tick can fill at the earliest on the next tick of its symbol.
- The spread is each tick's own recorded bid and ask, unless a virtual symbol replaces it (spread).
The exact fill rules (which side, which comparison, slippage, margin at a pending fill) are on Orders and fills.
Bar mode
What bar mode assumes inside a minute:
- No price path inside a bar. Bar mode takes one step per 1-minute bar of the primary symbol and treats the bar as a range: it knows the open, high, low and close, but not the order in which they happened. Every traded symbol is priced on its own 1-minute bars (§7).
- Decisions at the close, fills at the next open. A bar decides at its close, the instant tick mode decides on the tick that closes the candle. What it decides executes at the next bar's open, the first instant after it: market orders, position modifications, and placing, cancelling or modifying a pending order (bid = that open, ask = that open plus the bar's spread). Their stop, target, volume and trailing values are read at that moment, from the data the decision read: a candle-close order never reads the bar it fills into. This is the guard against trading at a price the decision already saw.
- Levels against the bar's range. Stops, targets and pending orders are tested once per bar of their own symbol against the bar's high and low (the ask side as the bid extremes plus the spread), and fill at their level. A gap is paid: a stop loss or a stop order that the bar opens beyond fills at the bar's open. A take profit or a limit order keeps its level. When a stop and a target both lie inside one bar, the stop wins.
- The bar's spread is the average spread of the minute's ticks.
The exact rules are on Orders and fills, and the inside-a-minute consequences for live trading under §11.
Slippage (both modes)
Slippage moves every simulated fill against you by a fixed number of points; the rule is on Orders and fills → slippage.
The current price your rules read
The Market Price value is the quote a market order would fill at: the latest tick in tick mode (inside a candle-close evaluation, the tick that fired it) and the processed bar's close in bar mode, with ask = close + spread. Every candle value and every indicator is computed on bid prices. A bar-mode run therefore reads different Market Price numbers than a tick-mode run or a live deployment, while tick mode and live agree (Market Price). A symbol you read only through Market Price, without trading it, has its 1-minute prices loaded in both modes and is subscribed live, as a traded symbol is.
3. When rules run
The events
Each action, status holder and record set runs on an execution event: its own if one is set, otherwise the strategy's default. The available events are:
- On Tick;
- On Candle Close, for each of the 21 timeframes: M1, M2, M3, M4, M5, M6, M10, M12, M15, M20, M30, H1, H2, H3, H4, H6, H8, H12, D1, W1, and MN1;
- On Timer, kept by strategies that already use it; new strategies cannot pick it (On Timer).
Candle closes, tick mode
On Candle Close · X fires once per X bar of the primary symbol, on the first tick at or after the start of the next X bar.
- That evaluation reads the bar that just closed as shift 0.
- A market order fills at that moment's quote.
- No earlier tick in the bar fires it.
- When a data gap spans several bars, it fires once, not once per missed bar.
- The very first tick of a run never fires a candle close.
Runs that load several symbols. This covers a second traded symbol, a symbol read only by conditions, and a currency-conversion symbol. The close is detected on the first tick of any loaded symbol at or after the boundary, as long as the primary has data in the new bar. The decision then uses the primary's latest quote, which can still be from before the boundary. A live deployment detects the close on the primary's own first tick of the new bar instead, so the two can differ by a fraction of a second of price.
Candle closes, bar mode
Bar mode decides at the close of each 1-minute bar of the primary symbol. On Candle Close · X runs on the 1-minute bar whose close falls on the X grid of the strategy's clock, that is the last minute of the X candle:
- M5: the bar closing at a minute divisible by 5;
- H1: the bar closing at minute 0 (the 10:59 bar closes the 10:00–11:00 candle);
- H4: the bar closing at minute 0 of an hour divisible by 4;
- D1: the bar closing at 00:00;
- W1: the bar closing at Monday 00:00;
- MN1: the bar closing at the 1st, 00:00.
For M1, every bar fires. For any X above M1, the rule fires on the candle's last minute and its market fill lands at the next bar's open, the same instant as tick mode.
The clock reads the decision instant. While the bar decides, your strategy's clock reads its close: an H1 close decided on the 10:59 bar reads 11:00, so a rule on the hour, the minute, a session or the time since the last trade agrees with tick mode.
The data is the closed candle. The decision reads every higher-timeframe candle closed by that instant: an H1 rule decided on the 10:59 bar reads the 10:00–11:00 bar at shift 0, and its market order fills at 11:00, the next bar's open. A candle whose period has ended is closed even when its series has no later bar yet.
A candle that ends inside a data gap. When the primary symbol's last bar before a gap stops short of the boundary (a quiet minute, a market that opens a few minutes after the boundary, a daily break), the close is decided at the open of the first bar after the gap, the instant tick mode decides it on the first tick there. It reads the market as of the last bar before the gap and fills at that open. However many boundaries the gap spans, the rule runs once.
Several timeframes closing at once
When one step closes several timeframes (11:00 closes M1, M5, M15, M30 and H1), they all fire in that step. Each action runs once, in the order the same-evaluation rules give, and each reads its own just-closed bar. Status holders and record sets update before any action runs.
On Tick
Tick mode, actions. An action runs on every tick of the symbol named in its trade levels. An action without trade levels, such as a close or delete that names no symbol, runs on every tick of every loaded symbol.
Tick mode, status holders and record sets. On Tick status holders and record sets update on every tick of every loaded symbol, currency-conversion symbols included.
Tick mode, order within the tick. On Tick actions run after that tick's candle-close actions and after its stop and target check.
Bar mode. On Tick runs once per 1-minute bar, at its close.
On Timer
The interval. The timer is fixed at 1 minute and cannot be configured.
Not offered for new strategies. The event pickers no longer list On Timer until its interval can be set. A strategy that already uses it keeps it, and it runs as described here.
Tick mode.
- Due instants are the clock's whole minutes: the first whole minute after the run starts, then every minute.
- The timer fires on the first tick of any loaded symbol at or after a due instant, at most once per tick.
- Each fire moves the next due instant to the first whole minute after that tick.
- After a gap in the data the timer fires once, on the first tick after the gap, and then resumes on the whole minutes. It does not replay the minutes it missed.
Bar mode. The timer fires on every bar.
Live. The same one-minute timer runs on the whole minutes from the deployment's start, and after a pause in ticks it fires once and resumes, as in tick mode.
Status holders and record sets on On Timer follow the same timer.
The primary symbol of a multi-symbol strategy
Which symbol is primary. When a strategy's actions trade more than one symbol, the primary is its first traded symbol: the symbol of the first action, in the order the Actions list shows them, that names one. Symbols read only by conditions, and currency-conversion symbols, never qualify. To make another symbol primary, move an action trading it to the top of the list. A strategy trading one symbol is not affected.
What it changes. The primary decides which symbol's candles fire On Candle Close rules and, in bar mode, which symbol's 1-minute bars drive the decisions.
Only the primary fires candle closes. A second traded symbol's own bar closes never fire On Candle Close rules, not even rules that trade that symbol. Those rules run when the primary closes its bar, and they fill on the other symbol at its latest price in tick mode, or at the open of its next 1-minute bar in bar mode.
No primary data, no close. If the primary has no data in a period, no candle close fires for that period.
Live uses the same rule.
Status holders, record sets and crossovers
- Status holders and record sets whose event fires update once per step, before any action is evaluated: after that step's pending-order fills in tick mode, and after the stop and target check in bar mode, so actions read this step's state. The order in which they update, and what one reads of another, is on Strategy semantics → status holders.
- Crossovers compare an action's values with its own previous evaluation, so their memory advances only when that action is evaluated: on every tick of its symbol for an On Tick action in tick mode, and once per bar in bar mode. The full rule: Strategy semantics → crossovers.
4. The order of operations inside one step
One tick (tick mode)
- The clock moves to the tick's time. The tick's quote, with any spread override applied, becomes the symbol's current price, and the developing bars are extended with its bid. Market orders waiting for this symbol's quote (paused symbols) fill now, in the order they were sent, after swap (step 2) and before its pending orders (step 5).
- Swap: the first tick at or after the rollover minute of a new day applies that day's rollover. Balance-mode swap is debited here.
- Bar boundaries are detected, and higher-timeframe bars that just closed become readable.
- If a timeframed drawdown limit is pausing trading, only status holders and record sets update, and steps 5 to 9 do not run.
- Pending orders of this tick's symbol are processed: expiries first, then fills.
- Status holders and record sets update.
- If a boundary was crossed, the candle-close actions run under the same-evaluation rules: their closes, deletes and modifies first, then their opens.
- Stop loss and take profit are checked for this tick's symbol. Then the trailing-stop and break-even ratchet runs; a stop it moves can trigger only on a later tick.
- On Tick and On Timer actions run, under the same rules.
- Equity and used margin are recomputed at every symbol's latest price, a stop-out is applied if equity is below 0, and the drawdown statistics are updated.
- Drawdown limits are checked. An Overall or Static overall breach ends the run. A timeframed breach cancels every pending order, closes every position and pauses trading until its window ends.
- Trade caps are enforced.
One 1-minute bar (bar mode)
The clock is the bar's open while the bar's fills and checks run, and its close while decisions are taken.
- Other symbols' series are moved to their last closed minute; each traded symbol's price is its own 1-minute bar at this minute (or its last bar's close when it has none).
- Swap rollover is applied.
- A candle close owed across a data gap before this bar is decided now, at this bar's open (candle closes, bar mode).
- What was decided on the previous bar (or just above) executes at this bar's open, in the order the same-evaluation rules gave it: closes, deletes and modifies, then opens and pending placements. An order on another symbol waits for that symbol's next bar, and so does the close of a position on a symbol with no bar at this minute. The orders already waiting for a symbol's bar fill first.
- Higher-timeframe bars that closed by this bar's close become readable.
- Pending orders either expire or fill, each on its own symbol's bar: at their price, or at the bar's open for a stop order the bar opens beyond.
- Stop loss and take profit are checked on each symbol's bar range, stop first. Then the trailing and break-even ratchet moves stops using the bar's favourable extreme; a stop it moves beyond the bar's close was crossed inside the bar, so the position closes there at the stop's level. Any other moved stop takes effect from the next bar.
- The clock moves to the bar's close, and the developing higher-timeframe bars take in this bar. Status holders and record sets update.
- Unless a timeframed drawdown limit is pausing trading, every action whose event fires on this bar is evaluated under the same-evaluation rules, and everything it decides is queued for the next bar's open.
- Equity is computed at the bar's close, and a stop-out is applied if equity is below 0. The drawdown calculation also values each open position at its worst price inside the bar: a long at the low, a short at the high plus spread.
- Drawdown limits are checked, as in tick mode.
- Trade caps are enforced.
A minute where a traded second symbol has a bar and the primary has none runs steps 2, 4, 6, 7 and 10 to 12 for that symbol, with no decision.
What this order means for your strategy
Stops and targets relative to your rules.
- In tick mode, the check sits between the candle-close rules and the On Tick rules. A position opened by a candle-close rule is checked on the same tick, so a stop that tick already breaches closes it at once. A position opened by an On Tick rule is first checked on the symbol's next tick.
- In bar mode, the check comes before the rules. A position filled at this bar's open and a pending order filled during this bar are both exposed to this bar's range. A close decided on this bar executes at the next bar's open, before that bar's check.
Several actions in the same evaluation follow the same-evaluation rules below, in tick mode, bar mode and live alike.
Stops already on the wrong side. A market order whose stop or target is already on the wrong side of the price it would close at is refused, as a broker refuses it; so are a pending order on the wrong side of the market, a pending order whose stop or target is on the wrong side of its own price, and a modification that would put a level on the wrong side (wrong-side stops).
Modifications. In tick mode they apply at once. In bar mode a position modification and an order modification both wait for the next bar's open with the market orders (changing open positions).
Several actions in one evaluation
An evaluation is everything a strategy does on one price update: one tick in tick mode and live, one bar close in bar mode. Within one evaluation the candle-close actions run first, then the On Tick and On Timer actions. Inside each group:
- Manage first. Every close, partial close, delete and modify whose conditions are met is decided on the state as it was when the group started, so actions that share a condition act together. Then they are applied: the closes, then the deletes, then the modifies, each kind in the order the Actions list shows them. A close naming "trade N" picks the Nth position as the group started, so two such closes decided together never renumber each other.
- Then open. Market opens and pending placements are decided one at a time, in the Actions list's order. Each one sees what step 1 did and what the opens above it did — including orders still in flight live and orders waiting for the next bar's open in bar mode, which count as positions (or resting orders) from the moment they are sent.
- Nothing an evaluation sends is closed, cancelled or changed by that same evaluation. This matters on a candle-boundary tick, where an On Tick close runs after a candle-close open: the close passes over the new position, and the next evaluation can close it.
A pending order the tick fills is filled before the rules run, as at a broker: it is an existing position, and any rule may act on it.
What this means in practice:
| Strategy | Result |
|---|---|
| Each hour, close the open trade and open a new one (whichever is listed first) | The old trade closes and the new one opens, every hour |
| Open buy / open sell gated on "no positions", closed on the opposite signal | Reverses on the signal, whatever the listing |
| A close of the buys and a close of the sells sharing one condition | Both sides close |
| Two opens gated on "no positions", both true | One opens |
| Delete a resting order and place a new one, the placement listed first | The old order is deleted and the new one rests |
What the rules do not change:
- A managing action that depends on another action in the same evaluation acts at the next one. "Delete the pending orders once flat" in the evaluation that closes the last position reads the position still open, and deletes at the next evaluation. Give both actions the same condition instead.
- Candle-close actions run before tick actions. An On Tick close on a candle-boundary tick cannot free the slot for a candle-close open on that same tick.
- Closed-trade readings (consecutive losses, trades per period, time since the last trade, session P&L) see a trade closed in this evaluation at once in tick mode, from the next bar in bar mode, and when the fill arrives live. An open gated on them in the same evaluation as a close can differ by one trade.
- Account figures in bar mode. An open's conditions see the positions the evaluation's closes will close as gone, but balance, equity and margin are the bar's until the orders fill at the next bar's open. A modify waiting for the next bar's open does not show in a position's stop or target before it executes.
- Live, a refused close. The opposite open may already be on its way; both positions stand until the next evaluation.
- Live, two closes of one position decided in one evaluation are sent as one order: the volumes add up, never beyond the position's own.
5. What a rule can see: no look-ahead
Shift convention (MT5's).
- In an On Candle Close evaluation, shift 0 is the bar that just closed and shift k is k bars further back.
- In an On Tick or On Timer evaluation, and in an On Tick status holder, shift 0 is the developing bar of the current period and shift 1 is the last closed bar. The developing bar's open is its first price, its high and low are the extremes so far, and its close is the latest price.
- A candle-close rule never sees a developing bar.
- Negative shifts are refused when you save and when a run starts.
Indicators at shift 0 in On Tick rules.
- The value is provisional: it is computed with the developing bar as the newest input, while shift 1 and older stay on the committed series.
- If the symbol has not ticked yet in the current period, the read falls back to the last closed bar.
- A value that cannot be produced reads as not available (NaN), never as a future value.
- Backtest and live behave the same way.
Higher timeframes at a decision. A candle-close evaluation reads the last closed bar of every higher timeframe as of the decision, including a bar that closes at exactly that moment. An H1 value is therefore current at xx:00, not an hour old.
The developing higher-timeframe bar.
- Tick mode and live build it from the ticks seen so far. At a backtest's start it is seeded with the period's already-closed minutes, so a run started at 09:17 begins with an H1 bar that already holds 09:00–09:17.
- Bar mode builds it from the 1-minute bars already processed. In the pass deciding minute M, it holds M's close, as tick mode does: the bar being decided has closed at the decision instant.
What prevents look-ahead.
- A market order fills at the deciding tick's quote in tick mode, or at its symbol's next tick when that symbol is paused, and at the next bar's open of its own symbol in bar mode.
- In bar mode, a candle-close order's stop, target and volume, read when it fills at the next bar's open, read what its decision read, never the bar it fills into.
- Higher-timeframe reads see only closed bars, or a developing bar built from data already seen.
- Bar mode's developing bars use only minutes already processed.
- Negative shifts are refused.
Read conventions that can surprise you
- A Price Range at shift 1 includes the bar that just closed in a candle-close rule. "Close at shift 0 > highest of N at shift 1" can therefore never be true, and the strategy trades zero times without an error; read the range at shift 2. The rule and the workaround: Strategy semantics → Price Range.
- A second symbol's 1-minute bars are one bar late at a candle close. At a candle-close decision, shift 0 of a second symbol's M1 series is the bar before the one that just closed for the primary: at the 10:05 decision the primary reads its 10:04 bar and the second symbol its 10:03 bar. This happens identically in both modes, and it is a delay, never a look-ahead. Higher-timeframe series of the second symbol are not affected.
6. Warm-up, start and end of a run
Warm-up depth. Before your start date the engine loads enough history for the deepest read in the strategy. Each value source needs:
- an indicator: the bar of its first value, given on its entry (indicators), one bar more for a colour line, plus the bars a line is drawn forward (a Shift field, the Alligator's shifts, Ichimoku's cloud);
- Parabolic SAR, either method: a convergence depth of at least 64 bars;
- VWAP: the most bars one period of its anchor can hold on its timeframe;
- price range: its bar count, plus one period of 1-minute bars when it is read at shift 0 on a higher timeframe;
- session range: one day of its timeframe;
- candle data: 0 bars;
- an expression: the largest need among the values it references.
To each need the engine adds the shift the source is read at, then uses the largest result for every series: each higher-timeframe series gets that many of its own bars before the start, and each 1-minute series gets that many minutes (more where needed to rebuild the period that straddles the start).
During warm-up nothing trades and no rule is evaluated. The history only primes the indicators and windows. Recursive indicators (every exponential or smoothed average and the indicators built on one) start from that warm-up only, not from all available history, so their first values in a run depend on how much warm-up was loaded; how fast they converge, and what to do about it, is on Strategy semantics → recursive indicators.
Values before warm-up completes. Until an indicator has enough bars, it reads as not available (NaN); how a condition treats that is on Strategy semantics → not-evaluable operands.
The first evaluation.
- Bar mode starts at the first 1-minute bar opening at or after your start, and takes its first decision at that bar's close: one minute after your start when a bar opens at it. A candle close falling exactly on your start is not decided, because deciding it would need the bar before the period.
- Tick mode starts at the first tick at or after your start.
- An On Tick rule can act on that first tick. A candle-close rule first acts at the first bar boundary after it, because the first tick never fires a candle close.
When there is not enough history. If the stored data before your start is shorter than the warm-up:
- for the primary symbol's 1-minute series, the missing bars are taken from inside your period: no rule runs and no order is checked on them, so the strategy starts that many bars after your start date, and the result does not say so;
- a higher-timeframe series starts with the bars that exist, so its indicators have no value until enough bars have closed.
The date picker offers the full stored range (the overlap of every referenced symbol's data) without reserving room for warm-up, so a run with any indicator that starts on the first offered day is affected. A live deployment in the same situation refuses to start (Live execution → warm-up).
Results depend on the start date. Each of these starts with the run:
- the warm-up depth;
- the developing-bar seed;
- status holders and record sets, which start from their initial values, except a record set with a lookback, rebuilt over the bars before the start;
- crossover memory, which starts empty;
- the On Timer schedule;
- drawdown-limit windows, which open at the first step;
- the balance path.
The same month can therefore trade differently inside a longer run.
Bounds and the end of a run
The period's bounds. The dates you pick are whole UTC days (market data → history). A run covers bars whose open time is between start and end, and ticks whose timestamp is between start and end, both included; the last bar may close up to a minute after the end. The longest range is in §10.
When data ends early. If the primary's data ends before your end date, the run ends at its last bar without a message (in bar mode, a traded second symbol's remaining bars in the period are still processed, with no decision). In bar mode, if a symbol read only by conditions above M1 runs out of 1-minute data before the end, the run fails with a message naming the symbol ("Market data for {symbol} does not cover the requested window…"), rather than continuing with stale values.
The end of a run.
- Every pending order is cancelled.
- Every open position is closed at the last price, with exit reason Forced close and slippage applied. In tick mode that is each symbol's latest tick; in bar mode it is the last bar's close, plus spread for a short.
- These closes are stamped with the time of the last tick the run reached in tick mode, and with the open time of the last 1-minute bar in bar mode (of a second traded symbol's last bar when that one is later).
- Closes a drawdown limit forces are not end-of-run closes: they are stamped at the breaching tick or bar and carry the exit reason Drawdown limit (drawdown limits in backtests).
- In bar mode, an order decided on the last bar is not executed, because there is no next bar to fill it.
7. Multi-symbol strategies
Order across symbols. In tick mode each tick is processed for its own symbol: its pending orders, stops, targets, trailing and On Tick actions. Equity, margin, stop-out and drawdown are recomputed on every tick with every symbol's latest price.
A tick of symbol B never triggers a stop, target or pending order on symbol A. It can, however, take the account into stop-out, and a stop-out may close a position on A.
A symbol with no ticks for a while keeps its last price. Equity on other symbols' ticks uses that price, and its own pending orders and stops are tested only when it ticks again. A market order on it waits for its next quote when it is paused (paused symbols). Until a symbol's first tick in the run, its price comes from its latest bar: the bid is the close, and the ask is the close plus that bar's spread.
Symbols read only by conditions.
- In tick mode they get their full tick stream, but they never fire candle closes.
- In bar mode, when read above M1, their developing bars are built from their 1-minute data, and the run fails if that data runs out before the end.
Currency conversion. Profit in another currency is converted at one catalog pair's current bid (inverted for an inverse pair); no third currency is used, and a run with an instrument whose currency has no such pair is refused when you start it. Tick mode uses that pair's latest tick, bar mode its current 1-minute bar. The full rule, and which account currencies cannot trade which instruments: Costs and the account → conversion.
A close action closes positions on every symbol, each at its own symbol's price; an On Tick close without a symbol runs on every tick of every loaded symbol (close scope). A position on a paused symbol closes at that symbol's next quote.
Orders on a paused symbol
Markets pause: every day for a while (Brent from 22:00 to 01:00 UTC in winter, the metals from 22:00 to 23:00), and over the weekend. A broker does not fill a market order there at the last price before the pause, so neither does a backtest.
- Which orders. A market open, and the close or partial close of a position, on a symbol that is not quoted when the order is sent. A pending order is not held: tick mode places it when it is sent, bar mode at its symbol's next 1-minute bar. It fills, as stops and targets trigger, only on its own symbol's prices.
- When a symbol counts as paused.
- Tick mode: the order is sent on another symbol's tick, and its own symbol has no 1-minute bar for the minute before. The minute before is over, so the test reads nothing after the decision.
- Bar mode: its symbol has no 1-minute bar at the step where the order fills.
- Either mode: its symbol has had no price at all yet in the run (a symbol with no price yet).
- What happens. The order waits and fills at its symbol's next quote (tick mode) or at the open of its next 1-minute bar (bar mode), at that price and time, before anything else on that symbol, in the order the orders were sent. A close and an open decided together on a paused symbol therefore both fill at its reopen, the close first.
- Meanwhile. The position keeps its last price for equity and margin, pays a swap rollover it is open across, and is not closed twice: a later close of a position already waiting for one adds nothing (a full close widens a waiting partial one). The wait is invisible to your rules: an open that is waiting does not count as a position until it fills.
- When the run stops first. A drawdown limit that closes everything, a stop-out and the end of the run drop the waiting orders; their positions close with everything else.
- The first minute of a pause still counts as quoted in tick mode, since the minute before had a bar: an order sent then fills at the symbol's last tick.
A symbol with no price yet
A symbol can have no price at all for a while after a run starts: no bar and no tick of it yet. Until its first one:
- Its bid, ask and spread are not a number. A condition that reads them is not met, as with an indicator that has no value yet, and the run goes on.
- A market order on it whose volume, stop and target do not read its price waits for its first quote and fills there, as at a reopen: at its first tick (tick mode) or at the open of its first 1-minute bar (bar mode).
- An order whose volume or levels read its price (a stop at the ask less a distance, a volume sized by exposure) cannot be computed yet in tick mode, where they are computed when the order is sent. It is refused for a value that is not a number (refusal reasons): a market order at the symbol's first quote, after waiting for it; a pending order when it is sent. Bar mode computes them when the order fills, at the symbol's first bar, where they have a price, so the same order is placed or filled there.
- A pending order is placed in tick mode with no check of its side of the market, since there is no price to check it against. A buy limit above the first quote, for instance, then fills at that quote by the usual rule. Bar mode places it at the open of the symbol's first 1-minute bar and checks it against that price, so the same order is refused there.
- A modify of positions finds none on that symbol. In tick mode a modify of a pending order resting there is not checked for its side either, as at its placement.
Live trading follows the same rule from every start (a deploy, a restart, a move to another server) until the deployment receives its first live price of the symbol:
- Its bid, ask and spread, and the profit of a trade already open on it, are not a number: a condition that reads them is not met. A "close when the profit is below X" rule therefore waits for the symbol's first price after a restart instead of reading a loss that is not there.
- An order whose volume or levels read its price is computed when it is sent, as in tick mode, and is not sent. A risk-based volume whose entry reads it is never raised to the minimum volume.
- Everything else runs: rules that do not read the symbol, exits, stops, targets and trailing stops. A market order whose levels do not read its price goes to your broker as usual.
- The deployment's activity log says which symbols it is waiting for and when each first price arrives, and warns if one still has none a minute after the start (live execution).
Bar mode with more than one traded symbol
Bar mode tests every traded symbol on its own prices.
- Each symbol at its own bar. At every step each traded symbol is priced at its own 1-minute bar of that minute, or at its last bar's close when it has none. Bid and ask, the next-open fill price, the end-of-step equity and the worst price inside the bar all come from that bar.
- Each order and position on its own bar. Stops, targets, trailing stops and pending orders are tested against their own symbol's 1-minute bar, at a minute where that symbol has one. Pending expiries are checked at every step.
- Fills at the symbol's own next open. A market order on another symbol fills at the open of that symbol's next 1-minute bar, and so does the close of a position on a symbol with no bar at the step (paused symbols).
- Every traded symbol's minutes are steps. A minute in which a traded second symbol has a bar and the primary has none is still processed for that symbol: orders due on it fill, swap is charged, its pending orders, stops, targets and trailing stops are tested, and the account is updated. No rule runs there: decisions stay on the primary's bars. After the primary's last bar, the second symbols' remaining bars in the period are processed the same way.
What a rule reads of a second symbol is unchanged: its 1-minute bars are one bar late at a candle close (read conventions), in both modes.
8. Account events during a run (timing)
Where each account event falls in a step is in the order of operations. The rules themselves:
- Equity and drawdown are measured after every tick in tick mode, and at every bar's close in bar mode together with each position's worst price inside the bar (drawdown).
- Stop-out happens when equity falls below 0, checked after every tick or at every bar's close; it closes every position and ends the run (stop-out).
- Drawdown limits are checked at the end of every tick or bar; how a breach closes positions and pauses or stops the run is on Drawdown limits → in backtests.
- Swap is charged at the first step at or after the rollover minute of each new period, before that step's pending fills and stop and target check (swap).
- Refused orders leave no trade and are visible only in a recorded replay (after a refusal).
9. Determinism, reruns and time stamps
No randomness. The engine has no random element and reads no wall clock while simulating: the same strategy, settings and data give the same trades, and simultaneous events always resolve in the same order (ticks by timestamp then a fixed symbol order; actions in strategy order). How this is checked: Why you can trust the engine → same inputs, same result. Recording a replay does not change a result (replay), and every combination of a sweep runs with the same frozen settings as a backtest (optimization).
Reruns.
- A rerun repeats the run's frozen strategy snapshot and settings, or the same snapshot with edited settings.
- It runs on the engine and the stored data as they are on the day of the rerun.
- A run does not record which engine version produced it.
Rounding of levels. Computed stop, target and order prices, and trailed stops, are rounded to the symbol's digits; prices read from a tick are not. The rule, including a level on an exact half (rounded away from zero, as MetaTrader 5 does): market data → two precisions.
Timestamps. All times are UTC.
- Tick mode: every event carries the time of the tick being processed.
- Bar mode, inside a bar: stop and target exits, pending fills and forced closes are stamped with that bar's open time, although they happen inside the bar.
- Bar mode, market fills: stamped with the next bar's open time, which is when they actually fill.
- Equity chart: a bar-mode point is stamped at the bar's open with the equity at its close; a tick-mode point is stamped at the start of the minute.
10. Limits that can stop a run
When you start a run. The run is refused if any of these is exceeded:
- range: 10,957 days, in either mode;
- the initial balance and the leverage: the allowed values in the account settings;
- the account currency: one of the offered currencies, and every traded instrument's profit must be convertible into it (conversion);
- memory: the memory the run would need, against the memory a backtest runs with. In tick mode each market read tick by tick (the strategy's own, and each pair read to convert into the account currency) holds its own month of ticks, so the number of markets decides far more than the period, which adds little. The message names the markets, what they need, how many tick mode fits over the period and the ways to fit. It reads, for example, "This backtest can't start: in tick mode it reads 7 markets tick by tick (…), which needs about 2.1 GB of memory, and a backtest runs with 2 GB. Tick mode fits up to 6 markets over this period. To run it, use bar mode, which needs much less memory; split the strategy's markets across separate runs; or choose an account currency that needs fewer conversion pairs."
Plan quotas also apply (plans). One backtest runs at a time: a start while one runs passes these checks and waits in your queue (up to twenty), and its turn checks your plan again; a start with twenty already waiting is refused, and so is a start on a spent day with none running.
While it runs. The run fails, with a message naming the limit, when it hits one of these:
- Time budget. A wall-clock budget that grows with the simulated years: 3,600 s plus 1,320 s per simulated year in tick mode, or plus 180 s per simulated year in bar mode. A run is also stopped early once 5% of it is done if it is projected to need more than 6× its budget. The message reads, for example, "Backtest exceeded its compute budget ({N} min) and was stopped."
- Today's backtest time. The share of the day's backtest time the run holds, when that is shorter than its time budget: it is stopped there, or early once projected past 1.25× it, with a message about today's time (plans → backtests).
- Completed trades. More than 2,000,000.
- Open trades. More than 50,000 open positions plus pending orders.
- Memory. A run that would not fit is refused when you start it (above), so running out of memory while it runs is rare. If it happens, the message names the memory a backtest runs with, how much the run had reached, and what to change: a shorter period, for example several runs of a few years each, or bar mode, which needs much less memory. It reads, for example, "The backtest ran out of memory and was stopped. A tick-mode run over {N} years needs more than the {memory} of memory a backtest runs with (it had reached {peak}). Run it over a shorter period, for example as several runs of a few years each, or in bar mode, which needs much less memory."
Cancel. If you cancel a run, it ends as Cancelled with the results accumulated up to that point.
Complexity cap. A strategy whose evaluation per tick exceeds 500 units can still be saved, but backtests, optimizations, deploys and restarts are refused, with a message naming the three heaviest parts. How each part is weighed, and what to shorten: Strategy semantics → the complexity limit.
11. Backtest versus live
- Shared decision code. Backtest and live run the same decision code: the phases and their order, event gating, status holders and record sets, the trailing and break-even rule, the order checks and developing-bar reads. Every place where a live deployment can still behave differently from a tick-mode backtest of the same revision is in the table on Live execution → live versus a backtest.
- What a bar-mode result tells you about live. Less than tick mode does. Bar mode cannot see what happens inside a minute: fills at levels, the stop-first rule, next-open fills, the bar-average spread, On Tick once per minute, and Market Price at the bar close. Tick mode and live share the quote model.
12. Coming from MetaTrader 5
- Tick by tick corresponds to MT5's "Every tick based on real ticks": both replay real ticks, and this is the mode that has been compared with MT5 trade by trade. Bar by bar (M1) is not MT5's "1 minute OHLC": MT5 replays four price points per minute, bar mode one step per minute on the bar's range, so the two cannot agree trade for trade. Every timing difference that can change a result is on Compared with the MT5 Strategy Tester → modes and timing.
Not yet documented
- Live: a second symbol's 1-minute bars at a candle close. Both backtest modes read these bars one bar late (§5). The live engine's behaviour on the same read has not been measured.
- Live versus backtest indicator values right after a deployment starts. Live warms each timeframe to its own depth, while the backtest uses one depth for all series. The size of any difference in the first bars has not been measured.
- How often multi-symbol candle-close decisions differ from live. It is not yet measured how often a multi-symbol tick-mode backtest takes a candle-close decision on another symbol's tick, using the primary's pre-boundary price, and how much that changes fills compared with live.
- MT5 at the run start. Whether MT5's tester enters on the very first tick of the test when a candle-close strategy is already in signal is recorded only as an allowance in the parity runs, and has not been established.
Questions?support@algotradinghub.io