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

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 ZenCortexHurry, Today, 01:07 PM
    0 responses
    2 views
    0 likes
    Last Post ZenCortexHurry  
    Started by ZenCortexHurry, Today, 01:04 PM
    0 responses
    0 views
    0 likes
    Last Post ZenCortexHurry  
    Started by f.saeidi, Today, 12:14 PM
    3 responses
    9 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by Russ Moreland, Today, 12:54 PM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by philmg, Today, 12:55 PM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Working...
    X