Trying to get an average volume per second by adding a PeriodType.Second,1 and then
using Volumes[1] / AvgPeriod (user defined). I tried putting the plot.set inside the If action shown as below and it still doesn't work.
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.SkyBlue), PlotStyle.Line, "VolAvgRate"));
Overlay = false;
//add a one second period type bars object
Add(PeriodType.Second,1);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Do not calculate if we don't have enough bars
if (CurrentBar < AvgPeriod) return;
// Calculate the volume per second(user defined Period) of the periodtype.second bars object
double volrate = 0;
if(BarsInProgress == 1)
{
volrate = Volumes[1][0] / AvgPeriod;
VolAvgRate.Set(volrate);
}
hmm, just thought of something. Maybe it is because there is no volume data provided on a per second basis.
Comment