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 geddyisodin, Today, 05:20 AM
          2 responses
          16 views
          0 likes
          Last Post geddyisodin  
          Started by hazylizard, Today, 08:38 AM
          0 responses
          6 views
          0 likes
          Last Post hazylizard  
          Started by Max238, Today, 01:28 AM
          5 responses
          43 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by giulyko00, Yesterday, 12:03 PM
          3 responses
          13 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by habeebft, Today, 07:27 AM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_ChristopherS  
          Working...
          X