Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

HighestBar() and LowestBar() on a secondary series?

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

    HighestBar() and LowestBar() on a secondary series?

    Can HighestBar() and LowestBar() reference a secondary series? For example: if I added a 4-Hour series to a 5-minute primary chart, can I use the following to get the number of bars ago the highest or lowest 4-hour bar occurred of the BarsArray[1]? Would the int used for period in the method apply to BIP 0 or BIP 1?

    Code:
    // store the highest bars ago value
      int highestBarsAgo = HighestBar(Highs[1], int used in CurrentBars[1]);
    
      //evaluate high price from highest bars ago value
      double highestPrice = Highs[1][highestBarsAgo];        
      ​

    #2
    Hello Lance El Camino,

    Thank you for your post.

    Yes, the HighestBar() and LowestBar() methods may be used to reference data from an added series. You would specify the barSeriesIndex use for the array of series<double> objects just as you have in specifying Highs[1]:


    The int used for the period would apply to the series being used, so if you use Highs[1] for the series in HighestBar() then the period would apply to BarsInProgress 1. This may be verified using a print statement, such as the following, and reviewing the output in the NinjaScript Output window when the script is applied:
    Code:
    // prints the time for the current bar of the secondary series, prints out the currentbars index for the added series, prints the highest bar from Highs[1] with a period of 3, and prints the current bar and last 3 bar's Highs[1] values
    Print(Times[1][0] + " CurrentBars[1]: " + CurrentBars[1] + " HighestBar: " + HighestBar(Highs[1], 3) + " Highs[1][0]: " + Highs[1][0] + " Highs[1][1]: " + Highs[1][1] + " Highs[1][2]: " + Highs[1][2] + " Highs[1][3]: " + Highs[1][3]);

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

    Comment


      #3
      Thank you!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      576 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X