Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimization

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

    Optimization

    Is there an option to perform optimization maximizing geometrical mean, if not, is it possible to modify NT to do this manually?

    Thank you.

    #2
    Hello,

    It is not currently possible natively, but is so using custom programming.

    Please see our Help Guide article on Developing Custom Fill and Optimizer Types for more information:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Thank you. It seem easy to program and I have done so but for some reason it does not work properly. I followed your instructions and copied and modified one of the existing optimization files, it is just a few lines. The optimization process is running ok but all values of performance have the same value 1. Did I miss anything?

      Here is my code:

      //
      // Copyright (C) 2006, NinjaTrader LLC <www.ninjatrader.com>.
      //
      #region Using declarations
      using System;
      using System.ComponentModel;
      using System.Drawing;
      using NinjaTrader.Cbi;
      using NinjaTrader.Data;
      using NinjaTrader.Indicator;
      using NinjaTrader.Strategy;
      #endregion

      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
      /// <summary>
      /// </summary>
      [Gui.Design.DisplayName("max. geo. mean")]
      public class MaxGeoMean : OptimizationType
      {
      /// <summary>
      /// Return the performance value of a backtesting result.
      /// </summary>
      /// <param name="systemPerformance"></param>
      /// <returns></returns>
      public override double GetPerformanceValue(SystemPerformance systemPerformance)
      {
      double gmean = 1;
      for (int i=0;i<systemPerformance.AllTrades.Count;i++)
      {
      Trade myTrade = systemPerformance.AllTrades[systemPerformance.AllTrades.Count - 1 - i];
      gmean = gmean * (1+myTrade.ProfitPercent);
      }
      gmean = Math.Pow(gmean,1.0/systemPerformance.AllTrades.Count);
      return(gmean);
      }
      }
      }

      Comment


        #4
        Hello BoyPlunger,
        Unfortunately custom optimization is beyond what we could support but you can refer to the DefaultOptimizationMethod.cs file located in the folder C:\Users\JMitra\Documents\NinjaTrader 7\bin\Custom\Type\ to get an idea on how to create custom Optimization methods.

        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        67 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        36 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        59 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        62 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X