NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Miscellaneous Support

Miscellaneous Support Miscellaneous support issues.

Reply
 
Thread Tools Display Modes
Old 07-29-2010, 08:19 PM   #1
daven
Senior Member
 
Join Date: Mar 2006
Location: Bellingham, WA , USA
Posts: 331
Thanks: 0
Thanked 11 times in 8 posts
Default Failed to call method 'Initialize'

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
Quote:
#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;
daven is offline  
Reply With Quote
Old 07-30-2010, 06:07 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,555
Thanks: 261
Thanked 1,013 times in 994 posts
Default

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
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 07-30-2010, 07:01 AM   #3
daven
Senior Member
 
Join Date: Mar 2006
Location: Bellingham, WA , USA
Posts: 331
Thanks: 0
Thanked 11 times in 8 posts
Default

I will try that later today and see what happens.
Thanks
daven is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Failed to call method 'Initialize' for strategy ' richa61416 Version 7 Beta General Questions & Bug Reports 10 04-23-2010 04:20 AM
failed to call method 'initialize' for indicator tinkerz General Programming 4 02-22-2010 09:46 AM
ERROR: Failed to call method 'Initialize' for indicator NinjaCustomer Indicator Development 11 12-09-2009 05:41 AM
ERROR: Failed to call 'Add' method for period type 'Tick' RK_trader Miscellaneous Support 24 06-04-2009 05:49 AM
Failed to call method "Initialize" for indicator 'Test': Object reference not set to clearpicks Indicator Development 3 04-23-2008 12:53 PM


All times are GMT -6. The time now is 07:34 PM.