Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancel Order And Processing Strategies

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

    Cancel Order And Processing Strategies

    Dear Support,
    I note two problems (I think):
    - sometimes, when I reload my strategy, some Orders was sent with ID equal to NT-0001, NT-0002, ecc.. For these orders, CancelOrder method didn't work correctly.Why?
    - using more strategies and reload after a disconnection Ninja process for entire period (for example from 8:00 to 16:00) the first strategy, after process for entire period second strategy,..and finally process last strategy for entire period. But in real time each strategy will be process at the same time. For our, this behaviour is a problem because each strategy must know wich is the status of another strategy (for do this we are using windows registry and api to write the status). What can we do?
    Thanks

    Sincerely, Walter

    #2
    I assume these questions are related to NinjaScript?

    - CancelOrder() method will work if you pass in an IOrder object for the order you wish to cancel

    - If you mean that you run three strategies and each strategy needs to know information about each other in order to make decisions but at the time you run the first strategy, the second strategy is not yet running...Then I am not sure what you can do other than code your strategies in a manner where they are not reliant on each other at start up. Another option could be to code all three strategies in one strategy.
    RayNinjaTrader Customer Service

    Comment


      #3
      >I assume these questions are related to NinjaScript?

      Yes correct (sorry).

      >- CancelOrder() method will work if you pass in an IOrder object for the order you wish to cancel

      Yes, I set IOrder object in variable and I pass this variable to CancelOrder.

      > If you mean that you run three strategies and each strategy needs to know information about each other in order to make decisions but at the time you run the first strategy, the second strategy is not yet running...Then I am not sure what you can do other than code your strategies in a manner where they are not reliant on each other at start up. Another option could be to code all three strategies in one strategy.

      I was obliged to divide my strategy, one for long operation and another one for short operations, this because Ninja reject me the Limitorder or stoporder if I would enter in opposite position. So the solution with only one strategy is not possible. For example I have 3 running strategy that work fine in real time because, every OnBarUpdate Ninja runs :
      1° strategy 11.00 AM
      2° strategy 11.00 AM
      3° strategy 11.00 AM

      but when we have a disconnection Ninja reload running strategy in this mode (5 minute bars):
      1° strategy 9.00 AM
      1° strategy 9.05 AM
      1° strategy 9.10 AM
      ......
      1° strategy 11.00 AM
      2° strategy 9.00 AM
      2° strategy 9.05 AM
      2° strategy 9.10 AM
      ......
      2° strategy 11.00 AM
      3° strategy 9.00 AM
      3° strategy 9.05 AM
      3° strategy 9.10 AM
      ......
      3° strategy 11.00 AM

      For my opinion, the correct way is

      1° strategy 9.00 AM
      2° strategy 9.00 AM
      3° strategy 9.00 AM
      1° strategy 9.05 AM
      2° strategy 9.05 AM
      3° strategy 9.05 AM
      ......
      1° strategy 11.00 AM
      2° strategy 11.00 AM
      3° strategy 11.00 AM



      Thank you

      Comment


        #4
        Can you provide us with the error you are receiving with CancelOrder()?
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Dear Josh,
          thank you for your answer..

          >Can you provide us with the error you are receiving with CancelOrder()?

          I try to explain our strategies. We have 10 TS that work fine in real time, after a signal (bars on close true) we send two orders, one stop and one limit close to market value (but not very close). When one order will be in filled state, we cancel immediately the opposite order. After a disconnection, when we reload a strategies and ts analysed old bars, sometimes both orders went in filled status.
          We check trace output (strategies write all operation in txt file and Access mdb) and cancel orders was called property. We don't received a error. For your experience, which is the problem? Using OCO behaviour, maybe we can solve this problem? If yes, where can I found examples or docs to explain me OCO property?

          Can you please answer me to second question?

          Sincerely
          Walter

          Comment


            #6
            You can try using SetProfitTarget() and SetStopLoss(). They automatically generate OCO orders and you don't need to worry about managing the cancelling of the other order.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              >You can try using SetProfitTarget() and SetStopLoss(). They automatically generate OCO orders and you don't need to worry about managing the cancelling of the other order.

              If I am flat and I would send two orders to enter position, one order is limit (market value + 5 ticks) and one order is stop (market value - 5 ticks); when one of them go in position, other must be cancelled. Is it possibile to do this with SetProfitTarget() and SetStopLoss()?

              Thank you

              Comment


                #8
                I misunderstood what you were trying to do. You cannot use Set() methods to achieve what you want. You can just use the IOrders along with CancelOrder() to achieve what you want OR you can submit limit and stop orders without using the liveUntilCancelled option. If you do that you will need to resubmit the orders at every new bar or else your orders will automatically cancel. When one of them fills just stop resubmitting the other order and it will automatically cancel out.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  >I misunderstood what you were trying to do. You cannot use Set() methods to achieve what you want. You can just use the IOrders along with CancelOrder() to achieve what you want OR you can submit limit and stop orders without using the liveUntilCancelled option. If you do that you will need to resubmit the orders at every new bar or else your orders will automatically cancel. When one of them fills just stop resubmitting the other order and it will automatically cancel out.

                  OK, now I use IOrders (liveUntilCancelled is true) with CancelOrder().
                  In real time is ok, when processing historical bars after a disconection cancel order sometimes doesn't work..I observe that when order will be sent and Ninja generate ID equal to 'NT-0001' is not possible delete the order with CancelOrder(), if Ninja generate a GUID (for example '321qw654das321') CancelOrder work correctly. Which is the difference between an Order with ID=NT-0001 and an order with ID=random number?

                  Comment


                    #10
                    There should be no difference. I don't know why you can't cancel the orders. You will need to provide code samples along with TraceOrders output reports to try and debug it.

                    Also please take note that historical behavior will never match real-time behavior. http://www.ninjatrader-support.com/H...sBacktest.html
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      >There should be no difference. I don't know why you can't cancel the orders. You will need to provide code samples along with TraceOrders output reports to try and debug it.

                      Hallo Josh,
                      we understanded difference between Backtest and Real time.
                      After test strategies and monitoring traceorder, I note that the problem (Ninja doesn't cancel order) is always the first time that we running strategy, after it work correctly.
                      We explain operation, start Ninja, connect market replay (27/02/2008), in the chart we load strategy, after press ok, for some day CancelOrder didn't work. If we move slidebar time or reload strategy CancelOrder work fine. We have a document that show you this behaviour, but I can't enclosed it, how can I sent you this doc?
                      This is a very problem for our because in the morning/afternoon we use a pc, but in the evening we use another laptop, so, after connection, all strategies will go a market with 2 contract.
                      Best

                      Comment


                        #12
                        Please send it to [josh] at (ninjatrader) dot com.
                        RayNinjaTrader 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