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

syntax for highest high

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

    syntax for highest high

    Can somebody explain this syntax to me:

    MAX(High, integer - 1)[1]

    #2
    Hello gordongekko,
    Thanks for your post.

    That method is referencing the largest value for historical "High" prices over a period. That period is equal to whatever the value of "integer" is minus one.
    The "[1]" at the end is a "BarsAgo" value that indicates the reference point for this calculation is one bar ago.

    I am including the relevant help guide documentation, for your convenience.

    MAX()
    https://ninjatrader.com/support/help...aximum_max.htm

    High
    https://ninjatrader.com/support/help...n-us/?high.htm

    Series<T>
    https://ninjatrader.com/support/help...s/?seriest.htm

    BarsAgo- Referencing the Correct Bar
    https://ninjatrader.com/support/foru...83&postcount=2

    Using [] Brackets


    Please let me know if you have any further questions.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      By reference point do you mean it starts scanning backwards until it hits that bar number and then gets the highest high and assigns it to a variable. Or does it stop at that [1] bar. For example here is a more detailed version with a variable that would actually be used.


      In this example stoch2 is a bar number in the 0 array that was obtained by iterating through the historical data using a for loop. In this case the profitTarget is going to be the highest price high the last time the stochastic was > 80.

      private double profitTarget = 0;

      profitTarget = stoch2 > 1 ? MAX(High, stoch2 - 1)[1] : High[1];
      Last edited by gordongekko; 02-23-2018, 11:52 AM.

      Comment


        #4
        The BarsAgo value is what the status of that series was at that bar. For example, MAX(High,20)[5] is referencing the highest "High" over a 20 bar look back period starting 5 bars ago.

        For comparison, MAX(High,20)[0] is referencing the highest "High" of a 20 bar look back period starting at the current bar.

        The forum post below should be helpful in explaining this.

        BarsAgo- Referencing the Correct Bar
        https://ninjatrader.com/support/foru...83&postcount=2
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Can the Max function work with a list of variables?

          MAX[Var1, Var2, . . . ] etc.

          Comment


            #6
            Hello ronaldgreene828,

            Thank you for your reply.

            No. The MAX() function requires a Series<double> and a lookback period over which to look at the series to find the highest value within. It would not work with a list of variables. You would simply want to compare the variables to each other, for which you can use Math.Max(). Publicly available documentation for Math.Max() can be found here:



            Please let us know if we may be of further assistance to you.

            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Rapine Heihei, Today, 08:19 PM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by Rapine Heihei, Today, 08:25 PM
            0 responses
            3 views
            0 likes
            Last Post Rapine Heihei  
            Started by f.saeidi, Today, 08:01 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by Rapine Heihei, Today, 07:51 PM
            0 responses
            6 views
            0 likes
            Last Post Rapine Heihei  
            Started by frslvr, 04-11-2024, 07:26 AM
            5 responses
            96 views
            1 like
            Last Post caryc123  
            Working...
            X