Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ChangeOrder method not working for stop loss price change

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

    ChangeOrder method not working for stop loss price change

    I am trying to change the change the stop loss order based on certain criteria.ChangeOrder method doesn't seem to change the stop loss order at all. I am testing this in strategy analyzer. I have not tested in Realtime mode.

    <<Code below is simplified version>>

    //OnBarUpdate()
    if (trend == TrendMode.Bullish)
    {
    SetStopLoss(signalName, CalculationMode.Price, Close[0] - StopLossMinAmount, false);
    EnterLong(DefaultQuantity, signalName);
    }

    if (Position.MarketPosition != MarketPosition.Flat)
    ChangeOrder(stopLossOrder, stopLossOrder.Quantity, stopLossOrder.LimitPrice, Close[0] + StopLossMinAmount); //This is where it doesn't work. Any number of times this code executes, the stop loss price remains the same.

    ​//OnOrderUpdate - Get instance of stop loss order.
    if (String.Equals(order.Name, "Stop Loss"))
    {
    if (order.OrderState == OrderState.Submitted)
    {
    stopLossOrder = order;

    }
    }​

    How to make this work properly? Is there any sample available?
    Thanks,
    Sam

    #2
    Tested with Realtime data in simulation account. Lowering the price of stop loss order doesn't change the stop loss order. Stop loss order stays at the same price. Anyone can help?
    Thanks,
    Sambath

    Comment


      #3
      Hello sambathraj​,

      All you have to do is call the SetStopLoss again with the same signalName and the new price.

      Hope that helps!
      Matt

      Comment


        #4
        Thanks Matt. It worked.

        Any reason why ChangeOrder doesn't work in this case?
        Thanks,
        Sam

        Comment


          #5
          Hello sambathraj​,

          Glad to hear that works! As for why your approach did not, I'll leave to the NT Support. My guess is that it has something to do with that SetStopLoss is an NT8 managed approach. I'll be interested in the answer, as well.

          Kind regards,
          Matt

          Comment


            #6
            Hello sambathraj,

            The ChangeOrder method would be to change any limit type order that is not generated by the Set methods such as SetStopLoss. As StealthM93 mentioned with the set methods you just need to call the set method again to update the order.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            39 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            19 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            26 views
            1 like
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            42 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            35 views
            0 likes
            Last Post CarlTrading  
            Working...
            X