ReplaceOrder()

Description

Change order, as the name suggests, changes an order.

Usage

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

Parameter

iOrder

An order object of the type "IOrder"

quantity

Number of units to be ordered

limitPrice

Limit price. Set this to 0 if not needed

stopPrice

Stop price. Set this to 0 if not needed

Example

private IOrder stopOrder = null;
protected override void OnCalculate()
{
// If the position is profiting by 10 ticks then set the stop to break-even
if (stopOrder != null
    && Close[0] >= Position.AvgPrice + (10 * TickSize)
        && stopOrder.StopPrice < Position.AvgPrice)
ReplaceOrder(stopOrder, stopOrder.Quantity, stopOrder.LimitPrice, Position.AvgPrice);
}

Last updated