PDA

View Full Version : ERROR: Failed to call method 'Initialize' for indicator


NinjaCustomer
12-09-2009, 12:29 AM
What does this mean? YRecent is an indicator I developed myself, but I'm currently not using it on any charts... but this always shows up in my logs:

2009-12-06 16:42:50:421 ERROR: Failed to call method 'Initialize' for indicator 'YRecent': Object reference not set to an instance of an object.
2009-12-06 16:44:33:296 ERROR: Failed to call method 'Initialize' for indicator 'YRecent': Object reference not set to an instance of an object.
2009-12-06 17:14:49:265 ERROR: Failed to call method 'Initialize' for indicator 'YRecent': Object reference not set to an instance of an object.
2009-12-06 17:22:18:734 ERROR: Failed to call method 'Initialize' for indicator 'YRecent': Object reference not set to an instance of an object.
2009-12-06 17:23:08:718 ERROR: Failed to call method 'Initialize' for indicator 'YRecent': Object reference not set to an instance of an object.

How do I fix it?

NinjaTrader_Bertrand
12-09-2009, 04:45 AM
NinjaCustomer, expected - since the Initialize() is called each time across studies, you could comment out the part giving you the issue or debug the script -

http://www.ninjatrader-support2.com/vb/showthread.php?t=3418

NinjaCustomer
12-09-2009, 05:05 AM
NinjaCustomer, expected - since the Initialize() is called each time across studies, you could comment out the part giving you the issue or debug the script -

http://www.ninjatrader-support2.com/vb/showthread.php?t=3418

just so you know, my indicator works fine and compiles fine...

it is just that i get this error message in the log...

could this be the culprit? I have this code in Initialize:

new DataSeries(this);

NinjaTrader_Bertrand
12-09-2009, 05:07 AM
Yes, as this alone is not a fully assigned DataSeries object - http://www.ninjatrader-support.com/HelpGuideV6/DataSeriesObject.html

NinjaCustomer
12-09-2009, 05:11 AM
so what should I do?

I see no difference between my code and what you have in the Help documentation link you gave me, so do I just ignore this error message? it is harmless?

NinjaCustomer
12-09-2009, 05:12 AM
btw. that was just a code fragment, of course I assigned it to a variable

NinjaTrader_Bertrand
12-09-2009, 05:13 AM
You want to assign to a data series variable created in the variables section of your code -


protected override void Initialize()
{
myDataSeries = new DataSeries(this);
}

NinjaTrader_Bertrand
12-09-2009, 05:14 AM
Please post your full Initialize() then, thanks.

NinjaCustomer
12-09-2009, 05:17 AM
just remember when reading the code, that everything works as I intended in the indicator... it is only those log error messages that make me concerned that i am writing sloppy code... i just want to rule out that my indicator could cause any instability (because of those error messages):


protected override void Initialize()
{

lastHighCache = new ArrayList();
lastLowCache = new ArrayList();

swingHighSeries = new DataSeries(this);
swingHighSwings = new DataSeries(this);
swingLowSeries = new DataSeries(this);
swingLowSwings = new DataSeries(this);

prevSwingRange = -1;

BarsRequired = 100;

AutoScale = false;
DisplayInDataBox = false;
CalculateOnBarClose = true;
PaintPriceMarkers = false;
Overlay = true;

ActiveMarketLogFile = Environment.GetFolderPath(Environment.SpecialFolde r.Personal) +
@"\misc\" + Instrument.MasterInstrument.Name + "_active_market_alerts.csv";

if (logActiveMarketAlerts) File.Delete(ActiveMarketLogFile);
}

NinjaTrader_Bertrand
12-09-2009, 05:29 AM
Please move the log file calls accessing the Instrument to the first OnBarUpdate() bar and then retry.

NinjaCustomer
12-09-2009, 05:37 AM
so I should just put it in a

if (CurrentBar == 0) {

}

in OnBarUpdate ?

NinjaTrader_Bertrand
12-09-2009, 05:41 AM
Yes, as the Instrument would likely be emtpy (null) if not placed there...