SetExitStop

Top  Previous  Next

Sets the exit stop for the specified unit.

There must be a position on, so this cannot be used in the Unit Size, Can Add Unit, or Can Fill Order scripts. In these scripts the order is being processed so the order object should be used.

This function can be used in the Entry Order Filled, Exit, Entry, Adjust Stops, or After Instrument Day scripts.

 

Syntax

 

SetExitStop( [unitNumber,] stopPrice )

 

Parameters

unitNumber

 

the unit number (optional). If not supplied this will default to the first unit

stopPrice

 

the value of the stop to be set.

 

Example for the Entry Order Filled script:

' Move the stop by the amount of the slippage.

instrument.SetExitStop( order.fillPrice - order.entryRisk )

 

 

' Set the stop price for the specified unit.

instrument.SetExitStop( unitNumber, newStopPrice )

 

NOTE: If you set the stop with this function, the daily risk will be calculated using this value, but no order is placed. To place an actual stop in the market use a broker order like this: broker.ExitAllUnitsOnStop( instrument.unitExitStop ).