Here are 10 TR values:
9.4, 7.9, 5.2, 2.7, 4.9, 4.3, 6.3, 6.3, 4.3, 2.5
The sum of these TR values = 53.8 and the 10 period SMA of this is 5.38. MC gives the 10 period ATR as 5.38 (the SMA). This is erroneous.
The *approx* correct value for the 10 period ATR over this series is 5.0342, but as it is an EMA you would need all prior values to correctly calculate it. An EMA is "exponential" which means it relies on all past values. This is just the correct value for my series which is not all listed here.
Investopedia has the formula wrong too! Most other references on ATR will give the correct formula, but the clearest correct one is:
http://en.wikipedia.org/wiki/Average_true_range
What is annoying about Investopedia is that they actually reference Wilder's book, "New Concepts in Technical Trading Systems" and then ignore his formula. Wikipedia has it right.
For reference purposes here is my code:
Code: Select all
true_range = this.TrueRange(0); // Get TrueRange
true_range = this.AverageTrueRange( 1, 0 ); // Same as TrueRange
atr = this.AverageTrueRange( 10, 0 ); // Incorrect ATR returned