I'm learning to write Ninjascrpts, These forum posts have been very helpful.
I'm looking to plot avg daily volume in the chart. I have a 1 Min and in that I need to plot to avg daily volume for the last 30 days (multi-time frame indicator)
Here's what I have... but it won't plot
public class MyVOL : Indicator
{
#region Variables
private int days1 = 30; // Default setting for Period
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.OrangeRed), PlotStyle.Line, "Plot0"));
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = false;
// Add Daily Bars object - BarsInProgress index = 1
Add(PeriodType.Day, Days1);
}
protected override void OnBarUpdate()
{
if (BarsInProgress == 1 )
return;
// Calculate the volume average
double average = SMA(VOL(BarsArray[1]), Days1) [0];
double average = SMA(Volumes[1], Days1)[0];
double average = VOLMA(BarsArray[1], Days1)[0];
Print("The current SMA value is " + average.ToString());
Plot0.Set(average);
}
____
I've tried different options in //Calcualte the volume average section above.
It give me "Error on calling 'OnBarUpdate' method for indicator 'AAeSPVOL' on bar 0" error.
Could someone please look into this.
Thanks,
Mike
Comment