#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
///
/// Enter the description of your new custom indicator here
///
[Description("Enter the description of your new custom indicator here")]
public class VPS : Indicator
{
#region Variables
TimeSpan timer;
private DataSeries volpersec;
#endregion
///
/// This method is used to configure the indicator and is called once before any bar data is loaded.
///
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Bar, "Plot0"));
Overlay = false;
}
///
/// Called on each bar update event (incoming tick)
///
protected override void OnBarUpdate()
{
if( CurrentBar < 1 )
return;
timer = Time[0] - Time[1];
totalseconds = (int)timer.TotalSeconds;
Plot0.Set (Volume [0]/totalseconds);
}
#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries Plot0
{
get { return Values[0]; }
}
#endregion
}
}
#region NinjaScript generated code. Neither change nor remove.
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
public partial class Indicator : IndicatorBase
{
private VPS[] cacheVPS = null;
private static VPS checkVPS = new VPS();
///
/// Enter the description of your new custom indicator here
///
///
public VPS VPS()
{
return VPS(Input);
}
///
/// Enter the description of your new custom indicator here
///
///
public VPS VPS(Data.IDataSeries input)
{
if (cacheVPS != null)
for (int idx = 0; idx < cacheVPS.Length; idx++)
if (cacheVPS[idx].EqualsInput(input))
return cacheVPS[idx];
lock (checkVPS)
{
if (cacheVPS != null)
for (int idx = 0; idx < cacheVPS.Length; idx++)
if (cacheVPS[idx].EqualsInput(input))
return cacheVPS[idx];
VPS indicator = new VPS();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
indicator.Input = input;
Indicators.Add(indicator);
indicator.SetUp();
VPS[] tmp = new VPS[cacheVPS == null ? 1 : cacheVPS.Length + 1];
if (cacheVPS != null)
cacheVPS.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheVPS = tmp;
return indicator;
}
}
}
}
// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
public partial class Column : ColumnBase
{
///
/// Enter the description of your new custom indicator here
///
///
[Gui.Design.WizardCondition("Indicator")]
public Indicator.VPS VPS()
{
return _indicator.VPS(Input);
}
///
/// Enter the description of your new custom indicator here
///
///
public Indicator.VPS VPS(Data.IDataSeries input)
{
return _indicator.VPS(input);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
///
/// Enter the description of your new custom indicator here
///
///
[Gui.Design.WizardCondition("Indicator")]
public Indicator.VPS VPS()
{
return _indicator.VPS(Input);
}
///
/// Enter the description of your new custom indicator here
///
///
public Indicator.VPS VPS(Data.IDataSeries input)
{
if (InInitialize && input == null)
throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
return _indicator.VPS(input);
}
}
}
#endregion