• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unmanaged Approach: How to change only a price order ? ( without change quantity )

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

    Unmanaged Approach: How to change only a price order ? ( without change quantity )

    This the situation:

    - You submit a Buy order for X quantity at Y price.

    - The order is working and suddenly you have a partially filled, so the order continues with a ( X - filled ) at Y price

    - The Strategy requires to change the working order price, so you have to set:
    ChangeOrder( "iorder" , "quantity", " price", 0);

    - So, when you request this change, in spite of you put the same remaining quantity ( X-filled ) of the old working order, Ninjatrader updates it and keeps working BUT it will cause a silent error that stops the Strategy. This is because that old order has partially filled execution previously and if you touch quantity something is altered.

    So, How would you change only the price order ?
    Thanks


    #2
    This might be easily a technical support matter because, under unmanaged approach, intending to change a price order of a working order which is already partially filled leads to a silent error, the strategy hangs, because the command to amend an order. forces to put quantity. I think you should address this matter as soon as possible. I hope you can answer.

    Comment


      #3
      Hello pstrusi,
      Thanks for your post.

      What do you mean specifically by "silent error" and by "the strategy hangs". Does the strategy disable itself?

      Are there errors on your logs tab?

      Does the strategy simply stop processing logic and remains enabled?

      Additionally, please go ahead and write in to PlatformSupport(AT)NinjaTrader(DOT)com and reference this forum post with RE:JOSH in the subject line. Please attach your Log and Trace files to your email so that I may investigate this matter further. You may follow the steps below to attach those files.
      • Open your NinjaTrader folder under My Documents.
      • Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
      • Send the 2 compressed folders as attachments to your email.
      • Once complete, you can delete these compressed folders.
      JoshNinjaTrader Customer Service

      Comment


        #4
        "A silentt error" means that there's an error, issue or bug happening for real, that has no warning nor log registered, BUT it's clearly happening cause since that moment the Strategy seems to work, with an actual position, but it remains in a frozen state forever, which is not expected at all. Obviously the Strategy "hangs" in that state because it never will come back to normal. After a deep forensic analysis, I think I've found what it might be. Let me give you a simple an example, so you could answer my original question.

        Imagine you have a working order, buying 2 contracts of ES ( e-mini ), suddenly your order is partially filled with 1 contract, so that order remains now with filled of 1 whilst it continues to work with the remaining. Now, imagine that for some reason, the strategy needs to update or change the price order, so when you use the command: ChangeOrder( "iorder" , "quantity", " price", 0); you're forced to put quantity in that command, so now you're gonna put 1, because it's the remaining of that order, well, it seems that procedure creates some problem in that order internally, cause it upgrades the price and quantity accordingly, BUT since that moment the Strategy freezes. So, back to my original question:

        Is there any way to change a price order, under unmanaged approach, without putting quantity, just the price?

        Thanks


        Comment


          #5
          pstrusi,

          Is there any way to change a price order, under unmanaged approach, without putting quantity, just the price?
          No, you cannot change an order that way. Using the Unmanaged Approach requires submitting and adjusting orders manually based on order and position updates. In this case you need to track the fills.



          When you say that the strategy is in a frozen state, do you mean the platform is giving you a "pinwheel" indicating the software has frozen? Do you mean the strategy just stops placing orders?

          Do you see this same behavior occur in the Strategy Analyzer and in Market Replay?

          Can you create another simple strategy that produces this behavior? This new strategy would not have anything other than basic logic to submit an order and then change it. Do you see that the new strategy discontinues trading after changing the order?
          JoshNinjaTrader Customer Service

          Comment


            #6
            Thanks Josh for your attention and suggestions.


            - When you say that the strategy is in a frozen state, do you mean the platform is giving you a "pinwheel" indicating the software has frozen? Do you mean the strategy just stops placing orders?
            As I told before, the Strategy freezes means exactly that, it stops placing orders any longer until it's reset.

            - Do you see this same behavior occur in the Strategy Analyzer and in Market Replay?
            No, I don't


            - Can you create another simple strategy that produces this behavior? This new strategy would not have anything other than basic logic to submit an order and then change it. Do you see that the new strategy discontinues trading after changing the order?
            Unfortunately, I don't have time for creating these comprobations mechanism. As far I can tell, I've created a workaround which it simply cancel and submit a new order with the pending quantity. If the order is not partially filled, just change the price, so far it works, no more frozen Algos..

            Thanks!

            Comment


              #7
              Hello pstrusi,

              Thank you for your response.

              I am putting together a test for this on my end and I will follow up with you when I have information on this report.
              Last edited by NinjaTrader_PatrickH; 12-19-2018, 03:49 PM.
              Patrick H.NinjaTrader Customer Service

              Comment


                #8
                Hello pstrusi,

                Thank you for your patience.

                I cannot reproduce the behavior you detail with the code below. Can you detail the order type and how you are checking the Partial Fill?

                Code:
                        protected override void OnBarUpdate()
                        {
                            if (Historical) return;
                
                            if (entry == null)
                                entry = SubmitOrder(0, OrderAction.Buy, OrderType.Limit, 100, Close[0] - (4 * TickSize), 0, "", "entry");
                        }
                
                        protected override void OnOrderUpdate(IOrder o)
                        {
                            if (entry != null && o == entry)
                            {
                                if (o.OrderState == OrderState.PartFilled)
                                    ChangeOrder(entry, o.Quantity, Close[0] - (2 * TickSize), 0);
                            }
                        }
                I look forward to your response.
                Patrick H.NinjaTrader Customer Service

                Comment


                  #9
                  The order type is a simple limit order.

                  1. Try to submit the original order with only 2 contracts, then after partial filled of 1, simulate that the remaining order continues to work at the exchange, after a minute, market moved and the strategy needs to change the buy price upward, so apply the command.

                  2. I check the partial fill like you in the code ( below ). But if you mean "manual check", obviously in the log.

                  if (setlong != null && setlong == order)
                  {
                  .......................
                  else if ( order.OrderState == OrderState.PartFilled )
                  {
                  // executes code accordingly
                  }
                  }


                  What it's interesting is you use " o.Quantity " like remaining order quantity. Since it's not an often sample I forgot that ability since I'm not a pro-IT person.

                  Let me try it. Thanks for your attention and help


                  Comment


                    #10
                    Patrick,

                    Is that possible to change the order within OnBarUpdate method only, but using some equivalent variable to o.Quantity ? Imagine the case where you must change ONLY if certain price is reached.

                    Looking forward

                    Comment


                      #11
                      Hello pstrusi,

                      Thank you for your response.

                      If you are using IOrder objects then you can pull their properties in OnBarUpdate. I would recommend verifying the order is an a state that the values are valid for though.

                      Please let me know if you have any questions.
                      Patrick H.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks for confirming it, Patrick

                        Regards and merry christmas

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by JohnAymin, Today, 02:38 PM
                        0 responses
                        3 views
                        0 likes
                        Last Post JohnAymin  
                        Started by Rmos22, Today, 02:20 PM
                        1 response
                        10 views
                        0 likes
                        Last Post NinjaTrader_Spencer  
                        Started by sawtooth500, Today, 12:59 PM
                        1 response
                        4 views
                        0 likes
                        Last Post NinjaTrader_Spencer  
                        Started by Steve L, Yesterday, 09:36 PM
                        1 response
                        20 views
                        0 likes
                        Last Post NinjaTrader_Kate  
                        Started by MichaelAlexander, 04-25-2017, 03:28 AM
                        9 responses
                        1,171 views
                        0 likes
                        Last Post dani neira  
                        Working...
                        X