NinjaScript > Language Reference > Strategy > Order Methods > Managed Approach >

SetProfitTarget()

Print this Topic Previous pageReturn to chapter overviewNext page

Definition
Generates a limit profit target order to exit a position. Profit target orders are real working orders 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 profit target price/offset is static
You may call this method from within the strategy OnBarUpdate() method should you wish to dynamically change the target price while in an open position
Should you call this method to dynamically change the target price in the strategy OnBarUpdate() method, you should always reset the target price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your profit target order on your next open position
 

Syntax
SetProfitTarget(double currency)

SetProfitTarget(CalculationMode mode, double value)

SetProfitTarget(string fromEntrySignal, CalculationMode mode, double value)

 

Parameters

currency

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

mode

CalculationMode.Percent

CalculationMode.Price

CalculationMode.Ticks

value

The value the profit target 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 profit target exit to the entry and exits the position quantity represented by the actual entry.

 

 

Examples

protected override void Initialize()
{
    // Submits a profit target order 10 ticks away from the avg entry price
    SetProfitTarget(CalculationMode.Ticks, 10);
}

 

 

Tips (also see Overview)

Profit target orders are submitted in real-time on incoming executions from entry orders
A strategy will either generate a target 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 stop loss or trail stop order is generated in addition to a profit target order, they are submitted as OCO (one cancels other)
A profit target order is automatically cancelled if the managing position is closed by another strategy generated exit order