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

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.
    JimNinjaTrader Customer Service

    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 judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      57 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
      20 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      9 views
      0 likes
      Last Post cre8able  
      Working...
      X