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

Understanding the MAX function

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

    Understanding the MAX function

    Hello there

    This probably sounds a silly question, but I'm looking at this line of code within the parabolic indicator script:

    Value.Set(xp + (longPosition ? -1 : 1) * ((MAX(High, CurrentBar)[0] - MIN(Low, CurrentBar)[0]) * af));


    so my queary is.. doesn't this

    MAX(High, CurrentBar)[0] just mean High;

    and this

    MIN(Low, CurrentBar)[0]) just mean low:

    Thanks in advance....... Andy

    #2
    MAX(High, CurrentBar)[0] means the maximum of the high values of the last "CurrentBar" bars (equivalent for MIN(Low, CurrentBar)[0]))


    Comment


      #3
      Thank you for the quick response, but I'm a little confused, doesn't currentbar mean the actual currentbar in progress?


      Here's the section of code it's from

      if (CurrentBar < 3)
      return;
      else if (CurrentBar == 3)
      {
      // Determine initial position
      longPosition = High[0] > High[1] ? true : false;
      xp = MAX(longPosition ? High : Low, CurrentBar)[0];
      af = Acceleration;
      Value.Set(xp + (longPosition ? -1 : 1) * ((MAX(High, CurrentBar)[0] - MIN(Low, CurrentBar)[0]) * af));
      return;


      Thanks

      Andy

      Comment


        #4
        Right, thus code below calculates the max of the highs of all bars seen so far.

        Comment


          #5
          Thank you again for the lightening quick response, just so I can get my head around it. It's basically saying the highest high of the first 3 bars on the chart to get the indicator underway... is this correct?

          Thanks

          Andy

          Comment


            #6
            I have not read the thread but...

            MAX(High, 3)[0]

            would return the highest high value of the last three bars.
            RayNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by zstheorist, Today, 07:52 PM
            0 responses
            6 views
            0 likes
            Last Post zstheorist  
            Started by pmachiraju, 11-01-2023, 04:46 AM
            8 responses
            150 views
            0 likes
            Last Post rehmans
            by rehmans
             
            Started by mattbsea, Today, 05:44 PM
            0 responses
            6 views
            0 likes
            Last Post mattbsea  
            Started by RideMe, 04-07-2024, 04:54 PM
            6 responses
            33 views
            0 likes
            Last Post RideMe
            by RideMe
             
            Started by tkaboris, Today, 05:13 PM
            0 responses
            6 views
            0 likes
            Last Post tkaboris  
            Working...
            X