// This namespace holds all indicators and is required. Do not change it.
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 RMHighLow : Indicator
{
#region Variables
// Wizard generated variables
private double high = 0; // Default setting for High
private double low = 0; // Default setting for Low
// 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.Khaki), PlotStyle.Line, "High1"));
Add(new Plot(Color.FromKnownColor(KnownColor.Khaki), PlotStyle.Line, "Low1"));
Overlay = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
High1.Set(High[0]);
Low1.Set(Low[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 High1
{
get { return Values[0]; }
}
[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 Low1
{
get { return Values[1]; }
}
[Description("")]
[GridCategory("Parameters")]
public double High
{
get { return high; }
set { high = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public double Low
{
get { return low; }
set { low = 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 RMHighLow[] cacheRMHighLow = null;
private static RMHighLow checkRMHighLow = new RMHighLow();
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public RMHighLow RMHighLow(double high, double low)
{
return RMHighLow(Input, high, low);
}
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public RMHighLow RMHighLow(Data.IDataSeries input, double high, double low)
{
if (cacheRMHighLow != null)
for (int idx = 0; idx < cacheRMHighLow.Length; idx++)
if (Math.Abs(cacheRMHighLow[idx].High - high) <= double.Epsilon && Math.Abs(cacheRMHighLow[idx].Low - low) <= double.Epsilon && cacheRMHighLow[idx].EqualsInput(input))
return cacheRMHighLow[idx];
lock (checkRMHighLow)
{
checkRMHighLow.High = high;
high = checkRMHighLow.High;
checkRMHighLow.Low = low;
low = checkRMHighLow.Low;
if (cacheRMHighLow != null)
for (int idx = 0; idx < cacheRMHighLow.Length; idx++)
if (Math.Abs(cacheRMHighLow[idx].High - high) <= double.Epsilon && Math.Abs(cacheRMHighLow[idx].Low - low) <= double.Epsilon && cacheRMHighLow[idx].EqualsInput(input))
return cacheRMHighLow[idx];
RMHighLow indicator = new RMHighLow();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
indicator.Input = input;
indicator.High = high;
indicator.Low = low;
Indicators.Add(indicator);
indicator.SetUp();
RMHighLow[] tmp = new RMHighLow[cacheRMHighLow == null ? 1 : cacheRMHighLow.Length + 1];
if (cacheRMHighLow != null)
cacheRMHighLow.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheRMHighLow = 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.RMHighLow RMHighLow(double high, double low)
{
return _indicator.RMHighLow(Input, high, low);
}
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public Indicator.RMHighLow RMHighLow(Data.IDataSeries input, double high, double low)
{
return _indicator.RMHighLow(input, high, low);
}
}
}
// 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.RMHighLow RMHighLow(double high, double low)
{
return _indicator.RMHighLow(Input, high, low);
}
/// <summary>
/// Enter the description of your new custom indicator here
/// </summary>
/// <returns></returns>
public Indicator.RMHighLow RMHighLow(Data.IDataSeries input, double high, double low)
{
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.RMHighLow(input, high, low);
}
}
}
#endregion
When I try to compile this, it keeps on complaining Cannot apply indexing with [] to an expression of type double. CS 0021. (for the highlighted lines)
I cant understand whats wrong. Its exactly as other indicators like PriceOHLC are doing. Any pointers as to how to fix this?
Appreciate all the help!!!
Comment