I have developed a very simple Indicator, which input might not be set on some bars, so I use IsValidPlot(CurrentBar) to figure this out:
protected override void OnBarUpdate()
{
if (Input.IsValidPlot(CurrentBar))
{
PriceLevel.Set( Input[0] );
}
}
I use this indicator using DataSeries as input, for example:
private DataSeries aTestSeries;
// ...
// in Initialize() :
//
aTestSeries = new DataSeries( this, MaximumBarsLookBack.TwoHundredFiftySix);
Add( VerySimpleIndicator( aTestSeries ) );
// ...
// In OnBarUpdate() :
//
if (condition)
aTestSeries.Set( Close[0] );
VerySimpleIndicator( aTestSeries )
The above doesn't work correctly, meaning in the indicator Input.IsValidPlot(CurrentBar) is always true.
However, if I create the aTestSeries using an infinite size, it works perfectly :
private DataSeries aTestSeries;
// ...
// in Initialize() :
//
aTestSeries = new DataSeries( this, MaximumBarsLookBack.Infinite);
Add( VerySimpleIndicator( aTestSeries ) );
// ...
// In OnBarUpdate() :
//
if (condition)
aTestSeries.Set( Close[0] );
VerySimpleIndicator( aTestSeries )
Of course, at this time this is what I have done, however in the long run I do not want to waste "infinite" amount of memories when a small size DataSeries object would do. I smell there is a bug somewhere in NinjaScript.
Comment