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 andrewtrades, Today, 04:57 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      6 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      436 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      9 views
      0 likes
      Last Post FAQtrader  
      Started by rocketman7, Today, 09:41 AM
      5 responses
      20 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X