Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancelling open order(s).

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

    Cancelling open order(s).

    Can anyone tell me how to cancel an open order in a strategy that I want to backtest?

    I've just started using NT and the strategy wizard. I've scoured the documentation and the board and tried importing SampleHaltBasicStrategy from the Reference Samples section.

    Is it something that has to be done with the unlocked code?

    In the quick strategy that I wanted to try, I wanted the system to take a long if the there is a HH, HL condition between two bars with an entry 2 tics above the HL.

    It has worked great so far, but I can't find a way to cancel the order if it doesn't fill within the next 2 bars, or cancel if there is a LL before it is filled.

    Many thanks in advance,

    DK

    #2
    Hi 8DTK8,

    To manually cancel an order you will have to unlock the code, but in your case I don't think you need to. NinjaScript orders are always cancelled if they are not resubmitted on the next bar. This is automatic so if you don't want the order anymore just don't resubmit it.

    Create a condition that will only evaluate to true on one bar. If it is not filled on that bar it will automatically cancel on the next bar. To do this you can do something like create a variable that has a value of 1. Only trade if that value is 1. One of the action will be to set that variable to 0 along with EnterLong(). After you do that it will not resubmit again therefore not keeping your order alive.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Follow up question on submitting orders in different time frames.

      This is a follow up question.
      I read Josh's "Strategy: Entering on one time frame and exiting on another " in reference samples and tinkered around with it a bit in strategy analyzer, but I still can't figure out the answer.

      My question builds on Josh's response that I got below.

      If I am submitting orders to go long in the 15 min and stop in the 1 min that gets placed as long as the account position is long, should I see orders being submitted for the stop every 1 min?

      For example:
      Strategy fills long at 10:00am in the 15 bar like it's supposed to.
      Should I see stop orders every min. until a filled?
      I'm looking at the "orders" tab right now and that's not what I'm seeing.

      Thank you,

      DK


      Originally posted by NinjaTrader_Josh View Post
      Hi 8DTK8,

      To manually cancel an order you will have to unlock the code, but in your case I don't think you need to. NinjaScript orders are always cancelled if they are not resubmitted on the next bar. This is automatic so if you don't want the order anymore just don't resubmit it.

      Create a condition that will only evaluate to true on one bar. If it is not filled on that bar it will automatically cancel on the next bar. To do this you can do something like create a variable that has a value of 1. Only trade if that value is 1. One of the action will be to set that variable to 0 along with EnterLong(). After you do that it will not resubmit again therefore not keeping your order alive.

      Comment


        #4
        You will only see one stop order because your submission conditions will only evaluate once. If you want this order to persist you can use liveUntilCancelled set to true, otherwise you will need to work out some way to resubmit your stop order on every bar to keep it alive.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Clarification

          I get what you are saying and I am going to read up on advanced order handling. However, I'm trying to figure out whether or not the script is doing what it is supposed to do.

          Back to my example.
          If the long condition triggers in the 15 min (in array 1) at 10am and you can see it being filled in the order tab, shouldn't there be an order for the stop if the only condition for that order to exist is that the BarsInProgress == 1 min period type and the Position.MarketPosition == MarketPosition.Long?

          So the condition are BarsInProgress == 1 min and a long position, and the strategy just went long at 10am, shouldn't I see the following orders?

          Sell... Stop... Cancelled... 10:01am
          Sell... Stop... Cancelled... 10:02am
          Sell... Stop... Cancelled... 10:03am
          Sell... Stop... Cancelled... 10:04am

          Sell... Stop... Cancelled... 10:05am
          Sell... Stop... Cancelled... 10:06am
          Sell... Stop... Cancelled... 10:07am
          ...
          ..
          .
          until it is finally filled?

          Thanks again.





          Originally posted by NinjaTrader_Josh View Post
          You will only see one stop order because your submission conditions will only evaluate once. If you want this order to persist you can use liveUntilCancelled set to true, otherwise you will need to work out some way to resubmit your stop order on every bar to keep it alive.

          Comment


            #6
            No. You submit your order from the 15min time frame. The order is submitted to the 1min. If at the next one min bar the order is not kept alive or already filled it is cancelled and that is it. End of the order. Are you not seeing this behavior?

            This is why you should use liveUntilCancelled = true. You will not need to resubmit to have the order persist, but you will need to cancel it manually if you do not wish for it to continue any longer.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            597 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            343 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            556 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            555 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X