AVERAGE TRUE RANGE
OK so I use Thomson One. For whatever reason, the capabilities are limited so we have to employ a few hacks and workarounds to get to our final result.
First we have to figure out the true range for a day, which is the greater of the difference between (the absolute values of):
1. Today’s high and low
2. Today’s high and yesterday’s close
3. Yesterday’s close and today’s low.
I have a nice little picture of how this works somewhere.
The text string we get to use is unreasonably low, so we have to create 3 functions and then nest them into an “IF” function to get the True Range. We are going to label each of the above ranges as T1, T2, and T3. Therefore we have:
- T1 = h - l
- T2 = abs( h - ref(c, -1) )
- T3 = abs( ref(c, -1) – l )
Where:
h = high
l = low
c = close
abs() = absolute value (because these could be negative)
ref(x, -y) = reference (look back) value of variable x, y periods ago
Now that we have T1, T2 and T3 defined, we can define True Range as
TR = IF ( T1 > T2, IF ( T1 > T3, T1, T3 ), IF ( T2 > T3 , T2 , T3 ) )
This is two nested “IF” functions, in the traditional “IF” language of:
IF ( logical test, value if true, value if false )
Which means:
If (today’s high minus low) is greater than (the absolute difference between yesterday’s close and today’s high), then if (today’s high minus low) is also greater than (the absolute difference between today’s low and yesterday’s close), then use (today’s high minus low), otherwise use (the absolute difference between today’s low and yesterday’s close), unless (today’s high minus low) was originally not greater than (the absolute difference between yesterday’s close and today’s high), in which case use (the absolute difference between yesterday’s close and today’s high) unless that is smaller than (the absolute difference between today’s low and yesterday’s close).
Hopefully you don't have to get this granular with your software, but I did, and at any rate, it’s good to know how things break down, so you can pull a MacGuyver when needed.
Note that this would have been unnecessary if we could just use the max() function, in which case we could just use:
max ( T1, T2, T3 )
Or just
max ( h - l , abs( h - ref(c, -1) ) , abs( ref(c, -1) – l ) )
Which would have been a lot simpler. But try saying that to the Thomson One Support Team, who won’t return my emails anymore.