View Full Version : OnStartUp vs Initialize
Mindset
05-10-2010, 07:02 AM
I understand that OnStartUp gets called once only and after initialize.
So is it ok to do this ie place eventhandler stuff here?
protected override void OnStartUp()
{
chartpanel = ChartControl.ChartPanel;
chartpanel.KeyDown += new KeyEventHandler(this.OnKeyDown);
}
NinjaTrader_Bertrand
05-10-2010, 07:36 AM
Mindset, you would need to give it a try - correct OnStartUp() is the best place for allocating custom resources to be used as it does not get called multiple times like script's Initialize().
Mindset
05-10-2010, 08:18 AM
Oh yes it definitely works but my programming skills are kindergarten and I was simply wondering if it is better in OnStartUp rather than Initialize - precisely because as you say it only gets called just once.
ie is it elegant and efficient programming?
NinjaTrader_Bertrand
05-10-2010, 09:05 AM
Moving those parts to OnStartUp() is good programming yes, it was exactly created for allocating custom resources, as in 65 you had to do it all on first OnBarUpdate() bar to avoid multiple calls.
Mindset
05-10-2010, 11:25 AM
Many thanks Bertrand
sbgtrading
05-31-2010, 02:19 PM
Question about the help docs for NT7.0.0.16 in regard to the "Initialize vs. OnStartUp" discussion. The help docs advocate calling any license checks from within OnStartUp...however, if you put the VendorLicense call in OnStartUp, then you never get a a popup window when the license fails validation. If you put the VendorLicense call in Initialize(), you will get a popup window when the license fails validation.
So I believe either the docs should contain information on this important side-effect, or the popup window should be triggered from within the OnStartUp() method.
eDanny
05-31-2010, 04:14 PM
Ben, I had to reread that area and it seems the standard NinjaTrader Vendor license check should be in the Initialize() section but if you are using your own custom check it should go in OnStartUp().
Dan
sbgtrading
05-31-2010, 05:34 PM
That's sounds reasonable...so then it's really just a matter of rephrasing/clearing up the statement in the help docs under "Initialize()".
NinjaTrader_Bertrand
06-01-2010, 07:42 AM
Ben, I'll forward this to be expressed more clear as far as the differences go for license checks used.