Matana Labs

Order execution model

Every Matana Labs backtest walks history one second at a time, with one price and one traded volume per second. Orders fill from that price and that volume, by the rules below; every default value on this page is read from the code when the site is built.

One second at a time

A second is labelled by its end: 09:30:01 is the second from 09:30:00 to 09:30:01. Its price is the price trading actually had in that second (see data quality); a second without trades carries the previous price, is flagged, and nothing fills in it. Inside every second the engine works in a fixed order:

  1. protective exits of open positions: trailing stop, then stop, then target;
  2. resting orders: limit and stop orders, and orders that waited for a second with trades;
  3. the strategy’s rules, which read the state after steps 1 and 2 (see no look-ahead);
  4. the rules’ market orders, at this second’s price;
  5. in intraday mode, the day-end close.

So a position opened in a second is first checked against its stop in the next second, and a rule never sees a fill that has not happened yet.

Order types and their fill prices

OrderFills whenAt what price
MarketIn the second the rule fires; if that second had no trades, in the next second with tradesThat second’s price, plus slippage (and the ask or bid with the spread model)
LimitA second’s price is at the level or better (with the spread model: the ask for a buy, the bid for a sell)The level, or the better price if the market jumped past it
Stop (entry or exit)A second’s price reaches the levelThat second’s price: a jump past the level fills worse than the level
Protective stopA second’s price is at or beyond the stopThat second’s price; never capped by volume
TargetThe second’s price (the bid for a long, the ask for a short) reaches the targetThat second’s price
Trailing stopThe price retreats from the best price since entry by the distanceThat second’s price

Stops, targets and trails take a distance in percent, in dollars or as a multiple of ATR, or an exact level. A limit or stop order lives until the end of the day by default; it can also have a lifetime (ttl 10m), stay overnight until filled (gtc) or live for one second only. A newly placed order is first checked in the next second; the fillSameSecond setting (off by default) lets an order whose price is already reached fill in the second it was placed.

Two settings change how strict a limit is, both off by default: limitCross fills a limit at its level when the price jumped over it within one second, and limitThrough fills only when the price traded through the level, not just touched it, which is closer to how a queue works.

Stop-limit, MIT and OCO

The demo account and the prop challenge practice in Prop Lab also take stop-limit orders (the stop price arms a limit; the fill is never worse than the limit), market-if-touched orders (a touch of the level fills at market, with slippage against you) and one-cancels-other groups. A level the market gapped through fills at the first price after the gap, and when in doubt the fill is the worse one.

Volume, queue ahead and partial fills

A trade can take only part of each second’s volume:

available = (volume of the second − queue ahead) × participation

SettingDefaultWhat it does
Queue ahead (firstOrders)3,700 shares per secondVolume taken by other traders’ orders standing ahead of yours
Participation10% of what is left (new strategies)Your share of the second’s remaining volume
Minimum volume (minVolumeToTrade)100 sharesSeconds with less volume are skipped for new trades

Gaps

When the price jumps past an order’s level without trading at it, overnight or across a stretch of seconds without trades, the order fills at the real price after the jump, not at your level. That is the default. A setting (gapAtOrderPrice) fills the built-in mechanisms’ resting orders at their level instead, which is the optimistic choice and is labelled as such in the app. A limit order the market jumped through in your favour fills at the better real price.

Forced exits are the end-of-day close, the emergency, virtual and daily stops, the end of the backtest range, a margin liquidation and a regime exit. When one falls in a second without trades, by default the day-end close and the end of the range fill at once at the carried price, as they always have, and so do the emergency and virtual stops of a long position; the other forced exits are limited by the second’s volume, which is zero there, so they sell nothing in that second (a margin call is tried again every second; a daily stop or regime exit leaves the position to the next exit, usually the day-end close). The setting exitFill set to nextTrade makes it wait for the next second with a real trade, like any other order. If the session ends with no trade, the exit moves to the first trade of the next day in the backtest: the position is held overnight and takes the gap. If the backtest ends first, the exit fills in the last second at the last known price. The results card says which way was used and how many exits waited, how many were held overnight and how many reached the end.

Sessions: intraday or continuous

Execution delay, margin and liquidation

Updated 2026-11-24. Describes the product as it is today; numbers are read from the code when the site is built. Educational content, not financial advice.