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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      174 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      329 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      252 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      356 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      182 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X