Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Minimum average ETD optimization fitness

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

    Minimum average ETD optimization fitness

    Hello,

    I need to create an optimization fitness for that optimizes for the minimum average ETD. I wrote the code I paste here but I do not get any result.

    What is the problem?


    namespace NinjaTrader.NinjaScript.OptimizationFitnesses
    {
    public class MinETD : OptimizationFitness
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Min. ETD";
    Name = "MinETD";
    }
    else if (State == State.Configure)
    {
    }
    }

    protected override void OnCalculatePerformanceValue(StrategyBase strategy)
    {
    //Considering that the optimization results are ordered from bigger to smaller values
    Value =(1 - strategy.SystemPerformance.AllTrades.TradesPerform ance.Percent.AverageEtd);
    }

    }
    }​


    #2
    Hello guillembm,

    Thank you for your post.

    Do you receive any errors on the Log tab of the Control Center? If so, what do the errors report?

    You mentioned you do not get any result. How are you testing and where are you reviewing results? Are you able to select Min. ETD in an optimization for the "Optimize on" setting? If so, do the results get sorted based on minimum ETD?

    I look forward to your reply.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply.

      I receive no errors in the log tab.

      To explain what I mean I attach two screenshots. In the first one I Optimize SampleMACrossover using the Max. Profit Factor Fitness and I get results. Instead, When I optimize with the Min. ETD Fitness I created I get nothing as you can see in the attached file.

      Did you try in your end?
      Attached Files

      Comment


        #4
        Hello guillembm,

        I tried the code you posted and I see results when using the ES. I can't see what quantity you are using in the analyzer and that is a forex instrument. Along with the left image showing values in cents did you make sure to use a whole lot size like 100000? The quantity for forex needs to be a lot size and not 1.



        JesseNinjaTrader Customer Service

        Comment


          #5
          I do not trade futures. I am optimizing the EURUSD instrument.

          The only difference between the screenshots I sent is the Optimizer fitness.

          "Set Order Quantity" is set to Strategy. Setting a default value of 100000 changes nothing.

          Can you send me the .cs file of this optimizer fitness to see if I did something wrong?

          Comment


            #6
            Hello guillembm,

            I understand that I was just relaying that it did produce results in a test.

            I copied the code you posted and pasted that in an optimization fitness, there were no changes made.

            You may want to use Print statements to check what value your calculation is making to get a better idea of what's happening in your test.

            Code:
            Print((1 - strategy.SystemPerformance.AllTrades.TradesPerformance.Percent.AverageEtd));
            JesseNinjaTrader Customer Service

            Comment


              #7
              I already did this. I attach a file with the Print results. I should show some results but nothing appears. The strange thing is that results appear with the other fitnesses.
              Attached Files

              Comment


                #8
                With this code it works.

                protected override void OnCalculatePerformanceValue(StrategyBase strategy)
                {
                double MyValue = (1 - strategy.SystemPerformance.AllTrades.TradesPerform ance.Percent.AverageEtd);

                if (MyValue == 1)
                MyValue = 0;

                Value = MyValue;
                }

                It showed first the values equal to 1 and this is not logic. There cannot exist an average ETD equal to zero. It was just about discarding them.​

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by lucasmelo152, 06-28-2021, 12:51 PM
                8 responses
                2,123 views
                0 likes
                Last Post Ymcapital  
                Started by Creamers, 04-27-2024, 05:32 AM
                11 responses
                68 views
                0 likes
                Last Post Creamers  
                Started by NM_eFe, 04-30-2024, 06:14 AM
                5 responses
                32 views
                0 likes
                Last Post NM_eFe
                by NM_eFe
                 
                Started by Jonker, 04-27-2024, 01:19 PM
                2 responses
                20 views
                0 likes
                Last Post Jonker
                by Jonker
                 
                Started by Max Baxter, 03-07-2019, 09:20 PM
                8 responses
                267 views
                0 likes
                Last Post Ymcapital  
                Working...
                X