On an ES 500 Volume Chart with a Secondary Series of 1 Volume we could never get the the two Series to Balance. In other words, when tracking the volume on the 1 Volume Series if never adds up to 500 which is the Primary Volume chart. The attached image is a png of the output window showing that the numbers do not balance. Maybe it is my computer or possibly I am suffering from a colossal case of Saturday morning cranial flatulence.
Any suggestions to cure this issue?
public class MTFVolumeQuestion : Indicator
{
private double BIP_1_VolumeCounter;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "MTFVolumeQuestion";
Calculate = Calculate.OnEachTick;
IsOverlay = false;
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.Orange, "VolumePlot");
}
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Volume, 1);
}
else if (State == State.DataLoaded)
{
ClearOutputWindow();
}
}
protected override void OnBarUpdate()
{
if(BarsInProgress == 0)
{
Print(string.Format("\r\nBIP_0 Volume {0} BIP_1_VolumeCounter {1}", Volume[0], BIP_1_VolumeCounter ));
if(IsFirstTickOfBar)
{
// Reset the BIP 1 (1 Volume) BIP_1_VolumeCounter to 0.
BIP_1_VolumeCounter = 0;
Print(string.Format("BIP 0: **** FirstTickOfBar {0:hh:mm:ss:fff tt} BIP_1_VolumeCounter {1,4}", Times[0][0], BIP_1_VolumeCounter ));
}
}
if(BarsInProgress == 1)
{
//Keep a running total of volume based on the 1 Volume Chart
BIP_1_VolumeCounter += Volume[0];
// This prints to many Lines.
// OutputWindow Error: You have reached the maximum threshold of the NinjaScript Output window. Some of your output messages have been suppressed.
// Can Uncomment and Print just the last few Bars
// Print(string.Format("BIP 1: {0:hh:mm:ss:fff tt} Vol 1: {1,4} BIP_1_VolumeCounter {2,3} ", Time[0], Volume[0], BIP_1_VolumeCounter ));
}
}
#region Properties
[Browsable(false)]
[XmlIgnore]
public Series<double> VolumePlot
{
get { return Values[0]; }
}
#endregion
}
Comment