• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Newtrader101, Today, 03:54 PM
    1 response
    15 views
    0 likes
    Last Post NinjaTrader_ShawnB  
    Started by williamzz, Today, 03:28 PM
    0 responses
    7 views
    0 likes
    Last Post williamzz  
    Started by Robert87, Today, 11:07 AM
    0 responses
    14 views
    0 likes
    Last Post Robert87  
    Started by phta123, Today, 10:24 AM
    0 responses
    17 views
    0 likes
    Last Post phta123
    by phta123
     
    Started by sidviciousX, Today, 06:47 AM
    0 responses
    16 views
    0 likes
    Last Post sidviciousX  
    Working...
    X