WaitForOcoClosingBracket

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference > Strategy >

WaitForOcoClosingBracket

Previous page Return to chapter overview Next page

Definition

Determines if the strategy will submit both legs of an OCO bracket before submitting the pair to the broker.

 

Why would this be needed?

There may be brokers who require that OCO orders are submitted simultaneously in a single API call vs sending them in sequence with an include user defined OCO identifier. For brokers that require OCO orders to be submitted in a single function call, a NinjaScript strategy must wait until it has both legs of the OCO pair generated by SetStopLoss(), SetTrailStop() and SetProfitTarget().

 

Warning:  If you only wish to send a stop loss or profit target (but not both) via any of the Set...() methods mentioned above, when WaitForOcoClosingBracket is enabled, your exit orders will NOT be sent since NinjaTrader needs to wait until it has both orders of the OCO bracket. Disabling WaitForOcoClosingBracket NinjaTrader will immediately submit a stop or profit target order, whichever is submitted first.

 

 

Property Value

This property returns true if the strategy will wait for both legs of an OCO bracket to be called in a strategy before submitting the order pair to the broker; otherwise, false.  Default value is set to true.

 

Note:   Current affected brokers: TD AMERITRADE.  For any other broker, this property has no effect.

 

 

Syntax

WaitForOcoClosingBracket

 

 

Examples

ns


protected override void OnStateChange()
{
    if (State == State.Configure)
    {
        WaitForOcoClosingBracket = false;
    }
}