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

Using same indicator instance during optimization

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

    Using same indicator instance during optimization

    Hi,

    I have an indicator that reads from several external files on initialization.

    I have a strategy that does not contain much logic, it basically just calls the indicator.

    When running optimizations in Strategy Analyzer, there is no need that the indicator would re-read those external files on every optimization iteration.

    Problem is the indicator is instantiated in the strategy's DataLoaded state. So if I set IsInstantiatedOnEachOptimizationIteration to false, how can it help to use the same indicator instance?

    Thank you.

    #2
    Hello digibob,

    Thank you for your post.

    IsInstantiated... reuses the strategy instance, not the indicators within. The indicator would still be re-instantiated with each optimization iteration. You could try moving the indicator logic into the strategy and specifically resetting any variables/series/etc that may need to be reset.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi Kate. Thank you for your reply.

      I was afraid of that.

      The indicator exists on its own unrelated to any strategy, currently some tens of thousands of code lines and is a continuous work in progress. If I make a strategy with the same code I would then have duplicate everything and always have to update two files. I'd like to keep things in one place. I was thinking of using an AddOn, but it wouldn't help for this case without knowing when an optimization starts and ends (first and last iterations). To my knowledge this information is not available. So I'm out of luck here.

      Kind regards.

      Comment


        #4
        Kate, I moved all the objects to the strategy, with IsInstantiatedOnEachOptimizationIteration set to false, but the objects are null on every optimization iteration.

        I also copied the example from the doc page as is, to make a test strategy, and this too shows that the myTrades dictionary is null on every optimization iteration.

        What is missing?

        Comment


          #5
          Ok I see the reason in Chelsea's post here. More than one strategy instance is used. I didn't try the optimization with enough iterations to see the difference. All is good now.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by algospoke, Today, 06:40 PM
          0 responses
          9 views
          0 likes
          Last Post algospoke  
          Started by maybeimnotrader, Today, 05:46 PM
          0 responses
          7 views
          0 likes
          Last Post maybeimnotrader  
          Started by quantismo, Today, 05:13 PM
          0 responses
          7 views
          0 likes
          Last Post quantismo  
          Started by AttiM, 02-14-2024, 05:20 PM
          8 responses
          168 views
          0 likes
          Last Post jeronymite  
          Started by cre8able, Today, 04:22 PM
          0 responses
          10 views
          0 likes
          Last Post cre8able  
          Working...
          X