Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to ensure both EnterLong() and EnterShort() hit?

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

    How to ensure both EnterLong() and EnterShort() hit?


    Hi there, how can I ensure both EnterLongLimit(Close[0]) and EnterShortLimit(Close]0\) simultaneously get a valid order, or none at all?

    I'm testing a strategy. Instead of just testing one side, I do both EnterLongLimit and EnterShortLimit, for say, 6 ticks gain/stop loss. One will gain, the other will loss. This way, I can test both sides, break out even, and only pay the commissions on the order. The problem I have is, it's not infrequent that only one side of the order hits.

    How can I get into both EnterLongLimit(Close[0]) and EnterShortLimit(Close]0\), or none at all? Thanks,





    Last edited by timmbbo; 03-14-2023, 10:51 PM.

    #2
    Hello, thanks for writing in. Submitting two orders in the opposite directions is not possible in the managed approach as it breaks the order handling rule:

    Methods that generate orders to enter a position will be ignored if:
    The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction


    You would need to use the unmanaged approach to submit a pair of orders that will go in opposite directions.

    Comment


      #3
      Beyond even that (needing unmanaged orders) the crux of your question is how to get both or none. That would require sending the orders as a combo together as all or none, and I don't think (NT please confirm) that NinjaTrader Brokerage supports this. If you're using another broker, you need to check with your broker if this is even supported. Some brokers do support it, but then the challenge will become how to submit it in the right format using unmanaged orders such that they're effectively all or none together.
      Bruce DeVault
      QuantKey Trading Vendor Services
      NinjaTrader Ecosystem Vendor - QuantKey

      Comment


        #4
        Hi, You can submit local OCO orders that run on your PC but the server side ATMs are not supported through strategy scripts. The SubmitOrderUnmanaged method has an OCO parameter where you can provide matching OCO strings.

        Comment


          #5
          This isn't an OCO, but rather it sounds like he wants to only get a fill on one limit order if they both get a fill. So, it's both filled or neither filled.
          Bruce DeVault
          QuantKey Trading Vendor Services
          NinjaTrader Ecosystem Vendor - QuantKey

          Comment


            #6
            Hi Bruce, You can not have a long and a short position on the same account at the same time. No brokerage will allow a "wash" trade where you try to hedge by placing two orders in opposite directions with two different accounts.

            Comment


              #7
              It would require a hedging rather than a netting account, and to the best of my awareness (but please confirm) NinjaTrader does not offer this account configuration.

              So, there are multiple problems here - besides being unable to link the two orders as a "fill all or none" - there is also the issue that if they were filled, he would be flat in a netting account, and as well, they can't both be tagged as entry orders though the exchange requires that they be tagged as entries or exits.

              In short, this just isn't happening, with managed or unmanaged orders.
              Bruce DeVault
              QuantKey Trading Vendor Services
              NinjaTrader Ecosystem Vendor - QuantKey

              Comment


                #8
                Originally posted by timmbbo View Post
                Hi there, how can I ensure both EnterLongLimit(Close[0]) and EnterShortLimit(Close]0\) simultaneously get a valid order, or none at all?

                I'm testing a strategy. Instead of just testing one side, I do both EnterLongLimit and EnterShortLimit, for say, 6 ticks gain/stop loss. One will gain, the other will loss. This way, I can test both sides, break out even, and only pay the commissions on the order. The problem I have is, it's not infrequent that only one side of the order hits.

                How can I get into both EnterLongLimit(Close[0]) and EnterShortLimit(Close]0\), or none at all? Thanks,
                sounds like a simple OCO order with limit..?
                you can use this project here it has OCO entry built in to it.


                see the yellow oco breakout button... it can also be programmatic
                and override the order type from stop loss to limit
                you can add rules to cancel if no fille after a period

                or if its not a limit oco - you can still use this to do things not possible with NT ATMS or managed strats check it out...

                but you are stumped as you cant be long and short the same instrument even on multiple accounts as its against rules

                HOWEVER
                you can though be long and short on different instruments for example

                10 MES and 1ES

                or 1 MES and 3 MYM etc you need to work out the lots




                Click image for larger version  Name:	image.png Views:	0 Size:	48.2 KB ID:	1240509

                Last edited by MicroTrends; 03-15-2023, 10:34 AM.
                MicroTrends
                NinjaTrader Ecosystem Vendor - micro-trends.co.uk

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, 03-13-2026, 05:17 AM
                0 responses
                86 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                151 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                79 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                52 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                59 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X