I’m working with a custom Optimization Fitnesses and I’m trying to add the way to specify an int variable value of the Optimization Fitnesses internal calculation as an input from the Strategy Analyzer, i.e. in a similar way as with a strategy you could insert a variable value as an input from its Properties from the Strategy Analyzer.
I was looking for an example about a similar situation but haven’t found a solution yet.
Here is a code with the structure of some things I’m trying with the part to add the input, please check the sections `Properties` and `State.SetDefaults`, but none of them make the input to be shown in the Strategy Analyzer UI to be an user inserted value.
#region Using declarations using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Xml.Serialization; using NinjaTrader.Cbi; using NinjaTrader.Gui; using NinjaTrader.Gui.Chart; using NinjaTrader.Gui.SuperDom; using NinjaTrader.Gui.Tools; using NinjaTrader.Data; using NinjaTrader.NinjaScript; using NinjaTrader.Core.FloatingPoint; #endregion namespace NinjaTrader.NinjaScript.OptimizationFitnesses { public class MaxProfitFactorCustom: OptimizationFitness { protected override void OnStateChange() { if (State == State.SetDefaults) { Name = "MaxProfitFactorCustom"; inputVar = 10; } } protected override void OnCalculatePerformanceValue(StrategyBase strategy) { Value = strategy.SystemPerformance.AllTrades.TradesPerformance.ProfitFactor; // extra calculation here with `inputVar`. } #region Properties [Display(ResourceType = typeof(Custom.Resource), Name = "NinjaScriptOptimizationFitness")] [Range(1, Int32.MaxValue)] public int inputVar { get; set; } // some of other alternatives tried. /* [NinjaScriptProperty] [Display(Name="variableInput", Description="...", Order=0, GroupName="NinjaScriptOptimizationFitness")] [Range(0, int.MaxValue)] public int inputVar { get; set; } */ /* [Display(ResourceType = typeof(Custom.Resource), Description = "...", Name = "Properties", Order = 0)] [Range(0, int.MaxValue)] public int inputVar { get; private set; } */ #endregion } }
What would be solution for these cases?
Thank you
Comment