Strategy optimization error doesn't make sense

I’m optimizing a strategy which has an input parameter “StopTicks.” As you can see in this snapshot, I have the parameters set to test between 10 and 42 ticks. However, I get the error indication that my stop ticks are set to zero! What’s happening here and how do I fix it?

Is the default in the script set to zero perhaps?

1 Like

Does your StopTicks property have a Range attribute applied? Like this in the @SampleMACrossOver.cs strategy

[Range(1, int.MaxValue), NinjaScriptProperty]
[Display(ResourceType = typeof(Custom.Resource), Name = "Fast", GroupName = "NinjaScriptStrategyParameters", Order = 0)]
public int Fast { get; set; }

In your case the Range is probably set to something like the following.

Range(10, int.MaxValue)

And if your StopTicks property is not explicitly initialized to a value other than zero, its default will be zero.

You could change the attribute or you could set the StopTicks default value in SetDefaults

      protected override void OnStateChange()
      {
          if (State == State.SetDefaults)
          {
              StopTicks = 10;
          }
1 Like

YES! This solved my problem. Thank you for taking the time to help!

1 Like