Unfortunately not since code review has not exposed any issue as of yet.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Not executing OnStartUp() in strategy
Collapse
X
-
-
Understood. I just suggested it to the OP as temporary workaround until the issue is resolved in the next beta release.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
Comment
-
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.Originally posted by NinjaTrader_Dierk View PostWe well address this issue as soon as we have understood it's cause which is not yet the case.
Comment
-
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:
Everything else prints as expected during live trading and doesn't print as expected during a backtest such as this in OnBarUpdate():PHP Code:protected override void OnStartUp()////////////////////////////////////////////////////////////////////// { if (Historical != true) { Print(DateTime.Now+" STRATEGY CUR_002/INSTRUMENT: " + Instrument.FullName + " ENABLED. MarketPosition: " + Position.MarketPosition); } }
And my OnTermination() works as expected on both live and backest: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()); }
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
-
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
-
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
-
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
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
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
355 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
561 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
564 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment