• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 mohdhm, Today, 04:09 PM
            0 responses
            1 view
            0 likes
            Last Post mohdhm
            by mohdhm
             
            Started by BGWTEX, Today, 03:30 PM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by marekflys, Today, 03:07 PM
            0 responses
            5 views
            0 likes
            Last Post marekflys  
            Started by GregoryBaskin, Today, 02:51 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_Tyler  
            Started by swcooke, Today, 12:33 PM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X