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 > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 06-05-2012, 10:57 AM   #1
itsnotme
Junior Member
 
Join Date: May 2011
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Cool Test Harness for generating error events?

Is there a way I can generate error events to test my error handling code?

I'm primarily interested in testing my code for handling Order Rejected events due to such things and Market Closed errors from Interactive Brokers.
itsnotme is offline  
Reply With Quote
Old 06-05-2012, 11:14 AM   #2
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello itsnotme,
You can simply use the TraceOrders function to print out the values in the Output window.
http://www.ninjatrader.com/support/h...raceorders.htm

For more debugging tips please refer to this post
http://www.ninjatrader.com/support/f...ead.php?t=3418

Please let me know if I can assist you any further.
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 06-05-2012, 03:02 PM   #3
itsnotme
Junior Member
 
Join Date: May 2011
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank you for responding, but how to debug is not the question I asked.
I wish to exercise my code for handling errors before letting in run autonomously on a live market, to do this I need a way of generating ninjatrader error events. What is the recommended method of doing this type of testing?


Quote:
Originally Posted by NinjaTrader_Joydeep View Post
Hello itsnotme,
You can simply use the TraceOrders function to print out the values in the Output window.
http://www.ninjatrader.com/support/h...raceorders.htm

For more debugging tips please refer to this post
http://www.ninjatrader.com/support/f...ead.php?t=3418

Please let me know if I can assist you any further.
itsnotme is offline  
Reply With Quote
Old 06-05-2012, 07:08 PM   #4
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,201
Thanks: 24
Thanked 1,227 times in 998 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by itsnotme View Post
Thank you for responding, but how to debug is not the question I asked.
I wish to exercise my code for handling errors before letting in run autonomously on a live market, to do this I need a way of generating ninjatrader error events. What is the recommended method of doing this type of testing?
Just generate illegal orders and you should have what you seek. e.g., a ShortStopLimit above the market, or a LongStopLimit below the market.

The other method would be to use a Try/Catch block and generate your own exception. Heck, you could even just use a code block/function to throw your own exceptions at will if you want.
Last edited by koganam; 06-05-2012 at 07:26 PM.
koganam is offline  
Reply With Quote
Old 06-06-2012, 04:05 AM   #5
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello itsnotme,
As koganam said you have to submit some invalid orders (like buy stop at below current market close etc).

You can use the OnOrderUpdate event to capture the order state.
http://www.ninjatrader.com/support/h...rderupdate.htm

Code:
protected override void OnOrderUpdate(IOrder order)
{
	if (order.OrderState == OrderState.Rejected)
	{
		//do something
	}
}
Thanks koganam for your input.

Please let me know if I can assist you any further.
NinjaTrader_Joydeep 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
error generating indicator dee50 Installation and Licensing 13 06-09-2011 10:46 AM
Error on generating Strategy chakriare Strategy Analyzer 3 10-03-2010 04:42 PM
Error on Generating Strategy andrgm Strategy Development 1 06-18-2010 02:13 PM
Error on generating Strategy philotrader ATM Strategies (Discretionary Trading) 6 05-21-2010 09:15 PM
Error generating strategy jbhansen7 Strategy Development 3 02-04-2009 07:24 AM


All times are GMT -6. The time now is 10:50 AM.