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!
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
NinjaTrader
Previous Days ATR Value
Collapse
X
-
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
-
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
-
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
-
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 FilesBertrandNinjaTrader Customer Service
Comment
-
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 f.saeidi, Today, 12:12 AM
|
0 responses
2 views
0 likes
|
Last Post
by f.saeidi
Today, 12:12 AM
|
||
Started by Conall, Today, 12:06 AM
|
0 responses
5 views
0 likes
|
Last Post
by Conall
Today, 12:06 AM
|
||
Started by proptradingshop, 03-21-2024, 09:50 AM
|
6 responses
27 views
0 likes
|
Last Post Today, 12:02 AM | ||
Started by mly916, Yesterday, 09:48 PM
|
1 response
11 views
0 likes
|
Last Post Yesterday, 11:54 PM | ||
Started by Mikey_, Yesterday, 09:21 PM
|
0 responses
11 views
0 likes
|
Last Post
by Mikey_
Yesterday, 09:21 PM
|
Comment