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 judysamnt7, 03-13-2023, 09:11 AM
            4 responses
            59 views
            0 likes
            Last Post DynamicTest  
            Started by ScottWalsh, Today, 06:52 PM
            4 responses
            36 views
            0 likes
            Last Post ScottWalsh  
            Started by olisav57, Today, 07:39 PM
            0 responses
            7 views
            0 likes
            Last Post olisav57  
            Started by trilliantrader, Today, 03:01 PM
            2 responses
            21 views
            0 likes
            Last Post helpwanted  
            Started by cre8able, Today, 07:24 PM
            0 responses
            10 views
            0 likes
            Last Post cre8able  
            Working...
            X