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 > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 09-17-2010, 05:42 AM   #1
zeller4
Senior Member
 
Join Date: Sep 2008
Posts: 185
Thanks: 20
Thanked 2 times in 2 posts
Default Correct Use of Print Statements

Hello,

I'm using various print statements to check orderstates in my custom strategy using Unmanaged = true.

I continue to get error messages:specifically "Object reference not set to an instance of an object".

Is this a valid print statement?
Code:

Print("longOrder.OrderState:\t"+longOrder.OrderState);
In other words, will this create the error message?

Or do I first need to check for null?
Code:

if (longOrder != null) Print("longOrder.OrderState:\t"+longOrder.OrderState);
I believe it has to do with a null reference not being checked but not sure where to look next. If it's more than just checking for null at the print statements, I'll post the code.

Thanks,
Kirk
zeller4 is offline  
Reply With Quote
Old 09-17-2010, 07:10 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,419
Thanks: 252
Thanked 981 times in 963 posts
Default

Kirk, correct you should add a != null check before attempting to access the IOrder objects in your prints.

http://www.ninjatrader.com/support/f...ead.php?t=4226
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 09-17-2010, 08:08 AM   #3
zeller4
Senior Member
 
Join Date: Sep 2008
Posts: 185
Thanks: 20
Thanked 2 times in 2 posts
Default

Thanks Bertrand,

I appreciate the link.

Kirk
zeller4 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
'If' statements with BarColor comand KLG08 General Programming 3 01-24-2010 11:46 PM
Statements if/true/false skikg General Programming 2 12-09-2009 01:45 PM
Live Print statements jerimac2 Automated Trading 2 09-29-2009 10:42 AM
IF Statements bologc NinjaScript File Sharing Discussion 3 09-03-2009 08:48 AM
statements ignored Burga1 General Programming 8 06-30-2008 10:36 PM


All times are GMT -6. The time now is 06:11 AM.