ProBacktest/probacktest · proorder

MINORDER

MINORDER is a DEFPARAM setting in ProBacktest and ProOrder that sets the smallest order size executed. Orders below the threshold are ignored entirely.

Syntax

probuilder
DEFPARAM MINORDER = value

Parameters

NameTypeDefaultDescription
valuenumericnoneSmallest number of units, contracts, or lots that can be executed in a single order.

How it works

DEFPARAM statements configure the execution environment and must appear at the top of the strategy, before any executable instruction. MINORDER sets a floor on order size: any order whose quantity falls below the configured value is dropped instead of being executed.

The setting exists for realism. Many instruments impose a minimum tradable size, one lot on a Forex account, one contract on a future, a minimum stake on a CFD. A sizing formula that divides capital by price can produce fractional or very small quantities that no broker would accept. MINORDER filters those orders out so the simulation only contains trades that could exist in practice.

Unlike MAXORDER, which clips oversized orders down to the cap, MINORDER does not round an undersized order up. The order is simply not sent. A strategy whose computed size stays below the threshold therefore never enters the market, which is itself a useful diagnostic: it reveals that the capital or the sizing formula is insufficient for the instrument.

Examples

Example 1, Enforcing a one-unit minimum (ProBacktest)

probuilder
// orders below 1 unit are not executed
DEFPARAM MINORDER = 1

IF NOT OnMarket AND close crosses over Average[50](close) THEN
  BUY 1 CONTRACT AT MARKET
ENDIF

The baseline configuration from the reference. Every order of at least one contract passes through, anything smaller would be discarded.

Example 2, Cash-based sizing that can fall below the floor (ProBacktest)

probuilder
DEFPARAM MINORDER = 1

// invest a fixed cash slice per trade
capitalPerTrade = 5000
positionsize = FLOOR(capitalPerTrade / close)

IF NOT OnMarket AND RSI[14](close) < 30 THEN
  BUY positionsize SHARES AT MARKET
ENDIF

When the share price rises above 5000, positionsize computes to 0 and the order falls under the MINORDER threshold, so no trade occurs. The filter prevents zero-quantity orders from reaching the engine.

Example 3, Minimum lot size on a Forex strategy (ProOrder)

probuilder
DEFPARAM MINORDER = 1

long = ExponentialAverage[20](close) crosses over ExponentialAverage[50](close)

IF NOT OnMarket AND long THEN
  BUY 1 LOT AT MARKET
  SET STOP PLOSS 40
ENDIF

IF LongOnMarket AND close < ExponentialAverage[50](close) THEN
  SELL AT MARKET
ENDIF

The minimum-order floor mirrors the account's smallest tradable lot, so the backtest cannot simulate positions the broker would refuse.

Common errors and gotchas

  • Undersized orders vanish silently. Orders below the threshold are skipped without an error or a log entry. A strategy that never trades in a backtest may simply be generating quantities under MINORDER, not failing its entry conditions.
  • No rounding up. MINORDER filters, it does not lift small orders to the minimum. Code that relies on the engine to bump a 0.4-lot order to 1 lot behaves differently than expected, the order is dropped.
  • DEFPARAM placement. All DEFPARAM statements must precede the first executable line. A DEFPARAM MINORDER further down the code fails to compile.
  • Exits are orders too. A partial exit whose quantity falls below the threshold is also skipped, which can leave a position open longer than intended when scaling out with computed quantities.
  • MAXORDER, maximum size allowed for a single order.
  • DEFPARAM, declares strategy-level execution parameters.
  • CASH, position sizing based on a cash amount.
  • BUY, opens or adds to a long position.
  • SELL, closes some or all of a long position.
  • LOT, order quantity expressed in lots.
  • CONTRACT, order quantity expressed in contracts.
  • SHARES, order quantity expressed in shares.