An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20131128/46346691/attachment.pl>
addATR() and addTA(ATR()) generate different plots
2 messages · manojit_roy at comcast.net, Joshua Ulrich
On Thu, Nov 28, 2013 at 9:33 AM, <manojit_roy at comcast.net> wrote:
I get different plots for ATR() when adding this indicator to my chart in two different ways (see last 2 lines of the code below):
require(quantmod)
getSymbols('GTAT')
ticker <- last(GTAT,'5 years')
barChart(ticker,TA=NULL,theme='white',major.ticks='months',minor.ticks=FALSE,show.grid=FALSE)
plot(addATR(n=20))
plot(addTA(ATR(ticker,n=20)$atr,col='blue',lwd=2))
Can someone help me understand what I am doing wrong, and which ATR values I should use?
ATR requires a HLC object. You're passing an OHLCV object to it. Try: plot(addTA(ATR(HLC(ticker),n=20)$atr,col='blue',lwd=2)) TTR can't use the HLC function because HLC is in quantmod and quantmod depends on TTR. So, for the time being, you have to be thoughtful about the columns in the object you pass to TTR functions. Best, -- Joshua Ulrich | about.me/joshuaulrich FOSS Trading | www.fosstrading.com