• 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

Weekly Crashes/Sync Account Position

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

    Weekly Crashes/Sync Account Position

    Hello,

    This is a two-part question. For background, I trade currencies with FXCM as a broker, and have a lifetime NinjaTrader license. I am live-testing automated strategies that I developed using Ninjascript.

    First: NinjaTrader crashes weekly. I believe that FXCM takes its servers down for maintenance on Friday evening and generally boots them by Saturday morning. If I have an active strategy, the control center displays that the connection was lost (red in bottom left corner) and this does not resolve itself by Sunday afternoon. If I attempt to do anything in NT, such as scroll in a chart or disable a strategy, the application crashes and I have to reboot, which leads to my second problem, but before we get to that - how can this be fixed?

    Second: When I try to re-enable a strategy that currently has an active position, NT flattens the position for me. I do not want this to happen; since a strategy has an active position, NT should reach out to my broker's server, match active orders, and continue without interruption.
    My settings are currently: SyncAccountPosition = true, and "Immediately Submit Live Working Historical Orders" is also checked.
    What combination of selections will fix this?

    Thank you.

    #2
    Hello UglyHack,

    Thank you for your post.

    For your first question, please send me your log and trace files for today so that I may look into what occurred. You can do this by going to the Control Center-> Help-> Mail to Platform Support. Please place this thread in the subject line: "http://www.ninjatrader.com/support/forum/showthread.php?t=70996"

    For the second item, NinjaTrader does not "reach out" to your broker for positions or orders. It will look to the account's current position and make sure it is in sync with the strategy's calculated position. If you do not want this to occur then set Sync Account Position to false.
    Please review the details on these options at the following link: http://www.ninjatrader.com/support/h..._positions.htm
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Hello Patrick,
      Thank you for your prompt response.
      I just sent the requested log and trace files to support, and hope that they are enlightening. Stopping the weekly crash issue will resolve my second question in most circumstances.

      To the second issue - how the NT API determines an active position/active orders is something of a semantic issue, really. The main point is, when NT (or a strategy) is restarted for whatever reason, how does one get the strategy to pick up where it left off?

      To illustrate:
      1. An active strategy has entered a position and has placed both Take Profit (Limit) and Stop Loss (Stop) orders.
      2. Either the strategy is disabled or NinjaTrader is closed.
      3. NinjaTrader is restarted. Order States for the Limit and Stop orders are "Working."
      4. The strategy is re-enabled. What I want to happen is for those orders to continue operating - for the position entered prior to the crash to continue until either the Stop or Limit price is reached, then for the strategy to continue as normal.

      My current option appears to close the position. This is vexatious, and if I read the manual correctly, could have been caused by previous NT crashes (and the corollary flattening of positions) causing the "historical" position to not by in sync with reality.

      A previous combination (Wait until flat, Sync = true, if I recall correctly) attempted to cancel active orders, which is also not what I want.

      What combination should I select for the scenario outlined in step 4 above to happen?

      Comment


        #4
        Hello UglyHack,

        Thank you for your response.

        You would set Sync to False, and Wait Until Flat. Then make sure under Tools > Options > Strategies > NinjaScript, that you do not have enter or exit orders set to cancel.

        Unfortunately, the strategies cannot pick up where they left off. You can ensure the orders are not cancelled and that the strategy does not force the position with Sync.
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          Hello Patrick,

          Sorry for the bad news here, but I selected the options you described and did not get the intended result.
          NT cancelled my Stop and Limit orders, then failed to start my strategy, throwing this error message: "Unable to cancel our live orders. Strategy....was not started."

          The only thing I can think of at this point is perhaps a malfunction in my OnStartUp() rule, which I have commented out for future testing.

          To try to get the strategy to run again, I flattened everything, made sure all orders were cancelled, closed NT, rebooted my system, and.... Now I cannot start either strategy that had an active position before testing. Strategies that did not have an active position start without issue.

          Below is an excerpt from the output window pertaining to this. I'm dead in the water here. Please advise.

          Thank you.

          **NT** Enabling NinjaScript strategy 'BBTF_STF_ID_TF_BBPctB/00910ea8c6844b7db288f9048136ba7a' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=False Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=False CalculateOnBarClose=True MaxRestarts=999 in 5 minutes
          **NT** Unable to cancel out live orders. Strategy 'BBTF_STF_ID_TF_BBPctB/00910ea8c6844b7db288f9048136ba7a' was not started.
          12/31/2014 7:38:09 PM CancelAllOrders: BarsInProgress=0
          12/31/2014 7:38:09 PM CancelAllOrders: BarsInProgress=1

          Comment


            #6
            UglyHack, we're sorry to hear that - could you please contact us via Help > Mail to Support so we could review your trace / log files for this occurrence closely?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Hello Bertrand,

              Thank you for your reply.

              I just sent that e-mail your way, and included the thread in the subject line as before: "http://www.ninjatrader.com/support/forum/showthread.php?t=70996"

              Another thought occurs to me - I had taken steps suggested in e-mail to prevent weekly crashes just before implementing the advice in this thread for order handling when the strategy is enabled. I don't know if this would have had any effect, but it is a variable.

              Comment


                #8
                Hello guys,

                NT lost the connection to the price server again on Friday (weekly maintenance, normal behavior) and did not reconnect by the session start on Sunday.

                I manually deactivated strategies and disconnected from the FXCM servers, then attempted to reconnect. No luck.
                I was only able to successfully reconnect after closing and re-opening NT.

                On a positive note, NinjaTrader did NOT crash today.

                I'd rather not repeat this performance every week if it could be avoided. Any ideas what might be happening here?

                Thank you.

                Comment


                  #9
                  Hello UglyHack,

                  Thank you for your patience.

                  Please rename your database with the following steps :
                  • Shutdown NinjaTrader and Go to the Start Menu
                  • Select My Documents--> NinjaTrader 7--> DB--> NinjaTrader.SDF.
                  • Right click on NinjaTrader.SDF and select "Rename." *Name it "OLDNinjaTrader.SDF."
                  • Then restart the software and NinjaTrader will create a fresh database file to use
                  • Unfortunately the following items stored in the old database will be lost - ATM Strategy templates, Session templates, Instrument Lists / Custom Instruments, historical trade execution data, saved Strategy Analyzer backtest results

                  To prevent running into situations where you can potentially lose important data, we advise to run regular backups via our inbuild backup feature in NinjaTrader - http://www.ninjatrader.com/support/h...up_archive.htm
                  Patrick H.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello Patrick,

                    Thank you for your response. I have done as advised, and will respond if the problem persists.

                    Comment


                      #11
                      Hello again,
                      The system crashed last Thursday, 1/29, with two open positions, each from a different strategy. This crash was due to Windows, not NinjaTrader.

                      Both positions had an affiliated Stop and Limit order that existed upon system and NT reboot.

                      Options selected when the strategies were re-started were:
                      Wait Until Flat
                      Sync Account Position = False.
                      In Tools > Options > Strategies > NinjaScript, cancelling orders was not selected.

                      Also, price was still valid - between the Stop and Limit prices.

                      Existing Stop and Limit orders for both strategies were cancelled. Based on the thread below, I do not believe that this should have happened.

                      Please advise, why is this happening?
                      Is there any additional information required to diagnose?

                      Thank you.

                      Comment


                        #12
                        Hello UglyHack,

                        If there is a crash of the PC, there is no way for the strategy to communicate a cancel of the orders.
                        Patrick H.NinjaTrader Customer Service

                        Comment


                          #13
                          Hello Patrick,

                          Please allow me to clarify.

                          Stop and Limit orders were cancelled when the strategies were re-started.

                          The PC crash did not cancel orders; restarting the strategies did.

                          Comment


                            #14
                            Hello UglyHack,

                            Thank you for your response.

                            When your strategy starts it will check for any active orders previously generated by the strategy on your account and cancel those first. Please refer to the following link for more information: http://www.ninjatrader.com/support/h..._positions.htm
                            Patrick H.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi Patrick,

                              The quote below is what you recommended to try in response to my inquiry on 12-29-2014 06:21 PM. The intended result was to have strategy re-activation NOT cancel open orders for an existing position.

                              It appears that this advice did not work as intended, which is why I am continuing this thread.

                              Originally posted by NinjaTrader_PatrickH View Post
                              Hello UglyHack,

                              Thank you for your response.

                              You would set Sync to False, and Wait Until Flat. Then make sure under Tools > Options > Strategies > NinjaScript, that you do not have enter or exit orders set to cancel.

                              Unfortunately, the strategies cannot pick up where they left off. You can ensure the orders are not cancelled and that the strategy does not force the position with Sync.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Brillo, Yesterday, 08:47 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post Brillo
                              by Brillo
                               
                              Started by Gav_G, Yesterday, 02:12 PM
                              3 responses
                              11 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Gav_G, Yesterday, 01:41 PM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by kweiss, Yesterday, 01:21 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by cutzpr, Yesterday, 08:44 AM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X