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

How to properly obtain information on the Strategy Analyzer...

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

    How to properly obtain information on the Strategy Analyzer...

    Hello awesome support staff!

    I have a complex strategy that usually loads its parameters from a database (one tuned record per instrument) so my code circumvents the normal property serialization.

    My strategy code runs great when embedded in a chart and when doing a backtest in the strategy analyzer, but when in the 'Optimization' mode of the Analyzer I need to stop my code from loading its properties from the DB so that the normal functionality of the optimizer can iterate through its span of parameter values.

    Unfortunately I haven't been able to detect when my strategy is hosted in the Optimization mode of the Analyzer. Is there a way to do this? (There is the IsInStrategyAnalyzer property (that only works in the 'Configure' and 'DataLoaded' states but nothing on which analyzer mode the strategy runs under)

    Thanks for the help!

    Jean-Pierre

    #2
    Hello,

    There isn't a supported property for detecting if the script is in an optimization run.
    I am happy to submit a feature request for this if you would like.

    You may try using unsupported code. This is not officially supported and not guaranteed to work.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Awesome!

      A test for 'Category != Category.Optimize' did the trick!

      Thanks again for the prompt and expert assistance Chelsea! How I wished other software would be supported by experts!

      Now that this is working better, is there a way to obtain a pointer to the Analyzer currently running? (I'd like to obtain what instrument the user has set in the Analyzer GUI so that I can load its record from my DB) Any code sample where a strategy obtains info from the host that creates / destroys it would be wonderful... Perhaps there is an enumeration in the running Analyzer instance of its GUI-facing parameters I can read?

      Comment


        #4
        Hello JPPoulin,

        NinjaTrader does not have any supported properties for this.

        You may be able to climb the visual tree to the top parent and see what kind of window this is and find what you are looking for within the window.
        This would be outside of what the NS Support is able to assist with.

        NinjaScriptBase topMost = this;
        for (; topMost.Parent != null; topMost = topMost.Parent) {}


        However, the Instrument selected by the user is available internally to the Strategy after State.DataLoaded.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea, thanks again for the hint on walking up the Windows parent.

          FYI I tried it and within the context of a strategy running inside both BackTest and Optimize mode of the Analyzer, topMost.Parent is always null and the code snippet never goes up a level and topMost is always equal to this... perhaps walking up this chain is useful in other contexts like Chart?

          Comment


            #6
            Hello JPPoulin,

            I don't have any other suggestions. This thread will remain open for any community members that would like to assist.

            Let me know you would like to submit a feature request.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            3 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            1 view
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            6 views
            0 likes
            Last Post Javierw.ok  
            Started by timmbbo, Today, 08:59 AM
            2 responses
            10 views
            0 likes
            Last Post bltdavid  
            Working...
            X