The problem is that another indicator now only works on those charts with calculate on bar close. If it's set to update on every tick (with tick replay) it produces rubbish.
I apologize if this is something really basic. I'm new to coding.
public class Locations : Indicator { private int Zero; private Brush Brush1; private Brush Brush2; private Brush Brush3; private Brush Brush4; private Brush Brush5; private Brush Brush6; private EMA EMA1; private EMA EMA2; private MABandsFixed MABandsFixed1; private NinjaTrader.NinjaScript.Indicators.GomPro.GomCD GomCD1; private EMA EMA3; private MABandsFixed MABandsFixed2; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionSMA; Name = "Locations"; IsOverlay = false; IsSuspendedWhileInactive = false; Zero = 0; } else if (State == State.Configure) { Brush1 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF3D0603")); Brush1.Freeze(); Brush2 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF1F3954")); Brush2.Freeze(); Brush3 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF3D0603")); Brush3.Freeze(); Brush4 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF1F3954")); Brush4.Freeze(); Brush5 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF1F3954")); Brush5.Freeze(); Brush6 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF3D0603")); Brush6.Freeze(); } else if (State == State.DataLoaded) { EMA1 = EMA(Close, 20); EMA2 = EMA(Close, 60); MABandsFixed1 = MABandsFixed(Close, 1.5, 1, 20); GomCD1 = GomCD(Close, Gom.DeltaLib.DeltaCalcType.BidAsk, true, -1, 0, Gom.CumulativeDelta.ChartType.CumulativeChart, false); EMA3 = EMA(GomCD1.DeltaClose, 20); MABandsFixed2 = MABandsFixed(Close, 1.5, 1, 60); } } protected override void OnBarUpdate() { { if (BarsInProgress != 0) return; // Set 1 if ((Close[0] < EMA1[0]) && (Close[0] < Open[0]) && (Close[0] < EMA2[0])) { BackBrushAll = Brush1; } // Set 2 if ((Close[0] > EMA1[0]) && (Close[0] > Open[0]) && (Close[0] > EMA2[0])) { BackBrushAll = Brush2; } //Set 3 if ((Close[0] > MABandsFixed1.Upper[0]) && (Close[0] < Open[0]) && (GomCD1.DeltaClose[0] < EMA3[0])) { BackBrushAll = Brush3; } //Set 4 if ((Close[0] < MABandsFixed1.Lower[0]) && (Close[0] > Open[0]) && (GomCD1.DeltaClose[0] > EMA3[0])) { BackBrushAll = Brush4; } //Set 5 if ((Close[0] > Open[0]) && (Close[0] < MABandsFixed2.Lower[0]) && (Close[0] > EMA1[0])) { BackBrushAll = Brush5; } //Set 6 if ((Close[0] > MABandsFixed2.Upper[0]) && (Close[0] < Open[0]) && (Close[0] < EMA1[0])) { BackBrushAll = Brush6; } }
Comment