Time Category Message
5/28/18 4:55:37 PM Default Fill type 'Default fill type': Error on calling 'OnBar' method: System.NullReferenceException: Object reference not set to an instance of an object. at NinjaTrader.NinjaScript.StrategyBase.AddExecution( Position position, Execution execution, Order order) at NinjaTrader.NinjaScript.StrategyBase.FillOrder(Ord er order, Double fillPrice, Double slippage) at NinjaTrader.NinjaScript.DefaultFillType.OnBar() at NinjaTrader.NinjaScript.StrategyBase.ProcessBackte stOrders()
I believe it is related to this line of code because when I comment it out everything runs fine (minus the actual trades):
EnterLongLimit(0, false, 1, GetCurrentAsk(), signal);
Here's the entire OnBarUpdate section if it's helpful.
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade)
return;
// OnBarUpdate() will be called on incoming tick events on all Bars objects added to the strategy
// We only want to process events on our primary Bars object (main instrument) (index = 0) which
// is set when adding the strategy to a chart
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 0)
return;
// Checks if the RSI is crossing below or above
buySignal = CrossAbove(rsi, BuyCross, 1);
if (buySignal)
{
Print("Buycross"+rsi[0]);
// Draws a square 1 tick above the high of the bar identifying when a limit order is issued
Draw.Square(this, "My Square" + CurrentBar, false, 0, High[0] + TickSize, Brushes.DodgerBlue);
// Enter a long position via a limit order at the current ask price
signal = ("Buy Limit"+ CurrentBar.ToString());
Print(signal);
EnterLongLimit(0, false, 1, GetCurrentAsk(), signal);
}
SetProfitTarget(signal, CalculationMode.Ticks,BuyProfitTarget);
SetStopLoss(signal,CalculationMode.Ticks,BuyStopLo ss,true);
}
Please let me know if there's any other info I can provide. Thanks.
Comment