Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

ChangeOrder and connections

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

    ChangeOrder and connections

    Is there a way to confirm that a ChangeOrder executed? Does it return a success or failure value?

    I got a log message saying I lost historical, price and order connection. I then got a message saying the historical and price connections were restored but not the order connection. How do I fix this?

    If I have a strategy running and there's an open position and orders, what should the sync setting be so that it doesn't get closed if the strategy is re-enabled after the connection is lost?

    Thanks!!
    Attached Files
    Last edited by GibbsB613; 05-27-2017, 03:51 PM.

    #2
    Hello GibbsB613,

    When an order is changed the order state becomes ChangePending/ChangeSubmitted.

    If the order change is successful the order state becomes Accepted or Working. (The same is true when submitting an order)



    Any time an order state is changed, this will trigger OnOrderUpdate().




    To restore the connection, disconnect from the connection and reconnect.

    To resume a strategy and ensure orders are not cancelled when the strategy is disabled.
    Ensure 'Cancel entry orders when a strategy is disabled' is unchecked and disabled
    Ensure 'Cancel exit orders when a strategy is disabled' is unchecked and disabled


    Set the Start behavior to 'Immediately submit' before first adding the instance of the strategy (this needs to be set before ever running the script)


    And ensure the script has intra-bar granularity.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I confirmed that the two boxes were unchecked.

      Ensure 'Cancel entry orders when a strategy is disabled' is unchecked and disabled.
      Ensure 'Cancel exit orders when a strategy is disabled' is unchecked and disabled.

      I'm calling ChangeOrder and nothing is happening, I'm not getting an error message or anything. The orders exist and all the parameters have values. It use to work but now nothing. Thoughts?

      ChangeOrder(myEntryOrder1Pt, Position.Quantity, NewLimit, 0);
      ChangeOrder(myEntryOrder1Sl, Position.Quantity, 0, NewStop);

      Thanks!

      Comment


        #4
        Hello GibbsB613,

        Have you confirmed that there are changes being made as part of that call? For example, that either the price or quantity are different from their previous value?

        When you are referring to the orders existing, do you mean they are working on the exchange? Could they be part of an entry order which hasn't be filled yet, thus the SL and PT orders have not yet been submitted?

        I look forward to your reply.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          I'm using Position.Quantity so that hasn't changed and I'm only testing one position. Shouldn't it still call ChangeOrder and throw an error or perform a partial operation? The price is different since I'm calculating the new prices; I'm printing the new values to the Output window.

          Thanks!
          Attached Files
          Last edited by GibbsB613; 05-29-2017, 06:32 PM.

          Comment


            #6
            I created a simple strategy to open a position and on the next bar update the stop and limit and it does nothing. See the attachment. I'm using CHFJPY in this demo.

            Also, after I close the position the strategy is disabled. What causes this?

            Thanks!!
            Attached Files
            Last edited by GibbsB613; 05-30-2017, 05:53 AM.

            Comment


              #7
              Hello GibbsB613,

              I would suggest commenting out lines 132 and 133. After doing so, is your stop and PT submitted as expected?

              It looks like on every bar update, you are going to submit a change order call for your PT and SL, with the same parameters, I would encourage you to set up a check to confirm that the qty or price is different before submitting a change order call. Are you seeing errors in the log when these ChangeOrder calls are made? When you say they used to work, what do you mean by this?

              I look forward to your reply.
              Alan P.NinjaTrader Customer Service

              Comment


                #8
                Did you test the code?

                1. The stop and PT are created as expected.
                2. I don't care if it sets it to the same value, the point is it never updates it at all. Why not?
                3. There are no errors in the log.
                4. It was working before my last NT 8 update.

                Do you see anything syntactically incorrect?

                Thanks!!

                Comment


                  #9
                  Hello GibbsB613

                  You should just call SetStopLoss/SetProfitTarget again within OnBarUpdate with the new parameters rather than use the ChangeOrder methods if you’d like to change order.

                  This is detailed in the helpguide,

                  “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”



                  I also put together a sample demonstrating this.

                  Please let us know if you need further assistance.
                  Attached Files
                  Alan P.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks a ton Alan. I'll give it a try later.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by BarzTrading, Today, 07:25 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post BarzTrading  
                    Started by i019945nj, 12-14-2023, 06:41 AM
                    5 responses
                    64 views
                    0 likes
                    Last Post i019945nj  
                    Started by ruudawakening, Today, 12:58 AM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by thread, Yesterday, 11:58 PM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by stafe, Yesterday, 08:34 PM
                    1 response
                    16 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Working...
                    X