I am coding a custom range bar type that will close each bar only if a simple indicator condition is met. The indicator is run with CalculateOnBarClose = false.
The challenges I face are constructing and assigning values to an indicator from the NinjaTrader.Data namespace (rather than from NinjaTrader.Strategy or NinjaTrader.Indicator).
From within the range bar’s Add() method, which is called tick by tick, I can construct the indicator, as follows:
NinjaTrader.Indicator.MyIndicator myIndicator = NinjaTrader.Indicator.MyIndicator();
myIndicator.Period = this.Period;
DataSeries barCloses = new DataSeries(myIndicator);
If (bars.Count > 1) {[INDENT]for (int i = 0; 1 < bars.Count; i++) {[INDENT]Bar bar = (Bar) bars.Get(i); barCloses.Set(bar.Close);[/INDENT] } myIndicator.RequiredDataSeries = barCloses;[/INDENT] }
double myIndicatorAPublicProperty = myIndicator.APublicProperty;
But the code doesn’t do as I expect it to!
I suspect I am not constructing (or loading) the indicator object correctly (although of course there could also be other problems!).
Can you see anything obviously wrong with the above approach?
Please don't respond simply that this is not supported ...
Many thanks.
Comment