Order commands reference

All 6 order commands in AlgoBarsX, each with its parameters, defaults, ranges and an example: buy, sell, close, close_all, modify, cancel.

buy sell close close_all modify cancel

buy [options]#

Open a long position or place a buy order.

Options

NameTypeDefaultWhat it is
sizelots | percent | money0.01 lotsPosition size in lots, or % / $ of balance as notional.
riskpercent | moneynoneRisk per trade; size is computed from the stop distance and rounded down to the lot step.
stopprice | distancenoneProtective stop. For a pending stop order, the entry price (its protective stop is then stop_loss).
targetprice | distancenoneTake-profit price or distance, such as 2R.
limitpricenoneEntry price of a pending limit order.
stop_lossprice | distancenoneProtective stop of a pending stop order.
ghostboolfalseKeep stop and target off the broker; AlgoBars enforces them.
expiresbars | durationnoneWhen a pending order expires.
marketsymbolmarket.symbolWhich symbol, in strategies with several markets.
tagstring""Label carried by the order and its trade.

Where it goes Inside a when rule, event or action fn of a strategy.

Block management

Example
buy risk: 1%, stop: 20 pips, target: 2R
strategysince 1.0

sell [options]#

Open a short position or place a sell order.

Options

NameTypeDefaultWhat it is
sizelots | percent | money0.01 lotsPosition size in lots, or % / $ of balance as notional.
riskpercent | moneynoneRisk per trade; size is computed from the stop distance and rounded down to the lot step.
stopprice | distancenoneProtective stop. For a pending stop order, the entry price (its protective stop is then stop_loss).
targetprice | distancenoneTake-profit price or distance, such as 2R.
limitpricenoneEntry price of a pending limit order.
stop_lossprice | distancenoneProtective stop of a pending stop order.
ghostboolfalseKeep stop and target off the broker; AlgoBars enforces them.
expiresbars | durationnoneWhen a pending order expires.
marketsymbolmarket.symbolWhich symbol, in strategies with several markets.
tagstring""Label carried by the order and its trade.

Where it goes Inside a when rule, event or action fn of a strategy.

Block management

Example
sell risk: $200, stop: highest(high, 10) + 2 pips, target: 2R
strategysince 1.0

close <trade> [options]#

Close a trade, fully or partly.

Arguments

NameTypeDefaultWhat it is
tradeTraderequiredTrade to close.

Options

NameTypeDefaultWhat it is
sizepercent | lots100%How much to close.

Where it goes Inside a when rule, event, loop or action fn of a strategy.

Example
close trades.last(), size: 50%
strategysince 1.0

close_all [options]#

Close all of the strategy's open trades, optionally filtered.

Options

NameTypeDefaultWhat it is
sidestringbothlong, short or both.
tagstring""Only trades with this tag.
marketsymbolmarket.symbolOnly this symbol.

Where it goes Inside a when rule, event or action fn of a strategy.

Example
close_all side: long
strategysince 1.0

modify <trade> [options]#

Change the stop or target of a trade.

Arguments

NameTypeDefaultWhat it is
tradeTraderequiredTrade to change.

Options

NameTypeDefaultWhat it is
stopprice | distanceunchangedNew stop.
targetprice | distanceunchangedNew target.

Where it goes Inside a when rule, event, loop or action fn of a strategy.

Example
modify trades.last(), stop: trades.last().entry_price
strategysince 1.0

cancel <orders>#

Cancel pending orders.

Arguments

NameTypeDefaultWhat it is
orderslist<Order>requiredOrders to cancel.

Where it goes Inside a when rule, event or action fn of a strategy.

Example
cancel orders.pending(tag: "grid")
strategysince 1.0

Try this in the Terminal. AlgoBars is free: $0 a month, no card needed.

Create my free account