namespace NinjaTrader.Indicator
{
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
[Description("Enter the description of your new custom indicator here")]
public class highVR : Indicator
{
#region Variables
// Wizard generated variables
private double vR1 = 1.7; // Default setting for VR1
private double vR2 = 1.3; // Default setting for VR2
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Bar, "Plot0"));
Overlay = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Set the value
Plot0.Set(High[0] > High[1]
&& Low[0] > Low[1]
&& Close[0] > Close[1]
&& Close[0] > Open[0]
&& Volume[0] > Volume[1] * VR1
&& Volume[0] > Volume[2] * VR2? 1 : 0);
}
#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]; }
}
[Description("")]
[GridCategory("Parameters")]
public double VR1
{
get { return vR1; }
set { vR1 = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public double VR2
{
get { return vR2; }
set { vR2 = Math.Max(1, value); }
}
#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 highVR[] cachehighVR = null;
private static highVR checkhighVR = new highVR();
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public highVR highVR(double vR1, double vR2)
{
return highVR(Input, vR1, vR2);
}
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public highVR highVR(Data.IDataSeries input, double vR1, double vR2)
{
if (cachehighVR != null)
for (int idx = 0; idx < cachehighVR.Length; idx++)
if (Math.Abs(cachehighVR[idx].VR1 - vR1) <= double.Epsilon && Math.Abs(cachehighVR[idx].VR2 - vR2) <= double.Epsilon && cachehighVR[idx].EqualsInput(input))
return cachehighVR[idx];
lock (checkhighVR)
{
checkhighVR.VR1 = vR1;
vR1 = checkhighVR.VR1;
checkhighVR.VR2 = vR2;
vR2 = checkhighVR.VR2;
if (cachehighVR != null)
for (int idx = 0; idx < cachehighVR.Length; idx++)
if (Math.Abs(cachehighVR[idx].VR1 - vR1) <= double.Epsilon && Math.Abs(cachehighVR[idx].VR2 - vR2) <= double.Epsilon && cachehighVR[idx].EqualsInput(input))
return cachehighVR[idx];
highVR indicator = new highVR();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
indicator.Input = input;
indicator.VR1 = vR1;
indicator.VR2 = vR2;
Indicators.Add(indicator);
indicator.SetUp();
highVR[] tmp = new highVR[cachehighVR == null ? 1 : cachehighVR.Length + 1];
if (cachehighVR != null)
cachehighVR.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cachehighVR = 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
{
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.highVR highVR(double vR1, double vR2)
{
return _indicator.highVR(Input, vR1, vR2);
}
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public Indicator.highVR highVR(Data.IDataSeries input, double vR1, double vR2)
{
return _indicator.highVR(input, vR1, vR2);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.highVR highVR(double vR1, double vR2)
{
return _indicator.highVR(Input, vR1, vR2);
}
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public Indicator.highVR highVR(Data.IDataSeries input, double vR1, double vR2)
{
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.highVR(input, vR1, vR2);
}
}
}
#endregion
Comment