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 devatechnologies, 04-14-2024, 02:58 PM
                3 responses
                19 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by tkaboris, Today, 08:01 AM
                0 responses
                2 views
                0 likes
                Last Post tkaboris  
                Started by BarzTrading, Today, 07:25 AM
                1 response
                11 views
                1 like
                Last Post NinjaTrader_Clayton  
                Started by EB Worx, 04-04-2023, 02:34 AM
                7 responses
                161 views
                0 likes
                Last Post VFI26
                by VFI26
                 
                Started by Mizzouman1, Today, 07:35 AM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X