Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Self optimizing strategy

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

    Self optimizing strategy

    I want to create a strategy which optimizes itself as it is executing, ie analysis runs in the background and if a more optimal set of parameters is found then the strategy will begin operating with those parameters. The only thing I am stuck on is how to find the optimal parameters. Is there any way to initiate a strategy analysis from within a ninjascript? (either backtest or optimization would work) Or any other suggestions of how to accomplish this? I need to put some of these excess CPU cycles to use

    #2
    Originally posted by sefstrat View Post
    I want to create a strategy which optimizes itself as it is executing, ie analysis runs in the background and if a more optimal set of parameters is found then the strategy will begin operating with those parameters. The only thing I am stuck on is how to find the optimal parameters. Is there any way to initiate a strategy analysis from within a ninjascript? (either backtest or optimization would work) Or any other suggestions of how to accomplish this? I need to put some of these excess CPU cycles to use

    Maybe this would give some ideas http://articles.mql4.com/506, this would be public or just to your use?

    Regards

    Comment


      #3
      Sounds like you want to do a walk-forward optimization. Please take a look at this Help Guide article: http://www.ninjatrader-support.com/H...AStrategy.html
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by PrTester View Post
        Maybe this would give some ideas http://articles.mql4.com/506, this would be public or just to your use?

        Regards
        Thanks for the link, some nice information at that site =) Yes, basically I want to do what they are doing there.. run an optimization (not walk forward) periodically and have my active strategy access the results from that optimization. I can instantiate a new StrategyAnalyzer, but as far as I can see there is no way to invoke analysis from code or access the results of an analysis since the necessary members are not publicly visible. I do see that there are public methods for saving and loading analysis sessions from XmlDocument, so I thought it might be possible to restore a saved session, then update its optimization data and save it to xml which I could then access in my strategy. Is that possible or any other way to accomplish this scenario?

        Comment


          #5
          You can save and load results. In the Strategy Analyzer, when you are done backtesting, there is a Save button on the top toolbar.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Ninjatrader v.s. Metatrader 4 on this topic

            Hello Ninjatraders,

            First of all, sorry for bumping this old thread, but it seems the only one which is relevant regarding the automation of a self-optimizing trading model.
            As a Metatrader 4 developer/trader I've created a trading model with a self-optimizing engine. Since this feature has not been implemented in MT, I was forced to create this myself. In short, this works as follows.

            On specific times, during the day:
            - Collect a large array of historical prices, both an initial historic part for the indicator calculations and for the optimization itself.
            - Simulate trades for all model parameters in certain steps.
            - Evaluate the current fitness (profit, etc) against the last best one.
            - Adjust the model parameters.

            Technically this is almost running fine in MT4, but it's very hard to simulate those trades with a realistic approach since I can't call historic bid/ask prices, so I have to simulate them.

            Now back to Ninjatrader, has NT better simulation features, like historic bid/asks and/or optimizer function calls?

            Thanks,

            Arthemis

            Comment


              #7
              Hello,

              Thanks for the forum post and welcome to the forums.

              Unfortunately although we do allow some custom coding in this area it is all un-supported and as such we really do not have any documentation on the process or if this would even be possible.For the most part we do not support calling the optimizer from code to allow it to run at a set interval and take the results from it for use. This is all done via the GUI in NInjaTrader.

              -Brett
              BrettNinjaTrader Product Management

              Comment


                #8
                Thanks Brett, for clarifying the capabilities of the optimization feature.

                The most important issue for me is the simulation part. In the NT7 help guide I saw the functions MarketDataType.Bid / .Ask. Does these functions allow me to capture historic bid/ask prices, during a back test or live trading, by placing them in an initializing function, like this?

                Code:
                protected override void Initialize()
                {
                Add(string instrumentName, PeriodType.Minute, 1, MarketDataType.Bid);
                Add(string instrumentName, PeriodType.Minute, 1, MarketDataType.Ask);
                }
                And if so, how can I refer to a specific bid/ask from n bars ago?

                Thank you,

                Arthemis

                Comment


                  #9
                  Hello,

                  Yes this allows you to access historical bid/ask updates from the provider and to do this you would use MTF programming method described here:

                  BrettNinjaTrader Product Management

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  633 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  364 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  105 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  567 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  568 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X