Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimization fitness programming errors

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

    Optimization fitness programming errors

    Hello. I have doubts on programming optimizer fitnesses.

    I want to use the code structure:

    protected override void OnCalculatePerformanceValue(StrategyBase strategy)
    {
    foreach (Trade t in strategy.SystemPerformance.AllTrades)
    {
    //Code
    }
    }

    but I receive the error: "The type or namespace name 'Trade' could not be found (are you missing a using directive or an assembly reference?)"

    This code works in a regular strategy but not in the optimization.

    #2
    I understand that this piece of code in an optimization fitness:

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    Name = NinjaTrader.Custom.Resource.NinjaScriptOptimizatio nFitnessNameMaxProfitFactor;
    }

    is used to push the optimization results to the UI. But, what if I want to make my own fitness that doesn't exist in the system?

    Comment


      #3
      Hello Guillembm,

      If you were to declare the following using directive, under #region Using Declarations, does the error referencing the trade object no longer appear?

      Code:
      using NinjaTrader.Cbi;
      If you wanted to make your own fitness, you should see the existing samples under OptimizationFitnesses as reference examples.

      Please let us know if you need further assistance.
      Alan P.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      85 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      48 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      29 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      32 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      67 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X