Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Return Number of Bars Ago from Bar Range

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

    Return Number of Bars Ago from Bar Range

    Greetings,

    I am looking for a way to retrieve the number of bars ago that a Low occurred that is between 5 and 10 bars ago. More specifically, I already have MIN(Low,5)[10], which works fine to return that value, but what I need is how many bars ago that low occurred.
    I tried using LowestBar(5), but it doesn't appear to have an offset if I am looking for the low in a range that does not begin with the current bar (i.e. 5-10 bars ago).
    Thank you for any help,
    hbmiles2000

    #2
    hbmiles2000,

    I am happy to assist you.

    You could keep a second dataseries that is delayed by 5 bars from the current dataseries, then check LowestBar(delayed_dataseries,5).

    Something like :

    if( CurrentBar >= 5)
    {
    delayed_dataseries.Set(main_dataseries[CurrentBar-5]);
    }

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by hbmiles2000 View Post
      Greetings,

      I am looking for a way to retrieve the number of bars ago that a Low occurred that is between 5 and 10 bars ago. More specifically, I already have MIN(Low,5)[10], which works fine to return that value, but what I need is how many bars ago that low occurred.
      I tried using LowestBar(5), but it doesn't appear to have an offset if I am looking for the low in a range that does not begin with the current bar (i.e. 5-10 bars ago).
      Thank you for any help,
      hbmiles2000
      You know that you are looking for the next 5 bars, starting from 10 bars ago, so use a "for" loop, to compare the low to the target value, indexed from 10 to 15, with a "break" when the first correct bar is found.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by kinfxhk, 07-14-2026, 09:39 AM
      0 responses
      125 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 10:18 AM
      0 responses
      105 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 09:50 AM
      0 responses
      85 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 07:21 AM
      0 responses
      105 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-11-2026, 02:11 AM
      0 responses
      84 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X