Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unintended removal of order...

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

    Unintended removal of order...

    Hello, I had a situation where I was running a long Ninjascript strategy and a short Ninjascript strategy. The long strategy performed perfectly, but, the long strategy was sold out (closed) at market (as intended) and the new short strategy was supposed to immediately trigger, much like a stop and reverse. However, for some reason the short was executed, but then immediately removed for no apparent reason. Below is a log of the sequence. It doesn't appear to be any type of brokerage rejection, rather, just some type of glitch. Can anyone see what might of happened? Obviously a situation I must fix ASAP! This hasn't happened the previous times this type of sequence took place. Any help would be awesome. Thanks!

    Here's the sequence:
    9/18/2020 8:45 Order Order='1552260442/7PQ2667' Name='Stop loss' New state='Cancelled' Instrument='ES 12-20' Action='Sell' Limit price=0 Stop price=3282.75 Quantity=1 Type='Stop Market' Time in force=DAY Oco='346121936141' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 8:45 Order Order='1552189772/7PQ2667' Name='Profit target' New state='Cancelled' Instrument='ES 12-20' Action='Sell' Limit price=3421.75 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='346121936141' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 8:45 Order Order='1552260442/7PQ2667' Name='Stop loss' New state='Cancel submitted' Instrument='ES 12-20' Action='Sell' Limit price=0 Stop price=3282.75 Quantity=1 Type='Stop Market' Time in force=DAY Oco='346121936141' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 8:45 Order Order='1552189772/7PQ2667' Name='Profit target' New state='Cancel submitted' Instrument='ES 12-20' Action='Sell' Limit price=3421.75 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='346121936141' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 8:45 Position Instrument='ES 12-20' Average price=0 Quantity=0 Market position=Short Operation=Remove ?????
    9/18/2020 8:45 Execution Execution='346151771405' Instrument='ES 12-20' Exchange=Globex Price=3347 Quantity=1 Market position=Short Operation=Operation_Add Order='1552289237' Time='9/18/2020 8:45 AM'
    9/18/2020 8:45 Order Order='1552289237/7PQ2667' Name='Sell' New state='Filled' Instrument='ES 12-20' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=DAY Oco='' Filled=1 Fill price=3347 Error='No error' Native error=''
    9/18/2020 8:45 Order Order='1552289237/7PQ2667' Name='Sell' New state='Working' Instrument='ES 12-20' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=DAY Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 8:45 Order Order='1552289237/7PQ2667' Name='Sell' New state='Accepted' Instrument='ES 12-20' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=DAY Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 8:45 Order Order='edae9804d2974e6e9c9170c107404d2c/7PQ2667' Name='Sell' New state='Submitted' Instrument='ES 12-20' Action='Sell' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=DAY Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 8:45 NinjaScript NinjaScript strategy '/176479240' submitting order
    9/18/2020 7:45 Order Order='1552189772/7PQ2667' Name='Profit target' New state='Working' Instrument='ES 12-20' Action='Sell' Limit price=3421.75 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='346121936141' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 7:45 Order Order='1552189772/7PQ2667' Name='Profit target' New state='Accepted' Instrument='ES 12-20' Action='Sell' Limit price=3421.75 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='346121936141' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 7:45 Order Order='1552260442/7PQ2667' Name='Stop loss' New state='Working' Instrument='ES 12-20' Action='Sell' Limit price=0 Stop price=3282.75 Quantity=1 Type='Stop Market' Time in force=DAY Oco='346121936141' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 7:45 Order Order='1552260442/7PQ2667' Name='Stop loss' New state='Accepted' Instrument='ES 12-20' Action='Sell' Limit price=0 Stop price=3282.75 Quantity=1 Type='Stop Market' Time in force=DAY Oco='346121936141' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 7:45 Position Instrument='ES 12-20' Average price=3357.25 Quantity=1 Market position=Long Operation=Operation_Add
    9/18/2020 7:45 Order Order='b1eb099ddac6499e9462d848693c5f0d/7PQ2667' Name='Profit target' New state='Submitted' Instrument='ES 12-20' Action='Sell' Limit price=3421.75 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='346121936141' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 7:45 Order Order='dee2d6a6ce8848c99f8bbbf1cb49d2c4/7PQ2667' Name='Stop loss' New state='Submitted' Instrument='ES 12-20' Action='Sell' Limit price=0 Stop price=3282.75 Quantity=1 Type='Stop Market' Time in force=DAY Oco='346121936141' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 7:45 NinjaScript NinjaScript strategy '/176479240' submitting order
    9/18/2020 7:45 NinjaScript NinjaScript strategy '/176479240' submitting order
    9/18/2020 7:45 Execution Execution='346121936141' Instrument='ES 12-20' Exchange=Globex Price=3357.25 Quantity=1 Market position=Long Operation=Operation_Add Order='1552226829' Time='9/18/2020 7:45 AM'
    9/18/2020 7:45 Order Order='1552226829/7PQ2667' Name='Buy' New state='Filled' Instrument='ES 12-20' Action='Buy' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=DAY Oco='' Filled=1 Fill price=3357.25 Error='No error' Native error=''
    9/18/2020 7:45 Order Order='1552226829/7PQ2667' Name='Buy' New state='Working' Instrument='ES 12-20' Action='Buy' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=DAY Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 7:45 Order Order='1552226829/7PQ2667' Name='Buy' New state='Accepted' Instrument='ES 12-20' Action='Buy' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=DAY Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 7:45 Order Order='71cb078613b1479da529c2d4b4002072/7PQ2667' Name='Buy' New state='Submitted' Instrument='ES 12-20' Action='Buy' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=DAY Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
    9/18/2020 7:45 NinjaScript NinjaScript strategy '/176479240' submitting order

    #2
    Hi bootize,
    To my understanding, this is not unintended behaviour.

    I'm happy to be corrected, but assume NinjaTrader recommendation is (still) to merge both strategies into one strategy and then to call an entry order in the opposite direction of the position without calling an exit method first, if a position shall be reversed on the same bar.
    NT-Roland


    Comment


      #3
      Hello NT-Roland, Thank you for the reply!

      So I merged the long and short strategies together. I then set criteria for exiting a position through a separate command for only when I am NOT getting a stop AND reverse signal. Otherwise, if I am already in a position at the time of a new and opposite trigger, I will automatically be exited from that original position and entered into the new and opposite position. Does that sound correct? I tested it in market replay and it seemed to work. But I just wanted to make sure I'm clear. Does this all sound correct?

      Also, when I view the code, the order triggers are in sets 1 - 6, then the stop orders are in sets 7 and 8. Does that chronology fulfill the requirement to call an entry orders before calling and exit method?

      Thanks!
      Last edited by bootize; 09-19-2020, 07:47 PM.

      Comment


        #4
        Hello bootize,

        As a heads up, do not call an entry and an exit on the same bar. If you are calling an entry, just call the entry and NinjaTrader will reverse the position. Calling an exit and an entry would result in doubling the position as it reverses or an overfill.


        Yes, combining the strategies into one strategy would be the recommended approach..


        If you are referring to condition sets with the strategy builder, these are evaluated independently and in order.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks Chelsea for the reply!

          The tricky part is that occasionally, I'll have an entry signal that happens to line up to the same time I have an exit signal from an already open and opposite position. So, for example, I'll be in a long position, then I'll get a [sell at market signal to close out and liquidate that long position] NOT from any already placed stop order. Then, every now and then, I'll simultaneously have a initiate short position signal at that same bar.

          If that scenario plays out like described above, should I, in the strategy builder, put in an argument to initiate the long liquidate signal only if I'm NOT in a short position? Or is there a better way to do this...

          Thanks Much!
          .

          Comment


            #6
            Hello bootize,

            In the strategy builder, the logic should be designed so that both can't happen. If the conditions for one are true for an exit, explicitly require those conditions to be false for the other condition set with an exit to be true.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by funk10101, Today, 09:43 PM
            0 responses
            3 views
            0 likes
            Last Post funk10101  
            Started by pkefal, 04-11-2024, 07:39 AM
            11 responses
            36 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
             
            Started by algospoke, Yesterday, 06:40 PM
            2 responses
            24 views
            0 likes
            Last Post algospoke  
            Working...
            X