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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    62 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    134 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X