• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error handling

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

    Error handling

    Many times, when an error occurs the strategy remains active but the instructions are not executed. This means that if I have an open position it won't be closed.

    Is there any kind of error handling for these kind of errors:

    **NT** Error on calling 'OnBarUpdate' method for strategy 'FOREX/347ed3a51f1e4ade92dceb3b85a0e115': Object reference not set to an instance of an object.

    I know the error handling with RealtimeErrorHandling.TakeNoAction and I'm already using it. This is useful when an order is rejected. But how to handle an error like the previous shown?

    #2
    guillembm, this more of a coding issue in your strategy code and thus would not fall under the reatime error handling considerations. You would need to manage a resulting position the yourself and debug the strategy code to review where the issue was coming from.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Do you know what could be the origin of this error?

      Comment


        #4
        Yes, I would suggest checking into this tip here - http://www.ninjatrader.com/support/f...ead.php?t=4226
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Lost EnterLongLimit

          Finally I found the origin of the error.

          What happens step by step:
          1. After filling an enter order I launch and EnterLongLimit order with LiveUntilCancelled set to true as a profit target.
          2. Suddendly the limit order from the Orders tab disappears but the position is still open in the Positions tab and in the Strategies tab.

          So I need a process to know why this happens and to avoid it.

          I printed all the process and the strange thing is that while the Market position is not flat the EnterLongLimit for the profit target appears as Filled.

          I don't know what to do

          Comment


            #6
            guillembm,

            From our help guide,

            Methods that generate orders to enter a position will be ignored if:
            • A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
            • A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction
            • The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction
            • The entry signal name is not unique

            Methods that generate orders to exit a position will be ignored if:
            • A position is open and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction
            • A position is open and an order submitted by a set method (SetStopLoss() for example) is active

            Set() methods that generate orders to exit a position will be ignored if:
            • A position is open and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction
            • A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active
            It sounds to me like you are violating one of these rules, as generally its advised to use the built in stop loss and profit target functions for protective orders. There is the unmanaged approach which may be more appropriate for what you are trying to do. I would suggest using SetProfitTarget() and SetStopLoss() for protective orders if you are going to continue using the managed approach.

            Please let me know if I may assist further.
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              I don't know what is my case but I found a solution. If the position is not flat and my profit target is null then I set the limit order again.

              It seems to work. Will see with more tests

              Comment


                #8
                guillembm,

                I am happy you have resolved your issue. Please be aware there are order handling rules "under-the-hood" when you use the managed approach. I have outlined these in the previous post. If you want to define your own rules the unmanaged approach is necessary.

                Please let me know if I may assist further.
                Adam P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by RedDuke, Today, 06:14 PM
                0 responses
                0 views
                0 likes
                Last Post RedDuke
                by RedDuke
                 
                Started by DariusDeck, Today, 04:22 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_Marco  
                Started by pstrusi, Today, 05:05 PM
                1 response
                2 views
                0 likes
                Last Post pstrusi
                by pstrusi
                 
                Started by saeed, Today, 10:20 AM
                4 responses
                17 views
                0 likes
                Last Post saeed
                by saeed
                 
                Started by priceisking, Yesterday, 07:44 PM
                1 response
                27 views
                0 likes
                Last Post NinjaTrader_Kate  
                Working...
                X