Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Annoying "Parameter value is 0 and not in the range" during GA optimization

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

    Annoying "Parameter value is 0 and not in the range" during GA optimization

    Something I noticed, which should be trapped out by NT8 developers, is the fact that if you use an integer-based parameter during GA optimization, and compare the iterated value during optimization with a double-based cutpoint in an if-statement, NT8 will throw an exception (error) that the value of 0 was identified during an iteration. Specifically, in my case I was using an ADX threshold below which I would not trade in a strategy. The code that caused the error was:

    Code:
    [Range(4, 50), NinjaScriptProperty]
    [Display(ResourceType = typeof(Custom.Resource), Name = "ADX threshold", GroupName = "NinjaScriptStrategyParameters", Order =6)]
    public int adxthresh
    { get; set; }
    and I was comparing adxthresh with

    Code:
    if ( adxlongterm < adxthresh )
    entertrades=false;
    where the DOUBLE class-level variable "adxlongterm" was set to adxlongterm = ADX(14)[0] in a bar update of a 5-minute data series.

    However, when I changed adxthresh to double using the code:

    Code:
    public double adxthresh
    the error stopped appearing. This indicates that NT8 does not like mixed integers and doubles, since NT8 was throwing an exception when an integer.
    Starts
    07-15-2019
    Ends
    07-16-2019

    #2
    Hello pel11, thanks for your note.

    This seems to be more of a run time issue with C# itself. If you need to adxthresh to be an int, you can cast it to a double when performing calculations with it, that should also solve this error.

    e.g.
    if ( adxlongterm < (double)adxthresh )

    Best regards.

    Comment

    Latest Posts

    Collapse

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