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 warreng86, 11-10-2020, 02:04 PM
          7 responses
          1,360 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by Perr0Grande, Today, 08:16 PM
          0 responses
          5 views
          0 likes
          Last Post Perr0Grande  
          Started by elderan, Today, 08:03 PM
          0 responses
          9 views
          0 likes
          Last Post elderan
          by elderan
           
          Started by algospoke, Today, 06:40 PM
          0 responses
          10 views
          0 likes
          Last Post algospoke  
          Started by maybeimnotrader, Today, 05:46 PM
          0 responses
          14 views
          0 likes
          Last Post maybeimnotrader  
          Working...
          X