Backtest Orderflow

Every order flow idea starts as a hunch: a big buyer hits the offer and price follows. MarketByOrder lets you test it on the same tick data, from watching one trade to backtesting every trade in the session.

We will follow one idea the whole way through: when a large aggressive trade prints, trade in its direction.

1. Trade it by hand on the DOM

Pick a date and start a replay. Watch the DOM ladder and the Time and Sales. When a big print hits, enter on Sim with a bracket and see how it plays out. Pause whenever you want, and use Replay from here to take the same moment again.

ES DOM ladder with a Sim long at 7721.50, its target at 7724.50 and stop at 7719.50, next to the Time and Sales.

This is the fastest way to find out whether the idea feels tradable at all. New to the ladder? Start with how to read the DOM.

2. Mark every one with an indicator

Trading by hand shows you a few examples. An indicator shows you all of them. Turn on Big Trades from the Indicators panel and every large aggressive order gets a circle on the chart, sized against the others. Scroll the day and look at what price did after each one.

One minute ES chart with the Big Trades indicator circling every large buy in blue and sell in red.

Want a different rule? Every indicator is a script. Duplicate one and edit it, or write your own with the Code API.

3. Backtest it with an algo

Open Algos from the order panel. The built-in Large trade entry algo waits for a trade of 100 contracts or more, then enters in the same direction with an 8 tick target and a 4 tick stop.

Large trade entry

Built into Algos. Press Duplicate to edit to change the size, target or stop.

// Follow a large trade with a bracketed entry.
// https://marketbyorder.com/docs/api/algos

const MIN_SIZE = 100
const TAKE_PROFIT_TICKS = 8
const STOP_LOSS_TICKS = 4
const COOLDOWN_MS = 30_000
let nextEntryTime = 0

onUpdate(({ time, bid, ask, trades }) => {
  if (time < nextEntryTime) return
  if (orders.position().side !== "flat" || orders.working().length > 0) return

  const signal = trades.findLast(trade => trade.size >= MIN_SIZE && trade.side !== "none")
  if (!signal) return

  if (signal.side === "buy") {
    orders.buy(1, {
      tp: ask + TAKE_PROFIT_TICKS * tickSize,
      sl: ask - STOP_LOSS_TICKS * tickSize,
    })
  } else {
    orders.sell(1, {
      tp: bid - TAKE_PROFIT_TICKS * tickSize,
      sl: bid + STOP_LOSS_TICKS * tickSize,
    })
  }
  nextEntryTime = time + COOLDOWN_MS
})

Press Backtest and it runs over the loaded history one trade at a time, with the order book as it stood at each moment. Limit orders fill only when price trades through them.

When it finishes you get round trips, wins, losses and net P&L. Change a number, run it again, compare.

Algos window with Large trade entry backtested on ES: 6 round trips, 1 win, 5 losses, net -$172.80 over 454,379 trades.

4. Ask the chat

Don't want to write code? Ask Claude in the chat: "Backtest Large trade entry on ES with a 150 contract minimum." It saves a copy with the new minimum, runs the backtest, and reads the results back to you. Then ask it to try a tighter stop.

Chat asked to backtest Large trade entry with a 150 contract minimum, replying with 1 round trip and net -$53.80.

What we found

We ran this idea across a full week in Backtesting Big Trades, and tested whether absorption marks a reversal in Backtesting Absorption. Both posts include the algo so you can run it yourself.

Test your own order flow idea.

Start backtesting

See plans and pricing