Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLong -- auto reverse position - quantity too high for broker

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

    EnterLong -- auto reverse position - quantity too high for broker

    I have an automated trading strategy that works great, but I doubled my contracts traded from 1 to 2 and now have issues. When the Strategy in Tab 1 performs: EnterLong(DefaultQuantity, @"LONG1"); it automatically reverses my short position and creates a long position with 2 contracts. The issue is it sends in a 4 contract BUY order (Close 2 short and Enter 2 long) which exceeds my margin limits at Interactive Brokers, so the whole transaction gets cancelled and I don't get reversed. Is there a way to have it do the order in two pieces so I don't exceed my maximum margin on the reversal?

    #2
    Hello Thalamusless,

    Thanks for your post and welcome to the NinjaTrader forums!

    You would need to separate your strategy logic by having a set that would close the position in advance of entering a new position. Then in your first set, you would check to make sure that your position is flat first before entering long. In the strategy builder, this can be found under the strategy folder (Market Position).
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Ok thanks, that makes sense.

      Comment


        #4
        I did as you described, separating the strategy into two sets, with one checking to see if the order state is "flat," and it didn't work. Using On Bar update the order state isn't checked again until the next bar, so if the 1st set closes the order, the 2nd set doesn't know the order state is "flat" so it executes as well, creating a doubled position going the other direction. I'm thinking this is beyond the out of the box order handling abilities of NT, and would require programming? Unless you have a simple solution, I've decided to use the margin limitations of my broker, which will solve the problem, and avoid the complexity of fixing this issue with programming the order handling manually.

        Comment


          #5
          Hello Thalamusless,

          Thanks for your reply.

          Something doesn't sound right. If you are checking for the market position to be flat and it is not flat then the action part of that set would not execute.

          If you would like further assistance, please post your strategy source code file.

          Alternatively, if you would prefer not to review in public, please feel free to write into PlatformSupport[at]NinjaTrader[dot]Com. Mark the e-mail Atten:Paul and please include a link to this thread. Attach your source code file to the e-mail. The file can be found in Documents>NinjaTrader8>bin>Custom>Strategies> and will have a .CS file extension.
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Thanks Paul for your help.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by elderan, Yesterday, 08:03 PM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by samish18, Yesterday, 08:57 AM
            8 responses
            25 views
            0 likes
            Last Post samish18  
            Started by DJ888, 04-16-2024, 06:09 PM
            3 responses
            10 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by RookieTrader, Today, 07:41 AM
            0 responses
            3 views
            0 likes
            Last Post RookieTrader  
            Started by maybeimnotrader, Yesterday, 05:46 PM
            1 response
            19 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X