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
| Name | Type | Default | What it is |
|---|---|---|---|
size | lots | percent | money | 0.01 lots | Position size in lots, or % / $ of balance as notional. |
risk | percent | money | none | Risk per trade; size is computed from the stop distance and rounded down to the lot step. |
stop | price | distance | none | Protective stop. For a pending stop order, the entry price (its protective stop is then stop_loss). |
target | price | distance | none | Take-profit price or distance, such as 2R. |
limit | price | none | Entry price of a pending limit order. |
stop_loss | price | distance | none | Protective stop of a pending stop order. |
ghost | bool | false | Keep stop and target off the broker; AlgoBars enforces them. |
expires | bars | duration | none | When a pending order expires. |
market | symbol | market.symbol | Which symbol, in strategies with several markets. |
tag | string | "" | Label carried by the order and its trade. |
buy risk: 1%, stop: 20 pips, target: 2Rstrategysince 1.0
sell [options]#
Open a short position or place a sell order.
Options
| Name | Type | Default | What it is |
|---|---|---|---|
size | lots | percent | money | 0.01 lots | Position size in lots, or % / $ of balance as notional. |
risk | percent | money | none | Risk per trade; size is computed from the stop distance and rounded down to the lot step. |
stop | price | distance | none | Protective stop. For a pending stop order, the entry price (its protective stop is then stop_loss). |
target | price | distance | none | Take-profit price or distance, such as 2R. |
limit | price | none | Entry price of a pending limit order. |
stop_loss | price | distance | none | Protective stop of a pending stop order. |
ghost | bool | false | Keep stop and target off the broker; AlgoBars enforces them. |
expires | bars | duration | none | When a pending order expires. |
market | symbol | market.symbol | Which symbol, in strategies with several markets. |
tag | string | "" | Label carried by the order and its trade. |
sell risk: $200, stop: highest(high, 10) + 2 pips, target: 2Rstrategysince 1.0
close <trade> [options]#
Close a trade, fully or partly.
Arguments
| Name | Type | Default | What it is |
|---|---|---|---|
trade | Trade | required | Trade to close. |
Options
| Name | Type | Default | What it is |
|---|---|---|---|
size | percent | lots | 100% | How much to close. |
close trades.last(), size: 50%strategysince 1.0
close_all [options]#
Close all of the strategy's open trades, optionally filtered.
Options
| Name | Type | Default | What it is |
|---|---|---|---|
side | string | both | long, short or both. |
tag | string | "" | Only trades with this tag. |
market | symbol | market.symbol | Only this symbol. |
close_all side: longstrategysince 1.0
modify <trade> [options]#
Change the stop or target of a trade.
Arguments
| Name | Type | Default | What it is |
|---|---|---|---|
trade | Trade | required | Trade to change. |
Options
| Name | Type | Default | What it is |
|---|---|---|---|
stop | price | distance | unchanged | New stop. |
target | price | distance | unchanged | New target. |
modify trades.last(), stop: trades.last().entry_pricestrategysince 1.0
cancel <orders>#
Cancel pending orders.
Arguments
| Name | Type | Default | What it is |
|---|---|---|---|
orders | list<Order> | required | Orders to cancel. |
cancel orders.pending(tag: "grid")strategysince 1.0