Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

When strategy loses connection

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

    When strategy loses connection

    When a strategy has an open position it's managing, and it loses the broker connection and disables itself, is there a way to enable the strategy and pick up managing that same trade again from where it left off?

    Bryan
    cassb
    NinjaTrader Ecosystem Vendor - Logical Forex

    #2
    Hello Bryan,

    Thank you for writing in.

    No, once the strategy has disabled itself due to hitting its max reconnect attempts, you would manually have to handle the strategy/position.

    If you are having connection issues you might consider looking into a new internet provider or a VPS.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Alan. Is there any workaround for this? Saving the strategy variables to a file on every tick and restoring from the file when it comes back online? Something? Anyone?
      cassb
      NinjaTrader Ecosystem Vendor - Logical Forex

      Comment


        #4
        Originally posted by NinjaTrader_AlanP View Post
        Hello Bryan,

        Thank you for writing in.

        No, once the strategy has disabled itself due to hitting its max reconnect attempts, you would manually have to handle the strategy/position.

        If you are having connection issues you might consider looking into a new internet provider or a VPS.

        Please let us know if you need further assistance.
        What about "StartBehavior.AdoptAccountPosition"? Is that not supposed to be its raison d'ętre.

        ref: http://ninjatrader.com/support/helpG...rtbehavior.htm

        Comment


          #5
          Yes, good point. And that goes with this flag:

          IsAdoptAccountPositionAware

          Definition

          Determines if the strategy is programmed in a manner capable of handling real-world account positions. Once set to true, your strategy's "Start behavior" options will include an additional parameter named "Adopt account position" which can bet set at run-time. Only set to true if you have specifically programmed your strategy to be able to adopt account positions.
          cassb
          NinjaTrader Ecosystem Vendor - Logical Forex

          Comment


            #6
            Hello cassb,

            Koganam provides a good suggestion for how to set up your strategy to begin re-managing an open position upon restart, thank you Koganam, however I have just submitted a bug report as its not behaving as expected.

            Your question about writing and reading from a text file could work, however would require you use the unmanaged approach, which a more advanced programming topic. You could read more about that here,


            If you were interested in that approach, I have provided links to reading/writing from a text file.

            Indicator: Using StreamWriter to write to a text file

            Then you could have your strategy read from the file, a reference example,
            Indicator: Using StreamReader to read from a text file

            Please let us know if you need further assistance.
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              Thanks Alan. I think I'll try koganam's suggestion, but you are saying it doesn't work in the current version? I do use the managed approach with orders, so I would rather not have to use text files and change the code to use the unmanaged approach.
              cassb
              NinjaTrader Ecosystem Vendor - Logical Forex

              Comment


                #8
                Hello cassb,

                Correct, upon reconnect its not managing the position. I have submitted a bug report and would expect the issue to be resolved in a coming release of NinjaTrader 8.

                Please let us know if you need further assistance.
                Alan P.NinjaTrader Customer Service

                Comment


                  #9
                  Fantastic, thank you! Is there an issue number or something I can reference in the next Release Notes that would tell me it's working?

                  Bryan
                  cassb
                  NinjaTrader Ecosystem Vendor - Logical Forex

                  Comment


                    #10
                    Hello Bryan,

                    I have made a note to will follow up when the issue has been assigned an ID.

                    Thank you for your patience.
                    Alan P.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Alan. Is this issue resolved yet? I would like to use it asap.

                      Thanks!
                      Bryan
                      cassb
                      NinjaTrader Ecosystem Vendor - Logical Forex

                      Comment


                        #12
                        Hello Bryan,

                        Go to Control Center>Tools>Options and under Strategy Categories, if you you set On Connection Loss>Handling> to Keep Running or Stop Strategy, then upon connection loss your strategy should behave as expected.

                        Start Behavior will only affect the strategies when they are first started.

                        I apologize for not following up on this sooner, I had forgot to include this ticket with the issue number and therefor couldn't follow up when it was explained to me.

                        Please let us know if you need further assistance.
                        Alan P.NinjaTrader Customer Service

                        Comment


                          #13
                          OK thank you. But we had that option set to "Keep Running", but the problem was that it lost the connection and never reconnected. When we disconnected and reconnected to the provider, the strategy disabled and then was not able to manage the position. Is there a way around that to manually reconnect to the broker without disabling the strategy?

                          Thanks!
                          Bryan
                          cassb
                          NinjaTrader Ecosystem Vendor - Logical Forex

                          Comment


                            #14
                            I have the same issue. Its not a frequent occurrence but would be nice to have this as a backup plan. I set the connection timeout to 180s and reconnection attempts to 5. The major obstacle is if you have to restart NT8 due to a crash and re-enable the strategy once restarted. I set start behavior on the strategy to sync with account and submit immediately. This way, you would have all original orders closed prior to enabling again and a fresh set of orders out in sync with the original order submission. Only drawback is you might enter the same position as a less favourable price (or better if your lucky).

                            Comment


                              #15
                              Exactly. I'm not sure why the strategy automatically disables when you disconnect from the broker, but it would be nice to have a switch to allow it to remain running while you reconnect so that it would stay in sync with the open positions at the broker.
                              cassb
                              NinjaTrader Ecosystem Vendor - Logical Forex

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              171 responses
                              2,273 views
                              0 likes
                              Last Post QuantKey_Bruce  
                              Started by Irukandji, Yesterday, 02:53 AM
                              2 responses
                              17 views
                              0 likes
                              Last Post Irukandji  
                              Started by adeelshahzad, Today, 03:54 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post adeelshahzad  
                              Started by CortexZenUSA, Today, 12:53 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post CortexZenUSA  
                              Started by CortexZenUSA, Today, 12:46 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post CortexZenUSA  
                              Working...
                              X