**NT** Error on calling 'OnStartUp' method for strategy 'PivotPlay/d93c1269d8904ff99817bfaa496ee2a4': Object reference not set to an instance of an object.
When i moved the code to OnBarUpdate method i get the following:
**NT** Error on calling 'OnBarUpdate' method for strategy 'PivotPlay/d93c1269d8904ff99817bfaa496ee2a4': Object reference not set to an instance of an object.
i only get the error when i try to enable the strategy. Any help would be appreciated.
Here is the code
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
///<summary>
/// this is a strategythat uses pivot points and support / resistance levels to set exit and entry points
///</summary>
[Description("this is a strategythat uses pivot points and support / resistance levels to set exit and entry points")]
publicclass PivotPlay : Strategy
{
#region Variables
// Wizard generated variables
privatedouble pct = 0.005; // Default setting for Pct
// User defined variables (add any user defined variables below
privatebool firstTime;
privatebool islong;
privatedouble pvtu;
privatedouble pvtl;
privatedouble rl1u;
privatedouble rl1l;
privatedouble rl2u;
privatedouble rl2l;
privatedouble rl3u;
privatedouble rl3l;
privatedouble sl1u;
privatedouble sl1l;
privatedouble sl2u;
privatedouble sl2l;
privatedouble sl3u;
privatedouble sl3l;
privatedouble pvt;
privatedouble rl1;
privatedouble rl2;
privatedouble rl3;
privatedouble sl1;
privatedouble sl2;
privatedouble sl3;
privatedouble prevDayClose;
privatedouble prevDayHigh;
privatedouble prevDayLow;
#endregion
///<summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
///</summary>
protectedoverridevoid Initialize()
{
firstTime = false;
islong = false;
CalculateOnBarClose = true;
}
protectedoverridevoid OnStartUp()
{
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
if(Bars.FirstBarOfSession && FirstTickOfBar)
{
prevDayClose = Bars.GetDayBar(1).Close;
prevDayHigh = Bars.GetDayBar(1).High;
prevDayLow = Bars.GetDayBar(1).Low;
pvt = (prevDayClose + prevDayHigh + prevDayLow) / 3;
pvtu = pvt + (pvt * pct);
pvtl = pvt - (pvt * pct);
rl1u = rl1 + (rl1 * pct);
rl1l = rl1 - (rl1 * pct);
rl2u = rl2 + (rl2 * pct);
rl2l = rl2 - (rl2 * pct);
rl3u = rl3 + (rl3 * pct);
rl3l = rl3 - (rl3 * pct);
sl1u = sl1 + (sl1 * pct);
sl1l = sl1 - (sl1 * pct);
sl2u = sl2 + (sl2 * pct);
sl2l = sl2 - (sl2 * pct);
sl3u = sl3 + (sl3 * pct);
sl3l = sl3 - (sl3 * pct);
}
/// Rule 1; enter long if close above first bar high...;
if (Bars.FirstBarOfSession)
{ return;
}
else
{ int barOne = Bars.BarsSinceSession;
if (Close[0] > High[barOne])
{
islong = true;
firstTime = true;
EnterLong("Entry");
}
}
/// rule 2;
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
publicdouble Pct
{
get { return pct; }
set { pct = Math.Max(0.001, value); }
}
#endregion
}
}

Comment