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

problem with calculating average daily range

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

    problem with calculating average daily range

    The code below:

    Code:
    // Calculate the range of the average daily range over the past day.
    AverageDailyRange.Set(CurrentDayOHL().CurrentHigh[0] - CurrentDayOHL().CurrentLow[0]);
    Code:
    // Print the current SMA 7 period Average Daily Range .
    DrawTextFixed("AverageDailyRange1", "Average Daily Range: " + Instrument.MasterInstrument.Round2TickSize(SMA(AverageDailyRange, 7)[0]), TextPosition.TopLeft, Color.Black, new Font("Arial", 8), Color.Transparent, Color.Transparent, 1);
    ---

    Is there a different way just to calculate the average daily range from the days high to the days low for the past 7 days (market hours only)? I seemed to be getting skewed numbers when I check it out against manually calculated figures over the daily high to daily low on my charts over the past 7 days. I am using tick charts if that helps... I need it to be dynamic so that it is not spitting out a fixed number each session, it needs to change as the market moves taking in the current days high and low as well (when they are made)..
    Last edited by ericadam; 10-21-2008, 11:13 AM.

    #2
    Hi ericadam,

    The reason your code is skewed is because you are referencing a period of 7 for your Average Daily Range. Unfortunately that period of 7 is not 7 days it just 7 bars. In your case, 7 tick bars.

    To get what you want you need to run calculations via PriorDayOHLC() and get the range of the 6 prior days. Then use CurrentDayOHL() to get the current day's range. When you are using PriorDayOHLC() you need to go many many bars back in your [] index to check for those. You will want to use GetBar() to figure out what index to use for each of the 7 days. Hope that help.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      So there is no 'easy' way to reference the average of calculating the day high - day low over the past 7 days, and then having that number print? I came from another charting package where you just put in (DailyRange, 7) for a 7 days daily range average.. could the logic be that simple?

      Comment


        #4
        It will be that simple in NT7 when we introduce multi-time framed indicators, but for now you will need to proceed with something along the lines of what I suggested in my previous post.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Ah okay. phew.. when is NT 7 slated for release?

          Comment


            #6
            NinjaTrader 7 is slotted for the first half of 2009.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              7 day average daily range w/ minute charts

              any way of programming this in the stratgey wizard?
              Thks Bert

              Comment


                #8
                Unfortunately not.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  I'm also looking for this indicator. To use for profit target and stop loss.

                  Comment


                    #10
                    You can always contact a NinjaScript consultant to get this custom coded professionally - http://www.ninjatrader.com/webnew/pa...injaScript.htm
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by Ninja B View Post
                      I'm also looking for this indicator. To use for profit target and stop loss.
                      I found a solution. Go to help, search "Custom indicator Development", clk "display", clk "Custom Indicator Development" (in blue in the right side big box), clk on level 2 & follow instructions substituting range for volume in the wizard. If I can do it you can. On the chart properties window of the chart using SMA of Range I activate the "exclude weekends" option. Weekend range is really low & skews the results. For daily range I use this on a 405 minute chart. A Zen-fire work around since they don't supply daily data.
                      Cheers, Bert
                      Last edited by BertW; 02-13-2009, 05:17 PM.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by usazencort, Today, 01:16 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post usazencort  
                      Started by kaywai, 09-01-2023, 08:44 PM
                      5 responses
                      603 views
                      0 likes
                      Last Post NinjaTrader_Jason  
                      Started by xiinteractive, 04-09-2024, 08:08 AM
                      6 responses
                      22 views
                      0 likes
                      Last Post xiinteractive  
                      Started by Pattontje, Yesterday, 02:10 PM
                      2 responses
                      21 views
                      0 likes
                      Last Post Pattontje  
                      Started by flybuzz, 04-21-2024, 04:07 PM
                      17 responses
                      230 views
                      0 likes
                      Last Post TradingLoss  
                      Working...
                      X