Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Revovering from Data Feed Disconnect

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

    Revovering from Data Feed Disconnect

    Is there any reason my Strategy cannot programmatically pick up from where it left off prior to a disconnect which kills the Strategy?

    I am thinking of storing an array of open positions to a file and restoring the file back to the array on script startup.

    Should this work? (complete access to moving stops/targets; receiving OnOrderUpdate events).

    Thanks!
    Last edited by SteveB; 11-29-2008, 08:09 AM.

    #2
    There is a lot involved in try to recover from a disconnect. NT7 will provide some options in this area. I personally would not advise trying to store a strategy state and recovering it. I can't guarantee that you could make it work.
    RayNinjaTrader Customer Service

    Comment


      #3
      This issue is critically important to me prior to my running my Srategy against a live account.

      What steps would I need to complete in NT6.5?

      How will this change in NT7?

      Thanks!

      Comment


        #4
        SteveB,

        In NT6.5, you want to make sure your strategy position is in sync with your account position. This needs to be done manually. Please see this tip: http://www.ninjatrader-support2.com/...ead.php?t=4033

        As Ray mentioned, NT7 will have improvements in this area. Announcements will be made when available.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Let's forget about the Account Position for now...

          What I am most interested in is:

          If my Strategy position is Long 1, with a corresponding Target and StopLoss, can I:

          1) Save my position info to a file from within my Strategy.
          2) End my Strategy.
          3) Start my Strategy (inputting data saved in step 1).
          4) Issue new SetTarget & SetStopLoss commands to move existing Long 1 Target & StopLoss.

          ...pick up from where I left off prior to ending Strategy?

          Another way of asking:

          Is there anykind of State info that NT maintains that would prevent me from resuming my Strategy if I can reconstruct all data available?

          Thanks!

          Comment


            #6
            The short answer is no.
            RayNinjaTrader Customer Service

            Comment


              #7
              umm, which question does that answer?

              Comment


                #8
                See below.

                Originally posted by SteveB View Post
                Let's forget about the Account Position for now...

                What I am most interested in is:

                If my Strategy position is Long 1, with a corresponding Target and StopLoss, can I:

                1) Save my position info to a file from within my Strategy.
                >> YES

                2) End my Strategy.
                3) Start my Strategy (inputting data saved in step 1).
                4) Issue new SetTarget & SetStopLoss commands to move existing Long 1 Target & StopLoss.
                >> NO

                ...pick up from where I left off prior to ending Strategy?
                >> NO
                Another way of asking:

                Is there anykind of State info that NT maintains that would prevent me from resuming my Strategy if I can reconstruct all data available?
                >> The short answer is that you can NOT reconstruct the last state of your strategy.
                Thanks!
                RayNinjaTrader Customer Service

                Comment


                  #9
                  So upon Strategy termination, I really have no choice but to manually close all positions and restart Strategy (losing all my stats for open positions)...?

                  Are there any fault-tolerance plans in NT's future to prevent termination of the Strategy in the event of a disconnect from the Data Feed/Broker?

                  Thanks!

                  Comment


                    #10
                    See below:

                    Originally posted by SteveB View Post
                    So upon Strategy termination, I really have no choice but to manually close all positions and restart Strategy (losing all my stats for open positions)...?
                    >>>> YES

                    Are there any fault-tolerance plans in NT's future to prevent termination of the Strategy in the event of a disconnect from the Data Feed/Broker?
                    >>> See Post #2

                    Thanks!
                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by SteveB View Post
                      So upon Strategy termination, I really have no choice but to manually close all positions and restart Strategy (losing all my stats for open positions)...?

                      Are there any fault-tolerance plans in NT's future to prevent termination of the Strategy in the event of a disconnect from the Data Feed/Broker?

                      Thanks!
                      Steve,

                      I think you can do a little better than that. You might not be able to rely on SL and PT, but you can certainly pick up and keep going in terms of strategy/actual position. (And you can always explicitly re-submit your stop and profit targets using ExitLongStop and ExitLongLimit.)

                      You really don't need to "save" your position information. As long as your strategy code hasn't changed, as the code runs again your hypothetical positions should look identical on the second run... right? The only thing that might change slightly are your fill numbers... and if you really need fully accurate fill numbers, you *will* need to track them and store them into a file externally with each execution.

                      I stop/start my strategy multiple times every day (debugging after all), and guaranteed every night. I'm holding my positions for weeks at a time, and it's working well... with one caveat. Go look in the Autotrading forum for my thread about "BuyToCover" versus Buy.

                      FYI, I used to work with Wealth Lab. Their programming model basically assumed a *complete* stop of the strategy after every bar was processed. When a new bar arrives, it would feed your strategy *every* bar from the very beginning of whatever defined data range, and you build your hypothetical position starting with zero... every time. That's not how NinjaTrader is "intended" to operate... but I don't see why it can't.

                      Comment


                        #12
                        Originally posted by heech View Post
                        I stop/start my strategy multiple times every day (debugging after all), and guaranteed every night. I'm holding my positions for weeks at a time, and it's working well... with one caveat. Go look in the Autotrading forum for my thread about "BuyToCover" versus Buy.
                        There's one thing I don't understand about this.. if you are already say long 3 ES from the day before and you stop and restart your strategy, it's going to show flat. What do you do to make the two synchronize? From what I understand of Ninjatrader the only way is to close out the positions in the account so that the account matches the strategy (is flat).

                        I must be missing something here.

                        Thanks

                        Comment


                          #13
                          When you restart a strategy NinjaTrader calculates out your Strategy Position. If your account position matches this strategy position there is nothing you need to do. If your strategy calculates out a position that is flat you need to flatten your account position to bring them in sync.

                          If it is showing flat it is because your strategy position is flat. You need to go reevaluate how your code is working. For sure there will be differences between real-time orders and historical orders. When you reload your strategy it calculates like it were a backtest. An order submitted in real-time may not necessarily also submit in backtesting. Please understand this difference.

                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by cunparis View Post
                            There's one thing I don't understand about this.. if you are already say long 3 ES from the day before and you stop and restart your strategy, it's going to show flat. What do you do to make the two synchronize? From what I understand of Ninjatrader the only way is to close out the positions in the account so that the account matches the strategy (is flat).

                            I must be missing something here.

                            Thanks
                            cunparis,

                            I just replied to a post of yours in a different thread about the same topic... basically, if you setup your strategy to again run over yesterday's bars (which made you go long 3 ES), your strategy will *again* build up a strategy position of long 3 ES.

                            Make sense? NinjaTrader sees your "historical" EnterLong() calls, and doesn't place new orders for them... but it assumes they filled, and builds up a strategy position.

                            So the key concept here is, start your strategy with HISTORICAL bars.

                            Comment


                              #15
                              Originally posted by heech View Post
                              cunparis,

                              I just replied to a post of yours in a different thread about the same topic... basically, if you setup your strategy to again run over yesterday's bars (which made you go long 3 ES), your strategy will *again* build up a strategy position of long 3 ES.

                              Make sense? NinjaTrader sees your "historical" EnterLong() calls, and doesn't place new orders for them... but it assumes they filled, and builds up a strategy position.

                              So the key concept here is, start your strategy with HISTORICAL bars.
                              Thanks for your feedback. How do you do that? I don't see any way to do it. When I run a strategy there is no option for how many historical bars are used.

                              Most of my trades should be within a few hours period, but when trading 60 minute charts I think it's possible that I could have a trade span 3 days. If it enters towards the end of day 1 and then holds day 2 and then exits day 3. This is the worst case. So if I can tell the strategy to reply the previous 2 days you're right, it should work ok.

                              Later on I plan to trade several strategies in parallel and that will make it much more complicated, but for now I start simple.

                              EDIT: Question answered in this thread: http://www.ninjatrader-support2.com/...4786#post64786

                              It's in the lookback period. I had no idea what that was for, now I know. This is awesome. I think this will be just fine for me. This and TWSStart will make it possible for me to autotrade with IB. I thought I had to open an account with a zen-fire broker..
                              Last edited by cunparis; 12-03-2008, 12:00 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              572 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              331 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              101 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              549 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              550 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X