• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Previous Days ATR Value

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

    #16
    Glad to hear, thanks for the update.
    BertrandNinjaTrader Customer Service

    Comment


      #17
      Hi,

      I was working through this example but am getting results that don't line up when comparing the chart to the code. I am looking over 6E data for the first 3 months of the year and the further I look back I note a difference between chart and code. My chart is a daily chart which plots daily ATR. My code uses:

      double AtrValue = (ATR(BarsArray[1], 14)[1]);
      Print("ATR");
      Print(AtrValue);

      At 08:00:00 on 27/03/13 my code tells me that the ATR for yesterday's close was 0.012286... The chart says that the ATR value directly under the 26/03/13 bar (i.e. the close of the previous day) was 0.0123. Assuming rounding, so far so good. At 08:00:00 on 14/02/13 I get 0.01026... vs 0.0104 under 13/02/13. At 08:00:00 on 04/01/13 I get 0.0085359... vs 0.00848 under 12/02/13.

      What gives? Have I done something wrong?

      I assume the overload of [1] is correct if I am interested in yesterday's closing ATR value. Which begs the question, what result do I get if I make it ATR(...)[0] as today's bar will not have completed yet - does it use the current price from today's candle to estimate the closing ATR?

      Cheers,
      darmbk.

      Comment


        #18
        darmbk, which base chart are you using when you add this in and how many days are you loading with which BarsRequired setting? No estimation of the closing price done, it all depends on your CalculateOnBarClose in realtime, then you would access the currently developing bar if this is set to false otherwise you will access the last completed bar with the 0 index.
        BertrandNinjaTrader Customer Service

        Comment


          #19
          Hi Bertrand,

          Thanks for your quick response. Firstly a correction, I was running with [0] as the index not [1], so this is correct. BarsRequired = 20. I am loading data from 1-12-12 to 29-3-13. My ATR values print where a trade is entered and the first trade is on 3/1/13.

          Comment


            #20
            darmbk, so which primary series are you working then from? With BarsRequired set to 20, 20 bars for all series would have to pass before OnBarUpdate() would be called for your script.
            BertrandNinjaTrader Customer Service

            Comment


              #21
              Hi Bertrand,

              My primary time frame is 1 minute and the only other time frame in use is daily. My intention in using data from 1/12/12 is so that 20 days will be available by the time I want to begin a back-test from January to March.

              Cheers,
              Dar.

              Comment


                #22
                Dar, thanks. Please check against this simply indicator study made for your 1 minute chart attached. I've compared a few days of the values and don't see an issue. Since the ATR uses an exponential like component (not finite filter like SMA) though for the smoothing I would expect minor differences on the first bars when the values are initialized and 'catching' up.
                Attached Files
                BertrandNinjaTrader Customer Service

                Comment


                  #23
                  Hi Bertrand,

                  Thanks for passing that on.

                  To recap, what I have been looking at up until now is the following: [1] I run a 1-min based strategy which takes a daily ATR value as an input, this strategy prints the ATR values to the output window on days where there are trades; [2] I have then compared these output ATR values to values of ATR as they are displayed on a separate daily chart that I create. The outcome is highlighted by the example ATR differences I posted previously.

                  Today I have replaced the original ATR values mentioned above with your ATRDaily indicator values. Here are the results for the dates I quoted last time:

                  ATRDaily (output window rounded to same decimal places as Data Box display from chart)
                  27/3/13: Output window = 0.0127, Data Box = 0.0127
                  14/2/13: 0.0105, 0.0105
                  4/1/13: 0.008, 0.008

                  So all looks well when using ATRDaily. I repeated the same test for ATR again just to confirm I had not introduced a manual error

                  For ATR (same test as above)
                  27/3/13: 0.0123, 0.0123
                  14/2/13: 0.0104, 0.0104
                  4/1/13: 0.0084, 0.0084

                  I believe I know where the original discrepancy arose. While the chart was displaying data from 29/11/12, the back test was using data from 1/12/12, thus introducing a small change in the indicator calculation from the start. Sorry about that Bertrand!

                  Many thanks,
                  darmbk.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by pstrusi, Today, 09:06 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post pstrusi
                  by pstrusi
                   
                  Started by vpzdcv, Today, 02:31 AM
                  0 responses
                  9 views
                  0 likes
                  Last Post vpzdcv
                  by vpzdcv
                   
                  Started by YevhenShynkarenko, Today, 01:22 AM
                  1 response
                  20 views
                  0 likes
                  Last Post YevhenShynkarenko  
                  Started by ttodua, Today, 12:52 AM
                  0 responses
                  8 views
                  0 likes
                  Last Post ttodua
                  by ttodua
                   
                  Started by ttodua, Today, 12:50 AM
                  0 responses
                  8 views
                  0 likes
                  Last Post ttodua
                  by ttodua
                   
                  Working...
                  X