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

order getting rejected in unmanaged orders submission

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

    order getting rejected in unmanaged orders submission

    Hi, I am using unmanaged orders submission like oco for my strategy. many times it shows error that orders are rejected. I am using playback forex data to test the strategy. Please see the screenshot attached for better understanding. I have read articles in this forum regarding this, but I could not find a realistic solution or example to avoid this. Any suggestion will be very helpful and appreciated.
    Attached Files

    #2
    Hello asmmbillah,

    Thanks for your post.

    The last error message is advising that the Buy stop or Buy stop limit order that the strategy placed at 1.25807 was at an inappropriate price level relative to where the current price was. These orders must be placed above the current price.

    The strategy would need to check before placing these orders that the current price is less than the order price.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply. Can you please direct me to an example about what you meant?

      Comment


        #4
        Hello asmmbillah,

        Thanks for your reply.

        I am not aware of an example of this.

        The logic can be simply stated as:

        if the current price is less than your intended buystop then place the buystop order.
        else (this would be up to you to decide).


        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks for your note. I have added some logics and it works better for most, but still shows fewer errors like this screenshot. But if I press ok, it works fine. is it possible to no to show this error or any other advise how to avoid this error?
          Attached Files

          Comment


            #6
            Hello asmmbillah,

            Thanks for your reply.

            In your code you would need to check that your intended order price value is appropriately above or below the actual current price. What check are you currently doing now (post relevant code section) and what calculate mode are you running the strategy on?
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Hello asmmbillah,

              Thanks for your reply.

              What I recommend would be to debug with print statements just prior to your SubmitOrderUnmanaged() methods. You would want to print something like:

              Print (Time[0]+" Current price = "Close[0]"+ " Limit Entry price: "+(reEntryUpper + entryOffsetConversion.Tostring())+ " StopLimit price: "+reEntryUpper - entryOffsetConversion.TosTring());

              This should get you prints to your output window when you are submitting orders and when you have the error you can check to see what value was in error.

              In both your order methods show you are using SellShort, is that what you really mean for both sets?
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Thanks for your suggestion, I have added and tested that and found the below:

                16/07/2019 22:30:00 Current price = 1.24127 Limit Entry price: 1.24120.0005 StopLimit price: 1.2407

                where StopLimit is lower the the current price, but still shows the same error. Any advise?

                I have sent you the code for the short side only which includes both sets.

                Comment


                  #9
                  Hello asmmbillah,

                  Thanks for your reply.

                  It looks like the print statement needs to be adjusted to add the values together before converting to string:

                  Print (Time[0]+" Current price = "Close[0]"+ " Limit Entry price: "+(reEntryUpper + entryOffsetConversion).Tostring()+ " StopLimit price: "+(reEntryUpper - entryOffsetConversion).ToString());

                  If I am reading correctly you are submitting a sell limit at 1.24125 while the current price is 1.24127, so keep in mind that you have order transmission time (internet speed) and the actual price may be moving rapidly making your price submitted invalid. As a test, I would suggest that you increase your distance value from the current price and see if that eliminates reduces these errors.

                  Paul H.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks for your reply.

                    For some reason, I just tried replacing GetCurrentBid() with Close[0], that solved the error. Can you please tell me what will be the differece between GetCurrentBid() and Close[0] in terms of price?

                    Comment


                      #11
                      Hello asmmbillah,

                      Thanks for your reply.

                      If you look at a Forex instrument on the super dome, the yellow would be the current price (Close) (last) and the green would be the (GetCurrentAsk()) ask price and you may see them as being the same at times and at other times there being a spread where the ask is higher.
                      Last edited by NinjaTrader_PaulH; 02-25-2020, 08:38 AM. Reason: Corrected GetCurrentBid to GetCurrentAsk and changed references from bid to ask.
                      Paul H.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks for your reply, but still I am not clear. there is bid price which I can get by GetCurrentBid() and ask with GetCurrentAsk(), then what this Close[0] gives me? is it just the Current close of the live bar on the chart?

                        Comment


                          #13
                          Hello asmmbillah,

                          Thanks for your reply.

                          Sorry for any confusion. I see that in my reply I incorrectly stated that "on the super dome, the yellow would be the current price (Close) and the green would be the (GetCurrentBid()) bid price" I meant to say the GetCurrentAsk() is what is shown. I will edit my previous reply to reflect that correction.

                          When using the Calculate.OnPriceChange, the Close[0] would be the current (last) price which would be the current close price of the currently forming bar meaning it it the current price of the instrument. In the case of Forex, the last price will be filled at the Bid price. Another way to visualize this would be to add the indicator Price Line and enable (show) the bid and ask line of that indicator. Note that the "last" line is always on top of the "Bid Line" and occasionally on the "ask line".

                          Paul H.NinjaTrader Customer Service

                          Comment


                            #14
                            Thanks for your reply and clarification.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by warreng86, 11-10-2020, 02:04 PM
                            5 responses
                            1,356 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by Perr0Grande, Today, 08:16 PM
                            0 responses
                            3 views
                            0 likes
                            Last Post Perr0Grande  
                            Started by elderan, Today, 08:03 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post elderan
                            by elderan
                             
                            Started by algospoke, Today, 06:40 PM
                            0 responses
                            10 views
                            0 likes
                            Last Post algospoke  
                            Started by maybeimnotrader, Today, 05:46 PM
                            0 responses
                            12 views
                            0 likes
                            Last Post maybeimnotrader  
                            Working...
                            X