Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position.Quantity doesn't work on fdax

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

    Position.Quantity doesn't work on fdax

    Hi, i have a problem with unmanaged order in nt8.
    When the strategy submit the first entry order on the fdax market, it place two stop loss and two target, despite the quantity is equal to "Position.Quantity".
    I have this problem only on Fdax on the first trade, in the other trade on fdax it work's in the right way. I try the same situation on the YM but, the sme strategy doesn't do the problem.

    I try to re-install the NT8 but it was fails to solve.

    I attach some screen on the output and the view of the chart.
    Attached Files

    #2
    Hello bergimax,

    Thank you for your post.

    I am able to reproduce the same behavior on the FDAX on my end. I will look into this further and report to development.

    Comment


      #3
      Thank's for the replay PatrickH. I continue the test on other market, and when i try FESX i had the same scenario like FDAX. I change the import value from EURO to US DOLLAR ( tools--> instrument ) and, after this change, i never had the problem. Can be EURO Currency the problem?

      Thank's!
      Last edited by bergimax; 11-17-2016, 05:02 PM.

      Comment


        #4
        Potentially that could be the item. Thank you for the additional information.

        Comment


          #5
          Hello bergimax,

          Thank you for your patience.

          I am unable to consistently get this to occur on the first trade. May we test your strategy on our end?
          You can send the strategy to platformsupport[at]ninjatrader[dot]com with 'ATTN: Patrick H' in the subject and this thread in the body of the email.

          Comment


            #6
            Hello bergimax,

            Thank you for your patience.

            Please set your entry order objects in the OnOrderUpdate method rather than in the OnBarUpdate method.

            For example:
            Code:
            protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, stringnativeError)
            {
            
              // Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected.
              // This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not guaranteed to be complete if it is referenced immediately        after submitting
            
              if (order.Name == "myEntryOrder")
                  entryOrder = order;
             
              if (entryOrder != null && entryOrder == order)
              {
                  Print(order.ToString());
                  if (order.OrderState == OrderState.Filled)
                      entryOrder = null;
              }
            }
            More information: http://ninjatrader.com/support/helpG...n-us/order.htm

            In any market where the movement could be quicker than the order update events (technically any market could do this) you would need to ensure to implement the concept above rather than using the OnBarUpdate method to assign the order objects.

            Comment


              #7
              Please, explain why this approach more reliable?

              After submitting order in OnBarUpdate() and before assigning order in OnOrderUpdate() strategy have non-controlled order without any reference.

              1. In another word, at this time interval strategy have no informations, that order was submitted?
              Subjectively it looks very dangerous.

              2. And does it mean requirement to use signals names always?

              3. What will contain entryOrder if "market where the movement could be quicker than the order update events" happens?

              4. Isn't it better to use combined approach:
              PHP Code:
              OnBarUpdate()
              {
                  
              entryOrder EnterLong"myEntryOrder" );
              }

              protected 
              override void OnOrderUpdate()
              {
                if (
              order.Name == "myEntryOrder")  entryOrder order;

              Last edited by fx.practic; 08-13-2017, 11:48 AM.
              fx.practic
              NinjaTrader Ecosystem Vendor - fx.practic

              Comment


                #8
                Hello fx.practic,

                Thank you for your post.

                Assigning the order object in the function that is called upon order update is more efficient as this is the event that occurs when the order is actually made. The order is not made in the OnBarUpdate() function, the call to the method to submit the order can be made (EnterLong, SetStopLoss, etc.) but the order events are not processed in OnBarUpdate().

                OnOrderUpdate() is called in all order events, this includes when the order is submitted, accepted, working, etc. Due to the multi-threaded nature of NinjaTrader 8 there is the possibility that OnBarUpdate() could be called again before the order event processes and therefore calling any properties of the Order object would be invalid. Now that is just one example though.

                Your questions:
                1. I am not sure what you mean here. The OnOrderUpdate() event only updates on the order events. You should not rely on OnBarUpdate() for order events.
                2. Signal names are generally used to name the order for not only reference in other order methods (such as SetStopLoss) but you can also clearly see the name in reports such as the Orders tab of the Control Center.
                3. This would be handled by OnOrderUpdate(). Events do not occur at all times in the sequence you want. Bar updates (ticks) could occur before an order updates that was submitted several ticks ago.
                4. No, this would not be better. As stated above the OnBarUpdate() function is not called on order events.


                Please let me know if you have any questions.

                Comment


                  #9
                  Once more question, please.

                  For example, on previous bar strategy send order.
                  OnOrderUpdate() method wasn't triggered.
                  Next (current) bar came.
                  Are there any evidences, that on previous bar order was sent?
                  Or, I have to create additional bool variable to know whether order was sent, or it wasn't?
                  fx.practic
                  NinjaTrader Ecosystem Vendor - fx.practic

                  Comment


                    #10
                    Hello fx.practic,

                    Thank you for your response.

                    OnOrderUpdate() would not trigger immediately on the call of the order submission method. If you need a means to determine the order submission method was called then your bool or a Print() call will suffice.

                    Please let me know if you have any questions.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by love2code2trade, Yesterday, 01:45 PM
                    4 responses
                    28 views
                    0 likes
                    Last Post love2code2trade  
                    Started by funk10101, Today, 09:43 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post funk10101  
                    Started by pkefal, 04-11-2024, 07:39 AM
                    11 responses
                    37 views
                    0 likes
                    Last Post jeronymite  
                    Started by bill2023, Yesterday, 08:51 AM
                    8 responses
                    44 views
                    0 likes
                    Last Post bill2023  
                    Started by yertle, Today, 08:38 AM
                    6 responses
                    26 views
                    0 likes
                    Last Post ryjoga
                    by ryjoga
                     
                    Working...
                    X