Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

RangePT Indicator

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

    RangePT Indicator

    Hey guys, a while back someone posted this indicator on the forums and I've tried to edit one thing to no avail. I'm attaching the file; it basically calculates the avg range (high to low) of a set amount of bars. Instead of using high-low, I want to use close to close. However, when I try to reference a any bar other than the one that just closed, the indicator no longer works.

    So basically, before now it has used High[0]-Low[0]....I'm trying to use if statements to see which close is higher than the other and then say the higher close minus the lower close. So considering yesterday's close was higher than today's, I'd use Close[1] - Close[0]. This is where I run into a problem...it all works when I only reference the first index of the array, but as soon as I go to the 2nd or any further back, it ceases to work. So it will work if I say Close[0]-Open[0], it still will calculate a value. However, as soon as I change the index from 0 to anything else, it won't work.

    The line I'm editing is #47.
    atr1.Set(High[0] - Low[0]);

    Attached is the indicator.

    Thanks
    Attached Files

    #2
    albazzaztariq,

    You will want to ensure that you have a CurrentBar check for your script. This will have the script ensure there is enough data on the chart when starting the calculations

    try using this at the beginning of your OnBarUpdate()
    Code:
    if(CurrentBar < 1) return;
    Cal H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    579 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
    554 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