Definition
Generates a trail stop order to exit a position. Trail stops are amended 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.
• | It is suggested to call this method from within the strategy Initialize() method if your trail stop price/offset is static |
• | You may call this method from within the strategy OnBarUpdate() method should you wish to dynamically change the trail stop price while in an open position |
• | Should you call this method to dynamically change the trail stop price in the strategy OnBarUpdate() method, you should always reset the trail stop price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your trail stop order on your next open position
|
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 stop loss amount in currency ($500 loss for example)
|
mode
|
Possible values:
CalculationMode.Percent
CalculationMode.Ticks
Note: CalculationMode.Price is irrelevant for trail stops
|
simulated
|
If true, will simulate the stop order and submit as market once triggered
|
value
|
The value the trail stop order is offset from the position entry price (exception is using .Price mode where 'value' will represent the actual price)
|
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()
{
SetTrailStop(CalculationMode.Ticks, 12);
}
|
|
Tips (also see Overview)
• | The SetTrailStop() method can NOT be used concurrently with the SetStopLoss() method for the same position, if both methods are called for the same position (fromEntrySignal) the SetStopLoss() will always take precedence. You can however, use both methods in the same strategy if they reference different signal names. |
• | Trail stop orders are submitted in real-time on incoming executions from entry orders |
• | A strategy will either generate a trail stop order for each partial fill of an entry order or one order for all fills. See additional information under the Strategies tab of the Options dialog window. |
• | If a profit target order is generated in addition to a trail stop order, they are submitted as OCO (one cancels other) |
• | Trail stop orders are submitted as stop market orders |
• | A trail stop order is automatically cancelled if the managing position is closed by another strategy generated exit order |
|