Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Test Harness for generating error events?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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.

    #2
    Hello itsnotme,
    You can simply use the TraceOrders function to print out the values in the Output window.


    For more debugging tips please refer to this post


    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      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?


      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.


      For more debugging tips please refer to this post


      Please let me know if I can assist you any further.

      Comment


        #4
        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, 07:26 PM.

        Comment


          #5
          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.


          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.
          JoydeepNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by DavidHP, Today, 07:56 AM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by kujista, Today, 06:23 AM
          3 responses
          8 views
          0 likes
          Last Post kujista
          by kujista
           
          Started by Mindset, Yesterday, 02:04 AM
          2 responses
          18 views
          0 likes
          Last Post NinjaTrader_RyanS  
          Started by f.saeidi, Today, 08:03 AM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by samish18, 04-17-2024, 08:57 AM
          15 responses
          53 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Working...
          X