Price is below Ninjacators VWAP indicator
MACD crosses above average
Go Long
namespace NinjaTrader.NinjaScript.Strategies { public class Crossover : Strategy { private MACD MACD1; private ncatSmartVWAP ncatSmartVWAP1; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @""; Name = "Crossover"; Calculate = Calculate.OnBarClose; EntriesPerDirection = 5; 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 = 20; // Disable this property for performance gains in Strategy Analyzer optimizations // See the Help Guide for additional information IsInstantiatedOnEachOptimizationIteration = true; } else if (State == State.Configure) { SetStopLoss("", CalculationMode.Ticks, StopLossTicks, false); } else if (State == State.DataLoaded) { MACD1 = MACD(12, 26, 9); ncatSmartVWAP1 = ncatSmartVWAP(Close); } } protected override void OnBarUpdate() { if (BarsInProgress != 0) return; if (CurrentBars[0] < 1) return; // Set 1 if (Close[0] < ncatSmartVWAP1[0]) { if ((CrossAbove(MACD1.Default, MACD1.Avg, 1))) { EnterLong(Convert.ToInt32(OrderQuantity), ""); }
"Indicator 'ncatSmartVWAP': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
Does anyone see what may be causing this?
Comment