Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MAX and MIN errors

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

    MAX and MIN errors

    Hello,

    I am trying to get a max, min values over a period a time. I have private variables declared in the beginning of the class:

    Code:
    private double high;
    private double low;
    in OnBarUpdate(), I assigned them to MAX and MIN:

    Code:
    high = MAX(high,30)[0];
    low = MIN(low,30)[0];
    And I am getting these errors:

    Code:
    Cannot implicitly convert type 'NinjaTrader.NinjaScript.Indicators.MAX' to 'double'

    when I check the documentation, I don't see​ anything different: https://ninjatrader.com/support/help...aximum_max.htm


    How do I fix this?

    #2
    Originally posted by Brevo View Post
    when I check the documentation, I don't see​ anything different
    Really? Nothing different?

    Look again, carefully, C# is very case sensitive.

    You've used high and low where you should be
    using High and Low -- that one letter difference in
    case is extremely important.

    The fix is simple,

    Code:
    high = MAX(High,30)[0];
    low = MIN(Low,30)[0];​
    The first argument to MIN and MAX must be a data
    series -- and high and low are not data series.

    That is, the variables high and low are type double,
    but High and Low are type Series<double>. The case
    of the first letter makes a critical difference, because,
    all C# identifiers (whether variables, types, or methods)
    are all case sensitive. For ex, high, High, and HIGH
    are three completely different identifiers.

    Make sense?

    Last edited by bltdavid; 02-20-2024, 01:37 AM.

    Comment


      #3
      my bad.. I was coding late at night. thx

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      626 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      359 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      562 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      567 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X