I'm a software developer but relatively new to NinjaTrader.
I have a custom indicator which is working correctly on a chart,
And that performed correctly from a strategy a couple of days ago
(Put out results on strategy analyzer, entered trades correctly etc.)
A day passed, and I went back to run the strategy in strategy analyzer after further development and the custom indicator included In it, and I run into the Object Reference not set to an instance of an object.(only internal logic of the strategy itself was added,nothing was changed in regards to instantiating indicators)
Further investigation revealed that the OnStartUp method of my custom indicators
Are no longer getting fired when called from the strategy, and therefore it's public Members are not getting instantiated, leading to Object Reference not set to an instance of an object when called upon from the containing strategy
The strategy itself is a MTF strategy.
I use visual studio for developing and debugging, and it's really easy to see that everytime I'm creating an instance custom indicator from a strategy, it's not hitting the OnStartUp() method even once. again, I'd like to remind that independently on a chart, all of my custom indicators work properly
My custom Indicator doesn't plot anything, so I haven't added it using the Add() method (although i tried adding the custom indicators using the Add() methond as well, it didn't changed anything)
To the strategy, again, reminding you that this approach worked fine just a day before..
I also noticed that when I'm trying to create an instance of my custom indicator from the immediate window in visual studio with the scope of the strategy, it's output is
the type <my custom indicator> exists both in '1'.dll and '2'.dll meaning that
Ninja trader creates two dll containing the same type.
it still give me back an instance of my custom indicator, but it's members which are not primitive types are not instantiated (meaning that OnStartUp of the indicator wasn't fired,
where all of the system indicators are instantiated for my custom indicator)
Trying to clean and rebuild didn't change this situation,
Trying to delete one of the dll's in the ninjatrader bin folder didn't changed.
upon creating the customer indicator using:
MyCustomerIndicator _customIndicator = new MyCustomIndicator()
I see that all public members of _customIndicator which are not primitive types
(meaning indicators themselves, system indicators like the SMA or Stochastics)
are instantiated and are not null
but trying to do something like:
_customIndicator.SMA[0] leads to index out of bounds exception.
Upon further invastigating I've noticed that the Values collection of the custom Indicator are not getting passed from the strategy to the custom indicator, regardless of passing a
BarsArray[x] or not. (it's an MTF strategy) meaning that doing
var x = new CustomerIndicator()
or
var x = new CustomerIndicator(BarsArray[1])
makes no difference.
I've also tried to create a constructor to accept an IDataSeries object
and to send explicitly a BarsArray[0] and to accept it into the Input property of the
Custom indicator. again - doesn't matter.
I'll be very happy to set up a remote session with you guys.
Please help.
Waiting for you guys to respond so i can send you code example, trace and log files to an email address..
Comment