ChangeOrder()

View as Markdown

Definition

Amends a specified Order.

This method is only relevant for Managed orders with IsLiveUntilCancelled set to true and Unmanaged orders.

Syntax

ChangeOrder(Order order, int quantity, double limitPrice, double stopPrice)

If you have existing historical order references which have transitioned to real-time, you MUST update the order object reference to the newly submitted real-time order; otherwise errors may occur as you attempt to change the order. You may use the GetRealtimeOrder() helper method to assist in this transition.

Parameters

ParameterDescription
orderOrder object of the order you wish to amend
quantityOrder quantity
limitPriceOrder limit price. Use “0” should this parameter be irrelevant for the OrderType being submitted.
stopPriceOrder stop price. Use “0” should this parameter be irrelevant for the OrderType being submitted.

Examples

1private Order stopOrder = null;
2
3protected override void OnBarUpdate()
4{
5 // Raise stop loss to breakeven when you are at least 4 ticks in profit
6 if (stopOrder != null && stopOrder.StopPrice < Position.AveragePrice && Close[0] >= Position.AveragePrice + 4 * TickSize)
7 ChangeOrder(stopOrder, stopOrder.Quantity, 0, Position.AveragePrice);
8}