i was trying to change BandWidth from points to ticks - i can't figure out what i need to make it work....
i tried changing [Range(1, int.MaxValue)]
to [Range(1, double.MaxValue)]
but that didn't work - maybe wrong syntax
i also tried to define a private double bandWidth = 9 * TickSize;
but i got another different compile error....
??
/wes
public class RangeMedianTicBands : Indicator { private MAX max; private MIN min; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Indicator here."; Name = "RangeMedianTicBands"; Calculate = Calculate.OnPriceChange; IsOverlay = true; IsAutoScale = false; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; IsSuspendedWhileInactive = true; Period = 20; BandWidth = 2; /// needs to be * TickSize; but getting implicit convert error AddPlot(Brushes.Yellow, "TopBand"); AddPlot(Brushes.Yellow, "Median"); AddPlot(Brushes.Yellow, "BottomBand"); } else if (State == State.DataLoaded) { max = MAX(High, Period); min = MIN(Low, Period); } } protected override void OnBarUpdate() { double max0 = max[0]; double min0 = min[0]; Median[0] = (max0 + min0) / 2; TopBand[0] = ((max0 + min0) / 2 + BandWidth); BottomBand[0] = ((max0 + min0) / 2 - BandWidth); } #region Properties [NinjaScriptProperty] [Range(1, int.MaxValue)] [Display(Name="Period", Order=1, GroupName="Parameters")] public int Period { get; set; } [NinjaScriptProperty] [Range(1, int.MaxValue)] [Display(Name="BandWidth", Order=2, GroupName="Parameters")] public int BandWidth { get; set; } [Browsable(false)] [XmlIgnore] public Series<double> TopBand { get { return Values[0]; } } [Browsable(false)] [XmlIgnore] public Series<double> Median { get { return Values[1]; } } [Browsable(false)] [XmlIgnore] public Series<double> BottomBand { get { return Values[2]; } }
Comment