PDA

View Full Version : Failed to call method 'Initialize'


daven
07-29-2010, 08:19 PM
I downloaded an indicator from a forum which appears to work just fine. the code is open and I can look at it. However, I keep getting the following message in the log file:

"Failed to call method 'Initialize' for indicator BTAutoPivots.' Object reference not set to an instance of an object."

What kind of thing should I be looking for in the code that might cause this kind of message? It doesn't seem to be affecting the performance of the indicator itself but how would I know. other than it doesn't work at all?

I'm adding the first part of the code and it clearly does have an initialization section.

Thanks
DaveN
#region Variables
// Wizard generated variables
private string contractExpDate = "SEP10"; // Default setting for ContractExpDate
private int numDecimals = 2;
// User defined variables (add any user defined variables below)
private SolidBrush[] brushes =
{ new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black),
new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black),
new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black)
};
private StringFormat stringFormatFar = new StringFormat();
private StringFormat stringFormatNear = new StringFormat();
private SolidBrush textBrush = new SolidBrush(Color.Black);
private Font textFont = new Font("Arial", 30);
private string errorData = "Insufficient historical data to calculate pivots. Increase chart look back period (days back).";
private float errorTextWidth = 0;
private float errorTextHeight = 0;
private int width = 20;
double pp, yopen, yclose, yhigh, ylow, s1, s2, s3, s4, r1, r2, r3, r4;
#endregion

/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Gold), PlotStyle.Line, "PP"));
Add(new Plot(Color.FromKnownColor(KnownColor.Violet), PlotStyle.Line, "Y_High"));
Add(new Plot(Color.FromKnownColor(KnownColor.Violet), PlotStyle.Line, "Y_Low"));
Add(new Plot(Color.FromKnownColor(KnownColor.Cyan), PlotStyle.Line, "Y_Close"));
Add(new Plot(Color.FromKnownColor(KnownColor.DarkCyan), PlotStyle.Line, "S1"));
Add(new Plot(Color.FromKnownColor(KnownColor.Chartreuse), PlotStyle.Line, "S2"));
Add(new Plot(Color.FromKnownColor(KnownColor.DarkRed), PlotStyle.Line, "S3"));
Add(new Plot(Color.FromKnownColor(KnownColor.DarkViolet), PlotStyle.Line, "S4"));
Add(new Plot(Color.FromKnownColor(KnownColor.DarkCyan), PlotStyle.Line, "R1"));
Add(new Plot(Color.FromKnownColor(KnownColor.Chartreuse), PlotStyle.Line, "R2"));
Add(new Plot(Color.FromKnownColor(KnownColor.DarkRed), PlotStyle.Line, "R3"));
Add(new Plot(Color.FromKnownColor(KnownColor.DarkViolet), PlotStyle.Line, "R4"));

Plots[0].Pen = new Pen(Color.Gold, 2); Plots[0].Pen.DashStyle = DashStyle.Solid;
Plots[1].Pen = new Pen(Color.Violet, 2); Plots[1].Pen.DashStyle = DashStyle.Dash;
Plots[2].Pen = new Pen(Color.Violet, 2); Plots[2].Pen.DashStyle = DashStyle.Dash;
Plots[3].Pen = new Pen(Color.Cyan, 2); Plots[3].Pen.DashStyle = DashStyle.Dash;
Plots[4].Pen = new Pen(Color.DarkCyan, 2); Plots[4].Pen.DashStyle = DashStyle.Solid;
Plots[5].Pen = new Pen(Color.Chartreuse, 2); Plots[5].Pen.DashStyle = DashStyle.Solid;
Plots[6].Pen = new Pen(Color.DarkRed, 2); Plots[6].Pen.DashStyle = DashStyle.Solid;
Plots[7].Pen = new Pen(Color.DarkViolet, 2); Plots[7].Pen.DashStyle = DashStyle.Solid;
Plots[8].Pen = new Pen(Color.DarkCyan, 2); Plots[8].Pen.DashStyle = DashStyle.Solid;
Plots[9].Pen = new Pen(Color.Chartreuse, 2); Plots[9].Pen.DashStyle = DashStyle.Solid;
Plots[10].Pen = new Pen(Color.DarkRed, 2); Plots[10].Pen.DashStyle = DashStyle.Solid;
Plots[11].Pen = new Pen(Color.DarkViolet, 2); Plots[11].Pen.DashStyle = DashStyle.Solid;

CalculateOnBarClose = true;
Overlay = true;
PriceTypeSupported = false;
AutoScale = false;
stringFormatFar.Alignment = StringAlignment.Far;

NinjaTrader_Bertrand
07-30-2010, 06:07 AM
Dave, the Initialize() you posted looks ok to me - is this part of any chart template / workspace? Can you please try if you see the same error in the log if you load the indicator in a fresh workspace and on a fresh chart?

Thanks

daven
07-30-2010, 07:01 AM
I will try that later today and see what happens.
Thanks