ExitLongStopLimit()
Previous Topic  Next Topic 

Definition
Generates a sell stop limit order to exit a long position.


Method Return Value

An IOrder read-only object that represents the order. Reserved for experienced programmers, additional information can be found within the Advanced Order Handling section.

Syntax
ExitLongStopLimit(double limitPrice, double stopPrice)

ExitLongStopLimit(int quantity, double limitPrice, double stopPrice)
ExitLongStopLimit(double limitPrice, double stopPrice, string fromEntrySignal)

ExitLongStopLimit(double limitPrice, double stopPrice, string signalName, string fromEntrySignal)

ExitLongStopLimit(int quantity, double limitPrice, double stopPrice, string signalName, string fromEntrySignal)


The following method variation is for experienced programmers who fully understand Advanced Order Handling concepts.


ExitLongStopLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, double stopPrice, string signalName, string fromEntrySignal)


Parameters

signalName

User defined signal name identifying the order generated.

fromEntrySignal

The entry signal name. This ties the exit to the entry and exits the position quantity represented by the actual entry.

limitPrice

The limit price of the order

stopPrice

The stop price of the order.

quantity

Entry order quantity.

liveUntilCancelled

The order will NOT expire at the end of a bar but instead remain live until the CancelOrder() method is called or its time in force has been reached.

barsInProgressIndex

The index of the Bars object the order is to be submitted against. See the BarsInProgress property. This determines what instrument the order is submitted for.


Examples

private double stopPrice = 0;

protected override void OnBarUpdate()
{
    if (CurrentBar < 20)
        return;
   
    // Only enter if at least 10 bars has passed since our last entry
    if (BarsSinceEntry() > 10 && CrossAbove(SMA(10), SMA(20), 1))
    {
        EnterLong("SMA Cross Entry");
        stopPrice = Low[0];
    }

    // Exits position
    ExitLongStopLimit(stopPrice - (10 * TickSize), stopPrice);
}


Tips (also see Overview)