Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Not executing OnStartUp() in strategy

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

    #16
    >> There is a reasonable chance that a developer might see quickly what the scenario is in which it doesn't get executed
    Unfortunately not since code review has not exposed any issue as of yet.

    Comment


      #17
      Originally posted by dave1992 View Post
      What I mean is not executing OnStartUp every time.
      OnStartUp() is not firing for me either when using NT7.0.0.12.

      Try using the OnStart() and OnStop() methods instead. They seem to be working fine.

      Comment


        #18
        >> Try using the OnStart() and OnStop() methods instead.
        This is NOT recommended as they are for internal only. We needed to isolate the original issue. Thanks

        Comment


          #19
          Originally posted by NinjaTrader_Dierk View Post
          >> Try using the OnStart() and OnStop() methods instead.
          This is NOT recommended as they are for internal only. We needed to isolate the original issue. Thanks
          Understood. I just suggested it to the OP as temporary workaround until the issue is resolved in the next beta release.

          Comment


            #20
            We well address this issue as soon as we have understood it's cause which is not yet the case.

            Comment


              #21
              Originally posted by NinjaTrader_Dierk View Post
              We well address this issue as soon as we have understood it's cause which is not yet the case.
              OK. I am experiencing it too so if there are any tests you wish me to run then let me know. Getting data from another person might make tracking down the problem easier.

              Comment


                #22
                Not sure if its helps or hinders but I've changed the the way I code print statements, and this is interesting. This is not printing when I enable a live Strat:

                PHP Code:
                protected override void OnStartUp()//////////////////////////////////////////////////////////////////////
                {
                if (Historical != true)
                { 
                Print(DateTime.Now+" STRATEGY CUR_002/INSTRUMENT: " + Instrument.FullName + " ENABLED. MarketPosition: "
                + Position.MarketPosition);
                } 
                } 
                
                Everything else prints as expected during live trading and doesn't print as expected during a backtest such as this in OnBarUpdate():

                PHP Code:
                {
                EnterLong(2, EntriesPerDirection, "Long 1a");
                EnterLong(2, EntriesPerDirection, "Long 1b");
                if(Historical != true)
                {
                Log(Instrument.FullName + " LONG signal generated with ASK at: " + GetCurrentAsk(),NinjaTrader.Cbi.LogLevel.Information); //For basic TCA
                PrintWithTimeStamp("STRATEGY CUR_002: " + Instrument.FullName + " LONG signal generated with ASK at: " + GetCurrentAsk());
                } 
                
                And my OnTermination() works as expected on both live and backest:

                PHP Code:
                protected override void OnTermination()
                {
                if (Historical != true)
                {
                Print(DateTime.Now+ " STRATEGY CUR_002/INSTRUMENT: " + Instrument.FullName + " DISABLED. MarketPosition: " + Position.MarketPosition);
                Print(DateTime.Now+ " STRATEGY CUR_002/INSTRUMENT: " + Instrument.FullName + " PriorTradesCumProfit= "+priorTradesCumProfit +
                ", Performance.AllTrades.TradesPerformance.Currency.CumProfit= "+Performance.AllTrades.TradesPerformance.Currency.CumProfit);
                }
                } 
                

                Comment


                  #23
                  MXASJ,

                  When you start a strategy at the very beginning I would not imagine Historical to be false. You still have historical bars to process. The switch to real-time is after you finish processing historical bars and not prior to then.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #24
                    I'm trying to work out when this happens, and I think it's a state that the strategy tab/strategies eventually gets into. I left NT up over the holiday weekend, not connected to Zen Fire, but with the strategies in the strategy tab. This morning, I just connected and enabled my 5 strategies, and non of them execute OnStartUp(). They seem to do everything else as expected. I can enable/disable as many times as I like, but it appears OnStartUp will never be executed.

                    I also tried the following actions, but the problem remained

                    - edit a strategy
                    - remove and new
                    - remove one strat, disconnect, remove, exit and restart and new strat
                    - restart, re-compile strategy

                    I still haven't found how to get them started properly. Like last time this happened, it will probably be just a few hours of trying things. I'll try and work out what the key thing was if I come across it today.

                    Dave

                    Comment


                      #25
                      Dave,

                      In your tests, please use the sample I posted earlier so we can be 100% sure there are no extraneous variables influencing the setup as you try to isolate the behavior. Thank you for your efforts and any additional information you may be able to find.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #26
                        Dave and MXASJ,

                        We believe we found and fixed something that may actually be causing some of the OnStartUp() missing events you have been experiencing. Please try again in the next version and let us know should you still experience issues. Thank you for your efforts and patience.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #27
                          Great, thanks. Do you mean potentially fixed in Beta 13 or 14?

                          Comment


                            #28
                            Hi Dave,

                            It should be there in B14.
                            Josh P.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            612 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            355 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            105 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            561 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            564 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X