Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Transition from Historical to Realtime error

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

    Transition from Historical to Realtime error

    I am getting the error:

    "Strategy 'XXX' has been disabled because it attempted to modify a historical order that has transitioned to a live order. Please see the help guide for more information on transitioning order references from historical to live."

    This error is happening when running in the Strategy Analyzer. There is no realtime data -- it is Saturday and the last bar on the chart is Friday's closing bar.

    I have code that transitions the orders in OnStateChange() when state changes to Realtime. The problem is that I get this error but the state never changed to Realtime.

    It also says in the doc on "Advanced Order Handling": "Tip: When the real-time order is submitted, there is a generic Order object passed into the OnOrderUpdate() method containing the live order details which can be used for debugging. It is recommended you use the helper GetRealtimeOrder() when your strategy transitions to real-time to update your order references"

    I've output to the Output window every call to OnOrderUpdate and see no live orders all order ID's are of the format NT-NNNNN-NNN.

    On a chart with the same setup it shows an active entry order. (strategy uses Unmanaged orders) and the state transition to Realtime is happening and no error is generated. OnOrderUpdate shows the live order.

    So there seems to be some issue with the Strategy Analyzer. It shouldn't be generating this error.

    #2
    Hello EquityBoost2,

    Please (copy and then) reduce the script to the minimum code necessary to reproduce the error, then please attached this reduced version as an attachment with your next post so that I may test this behavior on my end.

    To export a NinjaTrader 8 NinjaScript do the following:
    1. Click Tools -> Export -> NinjaScript...
    2. Click the 'add' link -> check the box(es) for the script(s) you want to include
    3. Click the 'Export' button
    4. Enter a unique name for the file in the value for 'File name:'
    5. Choose a save location -> click Save
    6. Click OK to clear the export location message

    By default your exported file will be in the following location:
    • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>


    Below is a link to the help guide on Exporting NinjaScripts.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello,
      I've encountered the same problem in the same conditions (unmanaged strategy, no transition to realtime in Strategy Analyzer, problem only appears in Strategy Analyzer). Did you manage to resolve the issue?

      Comment


        #4
        Hello InteRadek,

        Are you using the latest version of NinjaTrader 8 (8.0.9.0)?

        Have you created a simplified export for me to test that includes no code that is not absolutely necessary to reproduce the behavior?

        If so, please include this with your next post.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you for your interest. Yes, I'm using the latest version. In section State.Terminated I have a function, that is looking for open orders and sets Order variables to null, when orders are cancelled. When "Exit on session close" occured and it was a last available historical session, it triggered the error when it tried to null the profitOrder or stoplossOrder from State.Terminated. So I added a simple IF statement to not triger the function, when it is running in a Strategy Analyzer and the problem is resolved.
          Code:
          if (this.Id != -1)
            function();

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,607 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          9 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          19 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          6 views
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          15 views
          0 likes
          Last Post Javierw.ok  
          Working...
          X