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

Indicator for Average Range (NOT ATR)

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

    Indicator for Average Range (NOT ATR)

    Hi,

    I was wondering if anyone has an indicator that calculates the simple average range over a set number of bars. For example, for 3 bars, average range=[(bar1 high - bar1 low)+(bar2 high - bar2 low)+(bar3 high - bar3 low)] / 3.

    I don't know how to script indicators so if anyone already has one that would be perfect. Thanks so much.

    #2
    Unfortunately I'm not aware of a readymade one, but you could use the help given here as a starting point - the sample calculates an SMA of the range of the last 20 bars, you could easily change this to 3 for your case - http://www.ninjatrader-support.com/H...eV6/Range.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi. Thanks for that. I think it is what I am looking for. Could you please give me some instruction as to how I can create an indicator for the average range using Ninjascript? The only variable I want to be able to change is the number of bars used in the calculation (so I can calculate the average range over 5,10,100 etc. bars).

      Thanks so much,

      Comment


        #4
        I would suggest you start by checking into those tutorials on indicator coding here - http://www.ninjatrader-support.com/H...verview18.html

        Then you can just use the second snippet provided in the Range link from my previous post, it calcs over the set period of 20 bars.

        To create a customizable user defined input for this setting, please check into this link here -

        BertrandNinjaTrader Customer Service

        Comment


          #5
          Wouldn't this just be:

          Print("Average = " + (SMA(High, period)[0] - SMA(Low, period)[0])) // <=== untested

          Set the period to 3 for your purposes.

          Dan
          eDanny
          NinjaTrader Ecosystem Vendor - Integrity Traders

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by samish18, Yesterday, 08:31 AM
          3 responses
          13 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by funk10101, Yesterday, 09:43 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by TheWhiteDragon, 01-21-2019, 12:44 PM
          5 responses
          551 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by rtwave, 04-12-2024, 09:30 AM
          5 responses
          37 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by funk10101, Today, 12:02 AM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Working...
          X