SetTrailStop()
Previous Topic  Next Topic 

Definition
Generates a trail stop order to exit a position. Trail stops are ammended on a tick by tick basis. Trail stop orders are real working orders (unless simulated is specified in which case the stop order is locally simulated and submitted as market once triggered) submitted immediately to the market upon receiving an execution from an entry order.


Syntax
SetTrailStop(double currency)

SetTrailStop(double currency, bool simulated)

SetTrailStop(CalculationMode mode, double value)

SetTrailStop(string fromEntrySignal, CalculationMode mode, double value, bool simulated)


Parameters

currency

Sets the trail stop amount in currency ($500 profit for example)

simulated

If true, will simulate the trail stop order and submit as market once triggered

mode

CalculationMode.Percent (0.01 = 1%)

CalculationMode.Price

CalculationMode.Ticks

value

The trail stop value

fromEntrySignal

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


Examples

protected override void Initialize()
{
    // Sets a trail stop of 12 ticks
    SetTrailStop(CalculationMode.Ticks, 12);
}


Tips (also see Overview)