Indicator 'MainTrendAnalisys': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
i see you the structure of my program
MaintrendAnalisys indicator (OnStateChange)
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "MainTrendAnalisys";
Calculate = Calculate.OnBarClose;
IsOverlay = false;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
AddPlot(Brushes.Green, "ContaMtUp");
AddPlot(Brushes.Red, "ContaMtDown");
AddPlot(new Stroke(Brushes.Green, 1), PlotStyle.Bar, "Mt");
AddPlot(new Stroke(Brushes.Transparent, 3), PlotStyle.Dot, "CicliWilliam");
AddPlot(new Stroke(Brushes.Transparent, 4), PlotStyle.Dot, "CicliWilliamBreve");
AddPlot(new Stroke(Brushes.Transparent, 5), PlotStyle.Dot, "CicliWilliamMedio");
AddPlot(new Stroke(Brushes.Transparent, 6), PlotStyle.Dot, "CicliWilliamLungo");
Plotfc = Fc.Nessuno;
DrawBArExtreme = Fc.Nessuno;
anticipoBarDur = 0;
CountMt = false;
}
else if (State == State.Configure)
{
Mt = new MT(this);
mtClass = new MT.MTClass();
LPT = new proiezTempo(Mt);
Mp = new Gestione_Mt_Profit(Mt);
cicliLarry = new cicliLarryWilliam(Mt);
Mt.Add(mtClass);
zarranum = new List<double>();
zarrapos = new List<double>();
arranum = new List<double>();
myFont = new NinjaTrader.Gui.Tools.SimpleFont("Courier New", 12) { Size = dimFont, Bold = false }; //15
myFont2 = new NinjaTrader.Gui.Tools.SimpleFont("Courier New", 9) { Size = 9, Bold = false };
myFont3 = new NinjaTrader.Gui.Tools.SimpleFont("Courier New", 12) { Size = 50, Bold = false };
myFont4 = new NinjaTrader.Gui.Tools.SimpleFont("Verdana", 10) { Size = 11, Bold = false };
Historical = State == State.Historical; //da cancellare..e' per uso interno
textOffset = offset * Instrument.MasterInstrument.TickSize;
}
My Strategy
{
private MainTrendAnalisys main;
...
....
else if (State == State.Configure)
{
main = MainTrendAnalisys(3);
}
}
protected override void OnBarUpdate()
{
main.Update();
...
....
Comment