NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > Application Technical Support > Strategy Analyzer

Strategy Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer.

Reply
 
Thread Tools Display Modes
Old 12-14-2010, 11:14 AM   #1
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Exclamation 'Object reference not set to an instance of an object' error in NT7R1 but not in B20

Greetings,

I have spent the better part of this morning try to isolate an error in the log tab of NT7R1

[[ Error in calling 'OnExecution' method of strategy XXXX 'Object reference not set to an instance of an object' ]] ..

IS VERY strange as the error shows up in some timeframes I am optimizing but when I page through different time spans Nov2009 - Oct2010 sometimes it appears and sometimes not _without_ any changes in the paramater settings or setting for the PH Genetic.

This happens with two different desktops running NT7R1 ... when I copy the strategy and indicators and saved .xml for the strategy template (to a VM also running NT7), B20 runs the strategy without any problems, regardless of timespan chosen.

I am restoring a B20 image to one desktop to see if there is consistency of not getting any errors. I will also be exporting the historical data from the NT7R1 to maintain same basics, and importing that into the B20 ... strategy was developed on the NT7R1, and compiles without problems, there are no special drawing boxes or funny code, so I am wondering what possibly is happening that it has errors in NT7R1 and not in B20?

Jon
Trader.Jon is offline  
Reply With Quote
Old 12-14-2010, 11:39 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
Default

Jon, would you mind us testing your strategy with your settings in the SA on our R1 here to attempt reproducing?

If you could contact us at support at ninjatrader dot com that would be great.

Thanks,
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 12-14-2010, 11:52 AM   #3
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Default

Bertrand,

I will do that ... I am using $EURUSD exclusively ... do you want the data I am testing against?

Jon
Trader.Jon is offline  
Reply With Quote
Old 12-14-2010, 11:58 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
Default

Thanks Jon, yes that would be great to have the exact same testing base. If the email is getting too big, please use a file sharing service like Filexpressit to upload it.

Thanks,
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 12-15-2010, 12:08 PM   #5
Trader.Jon
Senior Member
 
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
Default

Bertrand,

It looks like the issue has more to do with corrupted hard disk than software. Thanks for the offer of asist and I will email if issue isnt resolved.

Jon
Trader.Jon is offline  
Reply With Quote
Old 01-06-2011, 10:37 PM   #6
saltminer
Senior Member
 
Join Date: Apr 2008
Posts: 164
Thanks: 2
Thanked 3 times in 3 posts
Default

I see this null object exception too. I believe it is caused by the final execution the Optimizer makes to get flat at the end of all the available data. Something about this execution might be screwy, as any strategy that tests things inside OnExecution gets randomly crashed.
The error never happens on a chart.
Cheers,
saltminer
saltminer is offline  
Reply With Quote
Old 01-07-2011, 03:56 AM   #7
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
Default

saltminer, are you checking for the objects being null in OnExecution?
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 01-07-2011, 03:30 PM   #8
saltminer
Senior Member
 
Join Date: Apr 2008
Posts: 164
Thanks: 2
Thanked 3 times in 3 posts
Default

On a different job a month or so ago I wrote code to check every last thing I could think of for null. Code is below. Despite this, null exceptions were still randomly created.I had to give up trying to test with the Genetic Optimiser.
The strategy worked fine on charts.

Code:
protected override void OnExecution(IExecution execution) 
        { 
            if (execution == null || execution.Name == null || execution.Name == "Exit On Close")
                return;
            
            if (execution.Name == "Stop loss" && Position != null && Position.MarketPosition != null &&
                Position.MarketPosition == MarketPosition.Flat && PyramidOrder != null)
            {
                Print("Cancelling pyramid order (if necessary)");
                CancelOrder(PyramidOrder);
            }
            if (Position != null && Position.MarketPosition != null &&
                PyramidOrder != null && 
                PyramidOrder.Token != null &&
                PyramidOrder.StopPrice != null &&
                PyramidOrder.OrderState != null &&
                PyramidOrder.Token == execution.Order.Token && PyramidOrder.OrderState == OrderState.Filled
                && PyramidMaxCount >= PyramidCount) 
            {
                // looks like our pyramid order filled, so place a new order further out
                if (Position.MarketPosition == MarketPosition.Long)
                    PyramidOrder = EnterLongStop(0,true,PyramidPositionSize,PyramidOrder.StopPrice+(PyramidPipDistance*TickSize),"P"+PyramidCount.ToString());
                else if (Position.MarketPosition == MarketPosition.Short)
                    PyramidOrder = EnterShortStop(0,true,PyramidPositionSize,PyramidOrder.StopPrice-(PyramidPipDistance*TickSize),"P"+PyramidCount.ToString());
                PyramidCount++;
            }

        }
Cheers,
saltminer
saltminer is offline  
Reply With Quote
Old 01-07-2011, 04:36 PM   #9
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

saltminer,

I suggest using a try-catch block over various segments in your code and that will trap wherever the issue is stemming from.
NinjaTrader_Josh 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
on bar 0: Object reference not set to an instance of an object. Lost Trader Indicator Development 13 07-12-2010 03:33 PM
Object reference not set to an instance of an object rcsingleton Indicator Development 3 03-18-2010 03:37 PM
Error calling 'OnExecution' - object reference not set to an instance of an object kcsystemtrader Strategy Development 9 05-11-2009 03:11 PM
Error on running optimizer. Object reference not set to an instance of an object. vasily20011 Strategy Analyzer 5 03-09-2009 08:09 AM
Error: Object reference not set to an instance of an object. Januson Market Analyzer 1 05-18-2007 12:12 AM


All times are GMT -6. The time now is 04:05 PM.