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.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ttodua, Today, 01:39 PM
            0 responses
            1 view
            0 likes
            Last Post ttodua
            by ttodua
             
            Started by carnitron, Today, 10:45 AM
            2 responses
            21 views
            0 likes
            Last Post carnitron  
            Started by dtaylor, Today, 01:13 PM
            0 responses
            4 views
            0 likes
            Last Post dtaylor
            by dtaylor
             
            Started by advgal, Today, 09:25 AM
            1 response
            13 views
            0 likes
            Last Post Soup Kitchen Jim  
            Started by pjsmith, Today, 07:13 AM
            1 response
            6 views
            0 likes
            Last Post bltdavid  
            Working...
            X