Hello everyone, there was a task to implement loading of days in the indicator regardless of the chart
Using an additional data series with a time pattern (I added data series)
AddDataSeries(Instrument.FullName, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1 }, "Forex");
if (BarsInProgress == 1)
if (BarsInProgress == 0)
{
Values[0][0] = (iCumTypicalVolume / iCumVolume);
}
}
Thanks in advance.
Here is my indicator code
namespace 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 = false;
DrawOnPricePanel = false;
DrawHorizontalGridLines = false;
DrawVerticalGridLines = false;
PaintPriceMarkers = false;
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(new Stroke(Brushes.SpringGreen, DashStyleHelper.Solid, 5), PlotStyle.Line, "VWAP");
}
else if (State == State.Configure)
{
AddDataSeries(Instrument.FullName, new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1 }, "Forex");
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 1)
{
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));
}
}
if (BarsInProgress == 0)
{
Values[0][0] = (iCumTypicalVolume / iCumVolume);
}
}
#region Properties
[Browsable(false)]
[XmlIgnore]
public Series<double> PlotVWAP
{
get { return Values[0]; }
}
#endregion
}
}

Comment