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.
      Josh G.NinjaTrader 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?
          Josh G.NinjaTrader 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.

              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.

                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.

                      Comment


                        #12
                        Thanks for confirming it, Patrick

                        Regards and merry christmas

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by judysamnt7, Today, 03:18 PM
                        0 responses
                        1 view
                        0 likes
                        Last Post judysamnt7  
                        Started by AgriTrdr, Today, 10:35 AM
                        4 responses
                        25 views
                        0 likes
                        Last Post AgriTrdr  
                        Started by kenz987, Today, 12:34 PM
                        2 responses
                        10 views
                        0 likes
                        Last Post kenz987
                        by kenz987
                         
                        Started by ChrisR, Yesterday, 12:04 PM
                        7 responses
                        31 views
                        0 likes
                        Last Post ChrisR
                        by ChrisR
                         
                        Started by markpk1, Today, 11:54 AM
                        5 responses
                        21 views
                        0 likes
                        Last Post NinjaTrader_Erick  
                        Working...
                        X