Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Second Entries Strategy"; Name = "SecEntryStrat"; Calculate = Calculate.OnEachTick; EntriesPerDirection = 1; EntryHandling = EntryHandling.AllEntries; IsExitOnSessionCloseStrategy = true; ExitOnSessionCloseSeconds = 30; IsFillLimitOnTouch = false; MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix; OrderFillResolution = OrderFillResolution.Standard; Slippage = 0; StartBehavior = StartBehavior.WaitUntilFlat; TimeInForce = TimeInForce.Gtc; TraceOrders = false; RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose; StopTargetHandling = StopTargetHandling.PerEntryExecution; BarsRequiredToTrade = 5; // Disable this property for performance gains in Strategy Analyzer optimizations // See the Help Guide for additional information IsInstantiatedOnEachOptimizationIteration = true; #region Default Settings UseTPByATR = true; ATRPeriod = 14; All2Entries = false; // ProfitTarget = 25; // PositionSize = 1; BounceEMAPeriod = 21; FilterEMAPeriod = 89; UseFilterEMA = false; UseBounceOnly = true; IsEMARisingFalling = false; LimitRisk = 100; StopLossOffset = 2; EntryOffSet = 2; DistEMAToSignal = 15; Start = DateTime.Parse("08:35", System.Globalization.CultureInfo.InvariantCulture); End = DateTime.Parse("15:00", System.Globalization.CultureInfo.InvariantCulture); TickOffsetTrail = 1; TrailTriggerAmount = 20; //Breakeven BreakevenTriggerAmount = 10; //Daily Limits DailyProfitLimit = 2000; DailyLossLimit = 2000; X = 50; //Position Size PositionSize = 1; ProfitTargetTicks = 50; StopLossTicks = 50; //User Option to set the following FixedStopLoss = false; DynamicStopLoss = true; ProfitTarget = false; SetBreakeven = false; SetTrail = false; OHLFilter = true; countOnce = true; //Prints to Output SystemPrint = true; #endregion } else if (State == State.Configure) { } //Not part of the strategy. else if (State == State.DataLoaded) { ClearOutputWindow(); //Clears Output window every time strategy is enabled _patsIndicator = TDUPriceAction(Close, TDUPatsRules.Mack, false, TDUPatsTradeManagement.Internal,0, 2, 95, 2, TDUPATSPositionSizing.Contracts, 1, 200, 1, 1, TDUPATSPositionSizingRunner.None, 1, 1, 1, 1, "[email protected]", 00000000000); _patsIndicator.Show01 = true; _patsIndicator.ShowTraps = false; _patsIndicator.ShowSLTP = true; AddChartIndicator(_patsIndicator); slShort = new Series<double>(this); slLong = new Series<double>(this); // signalBarStrengthShort = new Series<double>(this); // signalBarStrengthLong = new Series<double>(this); // trapShort = new Series<double>(this); // trapLong = new Series<double>(this); atrIndicator = ATR(ATRPeriod); bounceEMA = EMA(BounceEMAPeriod); filterEMA = EMA(FilterEMAPeriod); currentSHigh = CurrentDayOHL(Close); currentSLow = CurrentDayOHL(Close); } else if (State == State.Realtime) { if (ChartControl != null && !IsToolBarButtonAdded) { var unused1 = ChartControl.Dispatcher.InvokeAsync(() => { AddButtonToToolbar(); }); } } else if (State == State.Terminated) { if (chartWindow != null) { var unused = ChartControl.Dispatcher.InvokeAsync(() => { DisposeCleanUp(); }); } } }
Comment