ProBacktest/probacktest · proorder

LOT

LOT specifies the order quantity in lots for BUY and SELL commands in ProBacktest and ProOrder. Interchangeable with CONTRACT, SHARE, and PERPOINT units.

Syntax

probuilder
BUY n LOT AT MARKET
SELL n LOT AT MARKET

Parameters

NameTypeDefaultDescription
nnumeric1 on entry, full position on exitNumber of lots to trade. When omitted, an entry order trades 1 unit and an exit order closes the whole position.

How it works

Order statements in ProBacktest and ProOrder follow the pattern verb quantity unit AT type. LOT fills the unit slot and tells the engine that the quantity is expressed in lots, a standardized block of units of the traded asset.

The unit keywords are aliases. LOT, LOTS, SHARE, SHARES, CONTRACT, CONTRACTS, and PERPOINT can replace one another on any instrument type, the engine interprets the quantity according to the instrument, not the word. The choice is readability: SHARES reads naturally for stocks, LOT for Forex, CONTRACT for futures and CFDs.

On Forex the lot convention has a real effect. The stated quantity is multiplied by the size of one lot, so BUY 1 LOT on a pair with a 100,000-unit lot size trades 100,000 units of the base currency.

When the quantity is omitted entirely, defaults apply. BUY AT MARKET enters with a quantity of 1, and SELL AT MARKET closes the entire open position regardless of its size.

Examples

Example 1, Conditional entry of one lot (ProOrder)

probuilder
// setup defined earlier in the strategy
validsetup = close crosses over Average[50](close)

IF NOT ONMARKET AND validsetup THEN
  // NextBarOpen is legacy syntax and can be omitted in current code
  BUY 1 LOT AT MARKET NextBarOpen
ENDIF

When flat and the setup fires, the strategy buys one lot at market. The order fills at the open of the next bar, which is the default behavior, so the trailing NextBarOpen modifier is redundant in current versions.

Example 2, Scaling out half of a position (ProBacktest)

probuilder
IF NOT OnMarket AND close crosses over Average[20](close) THEN
  BUY 2 LOT AT MARKET
ENDIF

// take half off once the trade has moved 50 points
IF LongOnMarket AND close - TradePrice >= 50 * PointSize THEN
  SELL 1 LOT AT MARKET
ENDIF

The strategy enters with two lots and sells one lot once the trade shows 50 points of profit, leaving the remaining lot to run.

Example 3, Short entry sized in lots (ProOrder)

probuilder
short = RSI[14](close) > 70 AND close < close[1]

IF NOT ShortOnMarket AND short THEN
  SELLSHORT 1 LOT AT MARKET
  SET STOP PLOSS 30
ENDIF

LOT works identically on the short side. One lot is sold short at market with a 30-point protective stop.

Common errors and gotchas

  • Forex multiplies by lot size. On currency pairs the quantity is scaled by the instrument's lot size, often 100,000 units. BUY 2 LOT can therefore control 200,000 units of base currency. Verify the instrument's lot size before sizing positions.
  • Omitted quantity defaults differ by direction. BUY AT MARKET trades exactly 1 unit, but SELL AT MARKET closes the whole position. Assuming symmetrical defaults leads to unintended full exits when scaling out.
  • Unit keyword does not change the math. Swapping LOT for CONTRACT or SHARES on the same instrument changes nothing in execution. Reading CONTRACT as a different position size than LOT is a misconception.
  • Broker minimums still apply. In live ProOrder the broker's minimum and step sizes constrain the quantity, and DEFPARAM MINORDER or MAXORDER settings can filter or clip the order. A syntactically valid LOT quantity can still be rejected.
  • CONTRACT, alias unit keyword commonly used for futures and CFDs.
  • SHARES, alias unit keyword commonly used for stocks.
  • 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.
  • SELLSHORT, opens or adds to a short position.
  • MARKET, immediate execution at the current market price.
  • ONMARKET, true while any position is open.