I found the following code for a VWAP indicator.
I want to reset this, say every hour, instead of day, any idea how to go about it?
========================
amespace NinjaTrader.NinjaScript.Indicators
{
public class VWAP8 : Indicator
{
double iCumVolume = 0;
double iCumTypicalVolume = 0;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Volume Weighted Average Price";
Name = "VWAP8";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
AddPlot(Brushes.Black, "PlotVWAP");
}
}
protected override void OnBarUpdate()
{
if (Bars.IsFirstBarOfSession)
{
iCumVolume = VOL()[0];
iCumTypicalVolume = VOL()[0] * ((High[0] + Low[0] + Close[0]) / 3);
}
else
{
iCumVolume = iCumVolume + VOL()[0];
iCumTypicalVolume = iCumTypicalVolume + (VOL()[0] * ((High[0] + Low[0] + Close[0]) / 3));
}
PlotVWAP[0] = (iCumTypicalVolume / iCumVolume);
}
=====================
Thanks

Comment