Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Highest High Bar Calculation

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

    Highest High Bar Calculation

    Hello,
    I am sincerely hoping some one will help me here....

    I am trying (struggling) to write an indicator that plots how many bars ago did Highest High occur in a period.. Say I want to know how many bars ago did it occur in a window of 200 bars? and then plot that.

    Please help with a sample code...

    Thanx

    #2
    Hello sardana,

    Thanks for your post.

    MAX can be used to identify the Highest High from X number of bars ago.

    After finding this MAX value, I suggest to use a loop to loop back from High[0] to High[X] so you can see how many bars back you can go before you reach this highest value. As the loop iterates, increase a variable that you would like to use for the indicator plot.

    Our NinjaTrader 7 help guide provides some light information on loops, and more robust materials can be found externally to NinjaTrader.

    Code:
    int j = 0;
    double highestHigh = MAX(High, 100)[0];
    
    for (int i = 0; i < 100; i++)
    {
        if (High[i] < highestHigh)
            j++;
        else
            break;
    }
    j would represent how many bars have been counted from the current bar to the highest high.

    MAX - https://ninjatrader.com/support/help...aximum_max.htm

    Basic Programming Concepts from NT7 Help Guide - https://ninjatrader.com/support/help...g_commands.htm

    Please let us know if you have any questions.

    Comment


      #3
      Or you can, of course, just use the HighestBar() method directly.

      ref: https://ninjatrader.com/support/help...highestbar.htm

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      85 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      123 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      64 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      114 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X