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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      47 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      38 views
      0 likes
      Last Post CarlTrading  
      Working...
      X