• 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.


No announcement yet.

Partner 728x90


needless instantiation of all strategies, StrategyAnalyzer NT8 B12

  • Filter
  • Time
  • Show
Clear All
new posts

    needless instantiation of all strategies, StrategyAnalyzer NT8 B12

    By adding some Print statements in a couple of strategies I have found that all strategies get instantiated (OnStateChange called with State.SetDefaults then State.Terminated in the following cases:
    A) Twice when StrategyAnalyzer is started. I can understand why this might be needed once, but why twice?
    B) When changing the selected strategy.
    C) When Backtest type combo is changed.
    D) Every time a strategy is run (Backtest type = Standard).
    E) When backtest type is changed.
    F) If instrument is changed.
    G) If Data Series Type is changed.
    H) If Order Fill Resolution is changed.
    I) If Set Order Quantity combo is changed.

    At the moment I dont have many strategies in NT8 or much code in SetDefaults, but unnecessary instantiation of things I dont need right now seems to be asking for problems.
    Lets say I wanted to connect to another slow-to-respond application in a strategy. If I did this in State.SetDefaults then that would slow down testing of all other strategies. I suppose that sort of thing needs to go into State.Configure instead?

    This raises an interesting question. Would we get better overall performance if we deleted all unused indicators and strategies from their respective directories? NT can be a pig on memory all by itself. Would doing this help?
    Thanks ... Ed


      Hi Ed,
      Currently Strategy Analyzer "only" keeps instantiating all Strategies (not Indicators).
      I think a similar thing occurred in NT7 where I had to keep moving unused strategies out of the folders NT7 looked at, otherwise Strategy Analyzer became unusable.


        Very interesting. I have a pile of unused strats. I'll remove them and see if my performance improves. Optimizing is agonizingly slow as it is! Don't need to make it worse.
        THanks ... Ed


          In Charts. Every time the Indicators dialog is opened (eg Ctrl I), NT currently instantiates all Indicators (OnStateChange called with State.SetDefaults then State.Terminated).
          This seems necessary in the current design because for example the name displayed in the "Available" list comes from the Name property set in State.SetDefaults

          But if someone has added loads of custom indicators and is finding the Indicators dialog slow to display, they may want to move unused indicators somewhere else.



            Thank you for the post.

            It would be expected to see the SetDefaults and Terminated called multiple times depending on the actions being completed in the platform.

            This instantiation is to get the Defaults of the NinjaScript item for populating menus and other areas where the item is seen. This does not fully instantiate the script to where it is running but only the SetDefaults to get its defaults and then is terminated. This is the same concept as it had already existed in NT7, only it was the Initialize being called in NT7.

            It is certainly possible that a developer that is un aware of this concept could create items that make the menus load slowly, for example if you put some type of logic that requires time to complete in SetDefaults. In general the default items, or items that do not execute logic in this portion of the script specifically should not slow the platform down.

            I would suspect having thousands of items installed could take longer to load as the amount of items to display has increased. As DaveE said, if you are experiencing items causing slowness it may be wise to remove unused items to see if one of these is creating this type of situation.

            You can find more information about this on the States page here: http://ninjatrader.com/support/helpG...ghtsub=onstate

            Please let me know if I may be of additional assistance.
            JesseNinjaTrader Customer Service


            Latest Posts


            Topics Statistics Last Post
            Started by Mindset, Today, 10:06 AM
            0 responses
            1 view
            Last Post Mindset
            by Mindset
            Started by broffe18, Today, 09:57 AM
            0 responses
            1 view
            Last Post broffe18  
            Started by jimsw, Today, 09:52 AM
            0 responses
            Last Post jimsw
            by jimsw
            Started by caveat_lector, Today, 09:23 AM
            1 response
            Last Post NinjaTrader_ChelseaB  
            Started by Johnny, Today, 09:50 AM
            0 responses
            Last Post Johnny
            by Johnny