![]() |
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
|
|||||||
| Strategy Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
|
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,
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
|
Bertrand,
I will do that ... I am using $EURUSD exclusively ... do you want the data I am testing against? Jon |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
|
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,
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Dec 2008
Posts: 338
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Apr 2008
Posts: 164
Thanks: 2
Thanked 3 times in 3 posts
|
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 |
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,384
Thanks: 252
Thanked 967 times in 950 posts
|
saltminer, are you checking for the objects being null in OnExecution?
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Apr 2008
Posts: 164
Thanks: 2
Thanked 3 times in 3 posts
|
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++;
}
}
saltminer |
|
|
|
|
|
#9 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
saltminer,
I suggest using a try-catch block over various segments in your code and that will trap wherever the issue is stemming from.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |