Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

mulitple bracket trade management

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    mulitple bracket trade management

    hi - I need to create a strategy that has the following orders

    1 entry order which is a stop order (Buy Stop / Sell Stop) of quantity 6
    3 targets each with quantity of 2 at different price levels
    A protective stop for the whole trade and for the whole quantity.

    I need these to behave like OCO's in the sense that if the stop gets hit, all the targets gets caneled.
    If the targets get hit, the stop decreases in quantity accordingly.
    I imagine this can be implemented with 1 stop or 3 separate stops (1 stop for each target)

    So the question is, can this be done in NT7 using the managed approach?

    #2
    Hello onnb1,

    Thank you for writing in. You can accomplish this using a single stop by adjusting the order quantity. Here is a very basic example:
    Code:
    #region Variables
    	IOrder stopLoss, targetOne, targetTwo, targetThree;
    	private int stopLossQuantity = 6;
    	private double stopLossPrice;
    #endregion
    protected override void Initialize()
    {
        CalculateOnBarClose = true;
    }
    protected override void OnBarUpdate()
    {
    	if(Rising(Close) && targetOne == null && targetTwo == null && targetThree == null) //Enter your conditions instead here
    	{
    		EnterLongStop(6, Close[0], "EnterLongStop");
    		//EnterLongStop(int quantity, double stopPrice, string signalName)
    
    		targetOne = ExitLongLimit(0, true, 2, Close[0] * 1.001, "ExitLongLimit1", "EnterLongStop"); //Profit Target Example
    		targetTwo = ExitLongLimit(0, true, 2, Close[0] * 1.0025, "ExitLongLimit2", "EnterLongStop"); //Profit Target Example
    		targetThree = ExitLongLimit(0, true, 2, Close[0] * 1.005, "ExitLongLimit3", "EnterLongStop"); //Profit Target Example
    		//ExitLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName, string fromEntrySignal)
    		stopLossPrice = Close[0] - (Close[0] * 0.001);
    		stopLoss = ExitLongStop(0, true, stopLossQuantity, stopLossPrice, "StopLoss", "EnterLongStop"); //Stop Loss Example
    	}
    }
    protected override void OnExecution(IExecution e)
    {
    	if((targetOne != null && targetOne == e.Order) || (targetTwo != null && targetTwo == e.Order) || (targetThree != null && targetThree == e.Order) && e.Order.Filled > 0)
    	{
    		stopLossQuantity -= e.Order.Filled;
    		stopLoss = ExitLongStop(0, true, stopLossQuantity, stopLossPrice, "StopLoss", "EnterLongStop");
    		if(stopLossQuantity == 0)
    			stopLossQuantity = 6;
    	}
    }
    Here is some more information on working with IOrders: http://ninjatrader.com/support/helpG...nt7/iorder.htm

    Here is more information on working with the OnExecution method: http://ninjatrader.com/support/helpG...nexecution.htm

    You could instead create the stop loss and profit targets as an ATM strategy first (see ATM Strategy methods: http://ninjatrader.com/support/helpG...gy_methods.htm) and then create a strategy to enter that calls the ATM strategy. This would work as well, but you would not be able to track strategy performance.

    Please let me know if you have any questions.
    Michael M.NinjaTrader Quality Assurance

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    601 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    347 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    559 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    558 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X