Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

an alternative Quantmod ZigZag overlay

Tags:

r

quantmod

i'm currently using quantmod ZigZag overlay and i noticed it is calculated a bit differently then the original overlay. I've demonstrated the difference in the following picture of RDWR using ZigZag(5%) with quantmod and a with a different program. as you can see quantmod is missing allot of significant points peaks and highs. you can also see the difference pretty clearly when using StockCharts.

I think it's because of the way quantmod smooth the trend. the algorithm should be using both high & low values and not just an average price or some other regression. i was wondering if quantmod or maybe TTR provide an alternative ZigZag overlay that will produced the desired output (illustrated in the upper part of the picture).

Thanks.

the code for displaying the quantmod output in the picture is

s<-get(getSymbols('rdwr'))["2012-07::"]
chart_Series(s)
add_TA(ZigZag(s,5),on=1)
like image 434
haki Avatar asked Feb 09 '13 22:02

haki


1 Answers

The problem is that ?ZigZag says the input should be a high/low price series and you provided an OHLCVA series. It works correctly if you provide a high/low series.

s <- getSymbols('rdwr', auto.assign=FALSE)
chart_Series(s, subset="2012-07::")
add_TA(ZigZag(s[,2:3],5),on=1)

enter image description here

like image 154
Joshua Ulrich Avatar answered Sep 18 '22 12:09

Joshua Ulrich