Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy no longer reflects open positions after Restart

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

    Strategy no longer reflects open positions after Restart

    Hi, I am having a problem with maintaining positions left open at the end of the week.

    I trade FX markets using automated strategies, and hence leave my server computer on 5.5 days a week. At the end of the week, I need to carry out a server reboot and switch off the server for a while to give it a rest.

    However, when I switch on the computer, launch Ninjatrader and reactivate the strategies, they don't seem to pick up the open positions which were reflected at the close of the trading week before switching off the server. These positions aren't reflected under the "Strategies" tab although they clearly are reflected under the "Positions" tab.

    Can anyone enlighten me on how I can get my strategies to reflect the old positions which they opened and pick up where they left off? Thanks!
    Last edited by skyholder84; 12-27-2010, 09:43 AM.

    #2
    Hello Skyholder,

    The positions will be generated based on the strategy when ran against historical data.. How the strategy behaves then depends on your strategy settings under tools > Options > Strategies > NinjaScript, as well as your account syncing options. You can see the various combinations detailed here.

    http://www.ninjatrader.com/support/h..._positions.htm
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,

      My problem is a different one. I have thoroughly read through the position reconciliation section of the guide, and have taken careful steps to avoid out-of-sync situations. I should not be having syncing problems, since:

      1) I start Ninjatrader before the start of the FX trading week.

      2) I set "Sync" to false

      3) I choose "Wait until live before submitting live orders"

      4) I do not do any manual trading. My systems do all the trading on my account.

      As such, when I restart Ninjatrader after a server reboot, the strategies should recognize the positions they had generated before the server restart.

      My problem lies in the fact that my strategies leave open positions over the weekend (exit on close = false). These positions were generated by these strategies, and should have been reflected on the strategies page when I restarted Ninjatrader before the start of the new trading week. This is explicitly stated in the help page. They could not have been closed out by the strategies during the server reboot since I restart my server only on weekends, and and prices don't move on weekends.

      According to the guide:

      "Any active orders you may have had on your account prior to strategy start that was not generated by your strategy would not have been cancelled on start and can lead to your Account Position being out of sync from your Strategy Position."

      This implies that a strategy should pick up open orders which it generated during a previous trading session. However, I'm discovering that this is not the case. After a restart, my strategies start the week reflecting a flat position on the "strategies" page despite having left open positions from the week before. This should not be happening.


      Thanks!
      Last edited by skyholder84; 12-27-2010, 10:33 AM.

      Comment


        #4
        3) I choose "Wait until live before submitting live orders"
        The strategies may recognize your positions, but will not submit any orders until you reach a flat state. With this setting, you are manually managing the strategies prior positions, and the strategy will submit new entry orders only once it reaches a flat state.

        Your strategy is likely highlighted in yellow, which indicates "waiting for a flat state" rather than showing the strategy position. This is a change in version 7 from the 6.5
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          To summarize, I would like to give an example.

          Ideally

          My algorithm opens a trade on Thursday, and the position is left open over the weekend. The algorithmic logic required to exit the trade have not been fulfilled (ie: might be fulfilled only the following Tuesday). As such, when I restart my server on Saturday and re-launch Ninjatrader, the strategies page should show my existing position, and continue to reflect P&L changes in my position all the way until the trade flattens out on Tuesday.

          Now

          After the server reboot, I relaunch Ninjatrader and the strategies tab shows that I'm flat in all my strategies, while the positions tab continues to reflect the open positions generated by the strategies.

          Please note that the strategy could not have closed out these positions over the weekend while the server was being rebooted, since prices do not move and the conditions for trade exit would not be met.

          Thanks!

          Comment


            #6
            Originally posted by NinjaTrader_RyanM View Post
            The strategies may recognize your positions, but will not submit any orders until you reach a flat state. With this setting, you are manually managing the strategies prior positions, and the strategy will submit new entry orders only once it reaches a flat state.

            Your strategy is likely highlighted in yellow, which indicates "waiting for a flat state" rather than showing the strategy position. This is a change in version 7 from the 6.5
            So if I select "wait until flat before submitting live", I am actually choosing to manually manage prior positions opened by my strategy during the previous week?

            And this would mean that my strategy's exit conditions would not take me out of the previous week's trade since it's not submitting any orders until flat?

            How then can I instruct the strategy to pick up where it left off during the previous week? If I select "immediately submit live working historical orders", I'll be doubling my position wouldn't I? Or is this the correct setting to choose in my case?

            Comment


              #7
              Hi Ryan, from your guidance, it appears that "immediately submit live working historical orders" is the proper setting to choose in my case, where I seek to re-connect my strategy with positions opened in a prior trading session. Am I right?

              If this is correct, my next question is this: If I choose "immediately submit live working historical orders", how far back does my Ninjatrader look back to determine if my strategy is in an open position?

              One problem I foresee is this: My strategy keeps positions open for 15 days on average. If I choose "immediately submit live working historical orders", my strategy has to look back at more than 15 days worth of minute-by-minute data to determine if there is a historical live trade ongoing.

              Illustration:

              My strategy opens a position on the Friday of Week 1 and lasts all the way into Week 3. At the start of week 3, if Ninjatrader looks back only 5 days to determine if the strategy has opened a position, it will fail to detect the trade which it made in week 1 (and appear flat). Only if Ninjatrader looks back to Week 1 historical data will it detect that the conditions for entry were met, and a trade was entered.

              Could you confirm that my assumption is correct?

              Comment


                #8
                So if I select "wait until flat before submitting live", I am actually choosing to manually manage prior positions opened by my strategy during the previous week?

                And this would mean that my strategy's exit conditions would not take me out of the previous week's trade since it's not submitting any orders until flat?
                Yes, that's correct. With these settings you're telling it not to manage any prior positions opened by the strategy.

                How then can I instruct the strategy to pick up where it left off during the previous week? If I select "immediately submit live working historical orders", I'll be doubling my position wouldn't I? Or is this the correct setting to choose in my case?
                It won't submit double entry orders. It will submit your exit orders if the signals returns true for these orders. This all assumes the strategy position matches with the account position. This may not be the case if the data changed or if the strategy options don't match exactly.

                You have to weigh the convenience of strategy managed exits with expected consistency of the historical strategy run matching with a prior real time run.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Ryan,

                  Thanks for your enlightening explanation. I'm getting the main gist of what you mentioned.

                  So in my instance, where:

                  1) I use strategy managed exits
                  2) I run NT throughout the entire period of the weekly FX trading session (to avoid failing to place live trades)
                  3) And hold trades for an average of 15 days,

                  The settings I need to choose are:

                  1) "immediately submit live working historical orders"

                  2) When setting Maximum Bars Lookback, I should choose "Infinite". This eliminates the risk that my strategy would fail to link up with an open position generated 3 weeks back.

                  Conversely, if I were to wrongly pick 256 bars, the strategy would only look back 256 primary bars to determine (based on historical data) if my strategy has traded. Given that I use 1 minute Primary Bars, Ninjatrader is practically guaranteed to fail to identify trades placed during the prior week (making the 256 primary bars option a HUGE mistake). Is my understanding on this correct?

                  3) The final risk I would have to manage would be bad initial data provided by my data provider, which is cleaned up over the weekend. This might lead to situations where (i) the conditions for entry were met at the time the trade was entered, and the account position is now Long/Short (ii) but due to the data corrections over the weekend, Ninjatrader's relies on the corrected historical data after my reboot, with the result that the conditions for trade entry are not met, and the strategy appears flat despite having entered a trade the week before.

                  Is my understanding of the settings and risks involved correct? Thanks for your patience!

                  Comment


                    #10
                    MaximumBarsLookBack shouldn't affect this.The strategy is run on all historical bars that are available regardless of this setting. It only applies to indicator calculations so results should be the same as long as indicators can be calculated with fewer than 256 bars.

                    Correct - different real time data compared to historical data can contribute to positions out of sync.

                    Data values, the amount of data, and strategy settings will factor in generating your strategy position. Days to load is available either on a chart through the right click > data series screen or with the days to load field when you run strategies from control center. Keeping these consistent from a prior strategy run to a new one should help align the strategy position with the account position.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_RyanM View Post

                      Data values, the amount of data, and strategy settings will factor in generating your strategy position. Days to load is available either on a chart through the right click > data series screen or with the days to load field when you run strategies from control center. Keeping these consistent from a prior strategy run to a new one should help align the strategy position with the account position.
                      Hi, just one final clarification about the part in bold. From my understanding of what you have explained, it appears that I should not be keeping the "Days to Load" setting constant, but should be increasing the "Days to Load" count each time I relaunch my strategies before each trading week.

                      To Illustrate:

                      1) I commence trading on 1st Jan 2011. A Long EURUSD position opens on 1st Jan 2011, and the conditions for the trade to close out would materialize only on 16 Jan 2011.

                      2) After the end of the trading week on 5th Jan 2011, I restart my computer and relaunch Ninjatrader. For each strategy, I load 5 days of data, dating back to 1st Jan when my strategy decided to go long on EURUSD.

                      3) At the end of the second trading week on 12th Jan 2011, the conditions for trade exit have not been met. As such, my position is still long EURUSD. After rebooting my computer and relaunching Ninjatrader, I will have to load 10 days of data, dating back to 1st Jan 2011: that fateful day when my strategy decided to go long EURUSD.

                      If I had loaded only 5 days after the second reboot, Ninjatrader would possess price data only from 8th Jan 2011 onwards, and would not have detected that a Long EURUSD trade had been entered on 1st Jan 2011. The strategy would wrongly reflect a flat position, and would have failed to detect and manage the trade entered on 1st Jan 2011.

                      4) As such, at the end of each trading week, when I re-activate my strategy, I would have to reload data dating back to 1st Jan 2011 to ensure consistency between account position and strategy position. I would do so by increasing the "days to load" count by 5 days at the end of every week.

                      Is this correct? Thanks for your continued patience!

                      Comment


                        #12
                        Yes, excellent point. The start date for both strategy runs should be the same and to match these up requires different days to load between the tests.
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_RyanM View Post
                          Yes, excellent point. The start date for both strategy runs should be the same and to match these up requires different days to load between the tests.
                          Thanks for clearing the confusion I've had over the past few days!

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Barry Milan, Yesterday, 10:35 PM
                          7 responses
                          19 views
                          0 likes
                          Last Post NinjaTrader_Manfred  
                          Started by AttiM, 02-14-2024, 05:20 PM
                          10 responses
                          179 views
                          0 likes
                          Last Post jeronymite  
                          Started by ghoul, Today, 06:02 PM
                          0 responses
                          9 views
                          0 likes
                          Last Post ghoul
                          by ghoul
                           
                          Started by DanielSanMartin, Yesterday, 02:37 PM
                          2 responses
                          13 views
                          0 likes
                          Last Post DanielSanMartin  
                          Started by DJ888, 04-16-2024, 06:09 PM
                          4 responses
                          13 views
                          0 likes
                          Last Post DJ888
                          by DJ888
                           
                          Working...
                          X