First, I tried to declare a default constructor for my strategy as follows
MyCustomStrategy()
{
Print("Construct - this = " + this.ToString));
}
Secondly,since I couldn't get my constructor to work and wanted to make some observations about instantiations, I placed a static integer counter in my class to keep track of object creations. Noticed that 10 instances werecreated per backtest run which resulted inan invocation of MyCustomStrategy.Initialize() once per instantiated ojbect.Is this expected bahavior? If so, this tellsme that if I have any real heavy lifting to do in the strategy (a database open perhaps?) I should wait for the first bar in MyCustomStrategy.OnBarUpdate() before finishing initialization of the object instance. Here is the output from my experiment. And BTW - I *really* like that performance number
Best Regards,
Jim
Initialize - this = MyCustomStrategy(1) - myInitCounter = 1
Destruct - this = MyCustomStrategy(1) - myInitCounter = 0
Initialize - this = MyCustomStrategy(1) - myInitCounter = 2
Initialize - this = MyCustomStrategy(1) - myInitCounter = 3
Initialize - this = MyCustomStrategy(1) - myInitCounter = 4
Destruct - this = MyCustomStrategy(1) - myInitCounter = 1
Destruct - this = MyCustomStrategy(1) - myInitCounter = 7
Destruct - this = MyCustomStrategy(1) - myInitCounter = 4
Destruct - this = MyCustomStrategy(1) - myInitCounter = 3
Destruct - this = MyCustomStrategy(1) - myInitCounter = 5
Destruct - this = MyCustomStrategy(1) - myInitCounter = 6
Destruct - this = MyCustomStrategy(1) - myInitCounter = 0
Destruct - this = MyCustomStrategy(1) - myInitCounter = 8
OnBarUpdate - First Bar - this = MyCustomStrategy(1)
OnBarUpdate - myInitCounter = 4
Processed 562038 bars in 609 milliseconds
Initialize - this = MyCustomStrategy(1) - myInitCounter = 5
Initialize - this = MyCustomStrategy(1) - myInitCounter = 6
Initialize - this = MyCustomStrategy(1) - myInitCounter = 7
Initialize - this = MyCustomStrategy(1) - myInitCounter = 8
Initialize - this = MyCustomStrategy(1) - myInitCounter = 9
Initialize - this = MyCustomStrategy(1) - myInitCounter = 10
Destruct - this = MyCustomStrategy(1) - myInitCounter = 9
Destruct - this = MyCustomStrategy(1) - myInitCounter = 2
Destruct - this = MyCustomStrategy(1) - myInitCounter = 10
--snip--Exception details.
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at NinjaTrader.Strategy.NewStrategyForm.OnOK(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& ; m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message&am p; m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Fra...7/mscorlib.dll
----------------------------------------
NinjaTrader
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Program%20Files/NinjaTrad...injaTrader.exe
----------------------------------------
NinjaTrader.Core
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Program%20Files/NinjaTrad...rader.Core.DLL
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...dows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...em.Drawing.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...System.Xml.dll
----------------------------------------
WilsonORMapper
Assembly Version: 4.2.2.0
Win32 Version: 4.2.2.0
CodeBase: file:///C:/Program%20Files/NinjaTrad...onORMapper.DLL
----------------------------------------
System.Data
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_32/S...ystem.Data.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...figuration.dll
----------------------------------------
dsdvp9h9
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
SMTP.Net
Assembly Version: 3.0.1.0
Win32 Version: 3.0.1.0
CodeBase: file:///C:/Program%20Files/NinjaTrad...n/SMTP.Net.DLL
----------------------------------------
System.Management
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...Management.dll
----------------------------------------
11cf84afd8fb45e0a9088ea8d1fc7ecb
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...der.Custom.dll
----------------------------------------
NinjaTrader.Vendor
Assembly Version: 6.0.0.1
Win32 Version: 6.0.0.1
CodeBase: file:///C:/Documents%20and%20Setting...der.Vendor.dll
----------------------------------------
wi3-t3bt
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
fbkc1mdh
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
p-1lrvpq
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
y4qdu_c-
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
sdbkbu4x
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
9jgpp5g8
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
dsawgt_4
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
knax3q71
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
lpardnsn
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
cheflhmc
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
c5pk4ftl
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
ucxp2psp
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
rirvkepa
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
bv6nohtz
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
vkceaguz
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
w8bjjriz
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
4xzsgcv7
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
mpmay1md
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
mqle2hj5
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
rzpxovoe
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
9aw68cqe
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
1ngj5uns
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
jq1ukqm7
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
px6icxwa
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
System.Data.OracleClient
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_32/S...acleClient.dll
----------------------------------------
System.Transactions
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_32/S...ansactions.dll
----------------------------------------
System.EnterpriseServices
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_32/S...seServices.dll
----------------------------------------
hclzwq0y
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
bjt1ipis
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
5nwh8bet
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
evm8uizy
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
sfoo1_yo
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
5zqcr_2s
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
SourceGrid2
Assembly Version: 2.2.0.0
Win32 Version: 2.2.0.0
CodeBase: file:///C:/Program%20Files/NinjaTrad...ourceGrid2.DLL
----------------------------------------
SourceLibrary
Assembly Version: 1.2.3.0
Win32 Version: 1.2.3.1
CodeBase: file:///C:/Program%20Files/NinjaTrad...rceLibrary.DLL
----------------------------------------
System.Design
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...tem.Design.dll
----------------------------------------
Accessibility
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...essibility.dll
----------------------------------------
wb7-pog0
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
ActiproSoftware.SyntaxEditor.Net20
Assembly Version: 4.0.238.0
Win32 Version: 4.0.238.0
CodeBase: file:///C:/Program%20Files/NinjaTrad...itor.Net20.DLL
----------------------------------------
ActiproSoftware.Shared.Net20
Assembly Version: 1.0.85.0
Win32 Version: 1.0.85.0
CodeBase: file:///C:/Program%20Files/NinjaTrad...ared.Net20.DLL
----------------------------------------
ActiproSoftware.WinUICore.Net20
Assembly Version: 1.0.85.0
Win32 Version: 1.0.85.0
CodeBase: file:///C:/Program%20Files/NinjaTrad...Core.Net20.DLL
----------------------------------------
ActiproSoftware.SyntaxEditor.Addons.DotNet.Net20
Assembly Version: 4.0.238.0
Win32 Version: 4.0.238.0
CodeBase: file:///C:/Program%20Files/NinjaTrad...tNet.Net20.DLL
----------------------------------------
oji03-nb
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
ebcb32afc6204adaa876eaaa03b17e17
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...aa03b17e17.dll
----------------------------------------
894bb0b601174129a1a2a445ec5a2401
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...45ec5a2401.dll
----------------------------------------
UtilityLibrary
Assembly Version: 1.0.4.0
Win32 Version: 1.0.4.0
CodeBase: file:///C:/Program%20Files/NinjaTrad...ityLibrary.DLL
----------------------------------------
jhaex9pi
Assembly Version: 6.0.0.8
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL...089/System.dll
----------------------------------------
4322b0d7bec64ab48d138109c694fb1d
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...09c694fb1d.dll
----------------------------------------
cf1bec5f29824a3295ae09494f67b160
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...494f67b160.dll
----------------------------------------
990ea66b6ca743bd9d9a2ab7b51d5428
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...b7b51d5428.dll
----------------------------------------
5d23b475e7bc4b04aba9cce3d9670032
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...e3d9670032.dll
----------------------------------------
6129cdc04df94dd68c254be791cf9bd6
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...e791cf9bd6.dll
----------------------------------------
8dcb4be674974df38d522919add86db1
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...19add86db1.dll
----------------------------------------
b2489d91c4f14f05baa89b23a3020787
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...23a3020787.dll
----------------------------------------
9f98776c68d749399dfb59bef1d95d3a
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...bef1d95d3a.dll
----------------------------------------
f7e53eb5981d4405bc6780f3bc581786
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...f3bc581786.dll
----------------------------------------
1e035eacc77a4c8e8246e6dc4134375f
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...dc4134375f.dll
----------------------------------------
8d8dfdddf6fc4b85ab6cf0074a56bcfd
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...074a56bcfd.dll
----------------------------------------
515a19cba6a04ddd80ebbd0ec7af8405
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...0ec7af8405.dll
----------------------------------------
6f98aa7e81324438a2601de65bb83bec
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...e65bb83bec.dll
----------------------------------------
d5f9d69f25ec463a856d75ce5b5fe515
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...ce5b5fe515.dll
----------------------------------------
816ae768f91d4b99a141681510d34bdb
Assembly Version: 6.0.0.8
Win32 Version: 6.0.0.8
CodeBase: file:///C:/Documents%20and%20Setting...1510d34bdb.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Comment