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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      265 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      169 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      171 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      259 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      210 views
      0 likes
      Last Post CarlTrading  
      Working...
      X