Orders reference
The 7 functions and 0 values of orders: signature, effects, phase, cost and tested examples.
Place, change and cancel the orders of a strategy. The tester fills them on the bars of the chart under the rules of the setup and execution blocks.
Functions#
orders.cancel#
orders.cancel([key])
Cancels the pending order with this key.
- Effects: places, changes or cancels an order.
- Phase: every bar.
- Cost: one order record per call.
orders.cancel_all#
orders.cancel_all()
Cancels every pending order.
- Effects: places, changes or cancels an order.
- Phase: every bar.
- Cost: one order record per call.
orders.close#
orders.close(key, [comment], [qty], [qty_percent], [message], [immediately], [silent])
Closes the position that the entry with this key opened.
- Effects: places, changes or cancels an order.
- Phase: every bar.
- Cost: one order record per call.
- Examples: Moving average crossover strategy, RSI reversion strategy, Risk guards, Trade tally.
orders.close_all#
orders.close_all([comment], [message], [immediately], [silent])
Closes every open position.
- Effects: places, changes or cancels an order.
- Phase: every bar.
- Cost: one order record per call.
orders.enter#
orders.enter(key, side, [qty], [limit], [stop], [oca], [oca_type], [comment], [message], [silent], [expires])
Places an order in the direction side under the name key. Without limit or stop it is a market order; with one it waits until the price is reached, and expires limits how long it waits.
- Effects: places, changes or cancels an order.
- Phase: every bar.
- Cost: one order record per call.
- Examples: Moving average crossover strategy, Donchian breakout strategy, RSI reversion strategy, ATR stop and target.
orders.exit#
orders.exit(key, [entry], [qty], [qty_percent], [profit_ticks], [limit], [loss_ticks], [stop], [trail_price], [trail_ticks], [trail_offset_ticks], [oca], [comment], [profit_comment], [loss_comment], [trail_comment], [message], [profit_message], [loss_message], [trail_message], [silent])
Places the exit of the entry named entry: a stop, a limit, or a trailing stop, given as prices or as distances in ticks.
- Effects: places, changes or cancels an order.
- Phase: every bar.
- Cost: one order record per call.
- Examples: ATR stop and target, Donchian breakout strategy, Stops on the price grid, Loss limit before entry.
orders.place#
orders.place(key, side, [qty], [limit], [stop], [oca], [oca_type], [comment], [message], [silent], [expires])
Places an order of qty in the direction side under the name key, with the same price and expiry options as orders.enter.
- Effects: places, changes or cancels an order.
- Phase: every bar.
- Cost: one order record per call.