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

My limit order gets cancelled immediately

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

    My limit order gets cancelled immediately

    I have placed my limit order thru a strategy. It often went thru as expected. But today something weird happened where it got cancelled automatically.

    I have attached the printscreen of the log.

    There is no other strategy running with the same name, nor was there any open positions that could possibly cause a margin violation. When I turned it off and on again, the strategy indicated that a position should be in place and the coupled stop-loss order got submitted. I'm using 1-tick dataserie, and the start behavior is "immediately submit". Thanks.

    #2
    Hello qjl88,

    Thank you for your post.

    The default behavior for NinjaTrader is to cancel limit orders if the trigger conditions are no longer true. If you wish for your limit order to stay active once the conditions for entry are no longer true, you can explicitly set your orders to stay active until either filled or cancelled. Here's a link to our help guide that goes over how to keep your limit orders alive:



    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Click image for larger version

Name:	mnq.png
Views:	574
Size:	77.1 KB
ID:	1099268 Hi Kate,

      Thank you for your answer. If this is indeed the case, then I would have been very lucky 9 out 10 times so I'm wondering if there is another reason for it. Is it also possible that if the actual price is lower than my long limit order price, then the system would regard this as an invalid input price? I'm not noticing any errors from the log though.

      Comment


        #4
        Hello qjl88,

        Thank you for your reply.

        If you're not sure why a particular order is or is not being filled or if something's being cancelled that you don't think should, the first thing I would recommend would be to turn on the Order Trace function:

        Strategy Builder > Default Properties > More Properties > Trace Orders, or:

        if (State == State.SetDefaults)
        {
        TraceOrders = true;
        }

        Once you then recompile the strategy, you can open a new NinjaScript Output window under New > NinjaScript Output. This will print a log of any orders submitted by the strategy during while it's running, along with any ignored orders. You can then look through and see what may be occurring.

        Here is a link to our help guide that goes into more detail on tracing orders:



        Trace orders alone may not give you the full picture of whether or not a trade should have been entered or cancelled on a given bar, so adding prints to your strategy that will show in the NinjaScript Output window, with information on what the variables you're using for your conditions are on a particular bar, can be helpful.

        This forum post goes into great detail on how to use prints to help figure out where issues may stem from — this should get you going in the correct direction. You can even add these using the Strategy Builder.



        If you run into issues like we saw here, the above information will allow you to print out all values used in the condition in question that may be evaluating differently. With the printout information you can assess why your limit order may be getting cancelled.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Is there a way to solve this from within the strategy builder? I don't work in code yet...

          Comment


            #6
            Hello Gimbalto,

            Thank you for your reply.

            Yes, both Trace Orders may be turned on and prints may be added within the Strategy Builder:

            Strategy Builder > Default Properties > More Properties > Trace Orders
            This forum post goes into great detail on how to use prints to help figure out where issues may stem from — this should get you going in the correct direction. You can even add these using the Strategy Builder.

            https://ninjatrader.com/support/foru...ns-not-working
            A video specifically on adding prints with the Strategy Builder is available at the above link as well.

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              What about isliveUntilCancelled instructions?

              Comment


                #8
                Hello Gimbalto,

                Thank you for your reply.

                It would not be possible to submit a limit order using IsLiveUntilCancelled from the Strategy Builder - you would have to unlock your code for this as CancelOrder() is not available to the Strategy Builder.

                Please let us know if we may be of further assistance to you.
                Kate W.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jclose, Today, 09:37 PM
                0 responses
                4 views
                0 likes
                Last Post jclose
                by jclose
                 
                Started by WeyldFalcon, 08-07-2020, 06:13 AM
                10 responses
                1,413 views
                0 likes
                Last Post Traderontheroad  
                Started by firefoxforum12, Today, 08:53 PM
                0 responses
                10 views
                0 likes
                Last Post firefoxforum12  
                Started by stafe, Today, 08:34 PM
                0 responses
                10 views
                0 likes
                Last Post stafe
                by stafe
                 
                Started by sastrades, 01-31-2024, 10:19 PM
                11 responses
                169 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X