• 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


Custom Optimizer

  • Filter
  • Time
  • Show
Clear All
new posts

    Custom Optimizer


    I am trying to develop a custom optimizer and am having some trouble calling and using the function RunIteration().

    Is it possible to get more information about what this function does or the code behind it?

    Can it be called with input arguments?

    Can it be looped? For example:

    RunIteration() with one set of inputs,
    Get results,
    Then RunIteration() with another set of inputs, and
    Get results.

    Is this possible?

    Ideally I would like to run a multi-thread approach and pass multiple arguments to
    RunIteration(). I image this could be done through a GPGPU set up such as CUDAfy.

    As I understand global parameters are stored and then RunIteration() back tests each of these parameters and then ranks the results?

    Is there a way to call the straight back test method through code? And then loop through with different input arguments?

    Thank You


    Thank you for the question.

    I have put in a note to see if there can be expanded descriptions of the items in this section, currently there is limited documentation on these items.

    Regarding RunIteration(), this method has no overloads so it could not pass a parameter, I am a little confused on this question though. RunIteration() simply calls the next iteration, are you asking how to persist a value from one iteration to the next to allow it to be used in the next iteration?

    As for calling the backtest outside of this type, currently there are no documented ways to do a backtest without using the backtest tool, I will put in a feature request to see if this could be utilized from code.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service


      Hi Jesse,

      Thank you for your help.

      In simple psuedocode this is what I would like to do:

      Have a parameter in a strategy to optimize e.g. int 1 = 1

      Loop through the backtests with different settings for the parameter.

      for i = 0; 1 < 1000; i ++
      run backtest(i) - with parameter set to i
      recordResults[] = resultsBacktest(i)

      But to be able to mult-thread (ideally via GPGPU) and run the back tests with different settings for the optimization parameter simultaneously.

      Can this be achieved via the RunIteration() function and how can the results of each run be captured and recorded?

      Ideally it would be best to be able to call the backtest directly. For example the strategy parameters seem like they are just arguments to the strategy. For example:

      strategy1(parameter 1, parameter 2)

      And the strategy seems like it should just be an argument for the backtest. For example:

      backtest(strategy1(parameter 1, parameter 2)

      If it could be called this way it would be very easy to loop through. For example:

      for i = 0; i < 10; i ++
      for j = 0; j < 10; j++
      backtest(strategy1( i, j ))

      How every there is little information on being able to call the backtest or iteration functions or on how to capture and record the results for them.
      Last edited by Aether; 05-04-2016, 08:10 AM.



        Thank you for the reply.

        I wanted to further clarify this response.

        Based on what you are describing, I believe you are asking how Optimizer types would relate to completing an entire backtest and then utilizing the results of that test to essentially start another. Is this correct?

        The Optimizer type would simply control how the properties are incremented not control the entire backtest. The RunIteration method is simply letting the analyzer know to start the next iteration because the logic in the Optimzer has incremented the properties. The analyzer window would essentially be controlling the test and utilizing the Optimizer to control its increment for optimization.

        What you are asking would not currently be possible because there are no methods to complete a backtest without the actual backtest window, or no NinjaScript way of doing this anyway. I will submit a feature request for this item though.

        Regarding the remainder of the post about putting work off to the GPU, you could certainly try utilizing the GPU but this would be a subject that our support would not really be able to provide any helpful information on due to this being a third party library.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service


        Latest Posts


        Topics Statistics Last Post
        Started by swcooke, Yesterday, 10:39 PM
        1 response
        Last Post b16_aln
        by b16_aln
        Started by Fernand0, Yesterday, 09:53 PM
        0 responses
        Last Post Fernand0  
        Started by traderpards, Yesterday, 09:55 AM
        4 responses
        Last Post Lancer
        by Lancer
        Started by franco12364, Yesterday, 06:49 PM
        0 responses
        Last Post franco12364  
        Started by fx.practic, Yesterday, 03:55 PM
        0 responses
        Last Post fx.practic