an alternative Quantmod ZigZag overlay

2020-07-10 09:06发布

问题:

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)

回答1:

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)



标签: r quantmod