Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 llanqui, Today, 10:32 AM
      0 responses
      1 view
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by StockTrader88, 03-06-2021, 08:58 AM
      45 responses
      3,992 views
      3 likes
      Last Post johntraderuser2  
      Started by TAJTrades, Today, 09:46 AM
      0 responses
      7 views
      0 likes
      Last Post TAJTrades  
      Started by rhyminkevin, Yesterday, 04:58 PM
      5 responses
      62 views
      0 likes
      Last Post dp8282
      by dp8282
       
      Started by realblubb, Today, 09:28 AM
      0 responses
      8 views
      0 likes
      Last Post realblubb  
      Working...
      X