Kindly seeking assistance to create the 21 day Intraday Intensity volume indicator on NT8. I referred to previous posts on this site where the indicator was developed in earlier versions of NT. I attempted to convert the code to NT8 and it is compiling without errors. However, when I add the indicator to a chart, it returns nil values or blanks. Please tell me where I am going wrong. I have attached the cs file for your reference. Please help.
public class bbIIPercent : Indicator
{
#region Variables
private Series<double> IntensityAccumulator;
private Series<double> VolumeAccumulator;
#endregion
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Volume indicator description";
Name = "bbIIPercent";
IsSuspendedWhileInactive = true;
DrawOnPricePanel = false;
AddPlot(new Stroke(Brushes.MediumBlue, 3), PlotStyle.Bar, "IINorm");
AddLine(Brushes.Red, 0, NinjaTrader.Custom.Resource.NinjaScriptIndicatorZe roLine);
}
else if (State == State.Historical)
{
if (Calculate == Calculate.OnPriceChange)
{
Draw.TextFixed(this, "NinjaScriptInfo", string.Format(NinjaTrader.Custom.Resource.NinjaScr iptOnPriceChangeError, Name), TextPosition.BottomRight);
Log(string.Format(NinjaTrader.Custom.Resource.Ninj aScriptOnPriceChangeError, Name), LogLevel.Error);
}
}
}
protected override void OnBarUpdate()
{
double high0 = High[0];
double low0 = Low[0];
double close0 = Close[0];
double open0 = Open[0];
IntensityAccumulator[0] = ((((2*close0)-high0-low0)/(high0-low0+0.000001))*Volume[0]);
VolumeAccumulator[0] = Volume[0];
double IIntensity = SUM(IntensityAccumulator, 21)[0];
double INormalized = SUM(VolumeAccumulator, 21)[0];
IINorm[0] = ((IIntensity/INormalized)*100);
}
#region Properties
[Browsable(false)]
[XmlIgnore()]
public Series<double> IINorm
{
get { return Values[0]; }
}
#endregion
}
}
Comment