Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to exit a position if strategy is not in sync

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

    How to exit a position if strategy is not in sync

    Hi,
    I have an urgent problem where my strategy is not in sync with my IB account and my exits are not working. The ExitLong() is not performing anything assumingly due to the fact that the strategy position.quantity = 0.
    I am not able to use Syncronise account or Adopt Account Position settings since those would wreck other functionality in the strategy.

    I would appreciate prompt reply! Thanks.

    #2
    Critical: Please contact your brokers Orders Desk immediately so that you may manage your live orders and positions.

    I would highly suggest contacting your order desk before continuing with NinjaTrader Support. This forum is for technical assistance only.

    You should be able to use any of the manual order entry buttons in any order entry window to place an order which would flatten your position. For example, if you're in a 1 short position, a 1 long market order would flatten your position. Make sure that the appropriate instrument and account is selected before placing this order.
    Last edited by NinjaTrader_PatrickG; 03-21-2018, 02:53 PM.

    Comment


      #3
      Thanks Patrick. Manual order are probably working fine and luckily we are not talking about huge losses here. I just need to get this working on the strategy level. Is there any way to exit a position other than syncing the strategies?

      Comment


        #4
        Hello,

        Thank you for the reply.

        First I wanted to check, what is the reason that the strategy is not currently in sync with the IB account?

        Was this due to the strategies start behavior/sync settings? Or is this caused by other reasons such as placing external trades in TWS or having multiple strategies running on the same instrument/account?

        If the strategy is not in sync with the position of the account, you would likely be unable to exit based on Strategy Position based conditions. Strategy and Account positions are seperate so this can certainly occur depending on the reason for the sync being off. If you can provide more detail on the reason for the strategy being out of sync, it would be more clear what the solution will be.

        In the case you are using multiple strategies on the same instrument/account you may instead need to use the PositionAccount object instead of Position: https://ninjatrader.com/support/help...ositionAccount


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse,
          the situation where strategy and account are not in sync has been created due to the fact that strategies have been restarted while there are open positions. I have around 70 strategies where the same strategy is running for multiple instruments. Ninjatrader seems to freeze itself approximately once a week and I have no other option than to restart it. Since I have positions that need to be held over this kind of situations, if I have understood correctly, the only way that the strategies are handling this situation correctly and not exiting my open positions at startup is to use Immeadiately Submit or Adopt Account Situation. I tried the Adopt Account Position - setting and it worked for the first strategy I enabled and the strat.position was updated with the account position accordingly and sync was set to true. However when I enabled other strategies I got the error that it needs to be the only strategy having that instrument in the account when using Adopt Account Position startup parameter.
          I am able to see the Account positions in the strategy with Account.Position function. So I can get quantity, average price and market position through that. I would like to get the execution date also but as I have read from the manual it is not supported at the moment.

          I am prepared to use Patrick´s guidance and replace the ExitLong with EnterShort(Account.Positions Quantity) if there are no other ways to solve this.

          Thanks.

          Comment


            #6
            Hello,

            Thank you for the reply and details.

            Yes if the strategy has to be restarted that would certainly be a case where it can become out of sync depending on what needs to be done to get back in sync. This is also compounded when using more than one strategy on the same instrument as your options become limited due to the nature of how strategies work in a virtual environment.

            As you noted you would be unable to use adopt account position because you have more than one strategy per instrument. In the situation where adopt account position allows your logic for the first strategy to work correctly, I would likely suggest combining the multiple strategies that go on a single instrument into one main strategy so you can use that option. We often recommend against using more than one strategy per instrument as your options become limited for syncing/account performance and it can become very complicated in terms of startup.

            I may also suggest to also take another approach at this as you are programming around the main problem at this point. If the platform is having to be restarted weekly, we would likely want to address that before anything else. As you noted you are running a lot of strategies and what I can assume also include some indicators. I likely could suggest reducing the overall load to see if this aids in the restarting, if not we would likely want to collect more details around the time you have to restart to better understand why that may be happening. If you dont have to restart, the strategies won't need to sync and you wouldn't need to program around the problem, so that may be a more beneficial way to approach this. If you have the time to further review the restart situation we could go over that as well.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hi Jesse,
              well I had to restart NT just now since the IB connection had died and did not start again when I tried to connect to it in NT. I will send you the logs & trace files.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CortexZenUSA, Today, 12:53 AM
              0 responses
              2 views
              0 likes
              Last Post CortexZenUSA  
              Started by CortexZenUSA, Today, 12:46 AM
              0 responses
              1 view
              0 likes
              Last Post CortexZenUSA  
              Started by usazencortex, Today, 12:43 AM
              0 responses
              5 views
              0 likes
              Last Post usazencortex  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              168 responses
              2,266 views
              0 likes
              Last Post sidlercom80  
              Started by Barry Milan, Yesterday, 10:35 PM
              3 responses
              13 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X