I've duplicated the default SMA indicator without any modifications and renamed it SMADLL.. I've exported it as a compiled assembly without any type of confuscation or protection.. The export produces SMADLL.dll and SMADLL.cs.. I've then copy'd and modified the default SampleMACrossOver strategy to use the new SMADLL indicator instead of the default SMA, and exported it as a normal cs file named SampleSMADLLCrossOver.cs .. I've also thrown in a couple print statements in the strat so that you can see what if any errors are happening..
All this was done under B3... Now on a Virtual Machine for testing purposes, with B3 installed as well.. I've imported both the above indicator and strat, as well as added the SMADLL into the references.. Now I open a new strategy analyzer and do a standard backtest using the SampleSMADLLCrossOver on a CL 08-15 1min chart, all default settings, while connected to Kinetick.. So far everything works fine..
Now, I change the BackTest type from Standard to Optimization, modify the Fast parameter to 10:20:1 and try to run it again.. At this point it does run the first backtest for Fast 10, but on all subsequent test 11-20 I get this printed in the output window..
------------------
System.NullReferenceException: Object reference not set to an instance of an object.
at NinjaTrader.NinjaScript.Indicators.Indicator.SMADL L(ISeries`1 input, Int32 period)
at NinjaTrader.NinjaScript.Strategies.SampleSMADLLCro ssOver.OnStateChange()
Object reference not set to an instance of an object.
------------------
Running this same strat the exact same way on the machine that has the SMADLL as a cs file works just fine.. It's only the machine that is using the dll that has the problem..
I've combined and included all the code in an importable zip file below. Import it into NT8 B3 as you would any script.. By importing this, it will add the SampleSMADLLCrossOver strategy to the strategies folder, the SMADLL dll and cs file to the custom folder, and will also automatically add the SMADLL as a reference without needing to do so thru the NSEditor...
Again, Please be Aware by importing this file, It does contain a will install a non protected DLL file and will add a reference to it!
Please Advise!
Comment