I am seeing an issue with the ATR function and am not sure if it is a bug or an issue with how I am trying to use the function.
I am using the latest version of TA_LIB from the SVN trunk. I have built the libs successfully on Linux and am using SWIG to wrap TA-LIB for use with Python. All is working well so far except for this issue with ATR.
In short what I am seeing is that the ATR will match my expectations up until the last day in the series. In stead of the expected ATR the function is returning the last close. This is easy to see from the following output of the testcase I wrote to show this:
array([ 13.92, 20.25, 19.56, 13.38, 341.64])
Expected ATR is 10.850 not 341.64. This is the day's close for the last entry in the series.
I am not sure if this is a bug or a mistake in my accessing TA_LIB from python. This is the first time I have tried to use SWIG with Python and my first experience with TA-LIB (great package!)
Here is the python source for this program to show how I amusing the TA_ATR function:
from numpy import *
from TaLib import *
# data fields are for GOOG 5 days ending 2/26/09:
#  date (in matlab date2num format)
#  open
#  low
#  high
#  close
#  volume
data=[[733457.0, 357.0, 341.41, 359.8, 342.64, 4987408.0],
[733458.0, 339.20, 335.0, 348.92, 346.45, 6216742.0],
[733461.0, 346.68, 329.55, 349.8, 330.06, 5178393.0],
[733462.0, 331.0, 330.89, 349.62, 345.45, 6095415.0],
[733463.0, 343.11, 338.92, 352.30, 341.64, 6437530.0]]
# calculate the Average True Range of the daily data
# and return a new vector with the daily result
# TA_ATR start,end,high,low,close,lookback(day range)
day_atr = array(atr).astype('float')
# ATR according to stockcharts.com
print "ATR is 10.850"
Any help or guidance would be greatly appreciated. Please contact me via email:
sean at everson dot ws
Thanks in advance for your help!
Log in to post a comment.