NinjaScript > Language Reference > Strategy > Order Methods > Unmanaged Approach >

ChangeOrder()

Print this Topic Previous pageReturn to chapter overviewNext page

Definition
Amends an Unmanaged order.

 

Syntax

ChangeOrder(IOrder iOrder, int quantity, double limitPrice, double stopPrice)

 

 

Parameters

iOrder

IOrder object of the order you wish to amend

quantity

Order quantity

limitPrice

Order limit price. Use "0" should this parameter be irrelevant for the OrderType being submitted.

stopPrice

Order stop price. Use "0" should this parameter be irrelevant for the OrderType being submitted.

 

 

Examples

private IOrder stopOrder = null;

 

protected override void OnBarUpdate()
{
    // Raise stop loss to breakeven when you are at least 4 ticks in profit
    if (stopOrder != null && stopOrder.StopPrice < Position.AvgPrice && Close[0] >= Position.AvgPrice + 4 * TickSize)
         ChangeOrder(stopOrder, stopOrder.Quantity, stopOrder.LimitPrice, Position.AvgPrice);
}