简体   繁体   English

微调addADX()以避免截断趋势曲线

[英]Fine tuning addADX() to avoind truncating the trend curves

I am using the following code to look at the past 9 months of a stock. 我正在使用以下代码查看过去9个月的库存。

library(quantmod)
getSymbols("AMZN")
candleChart(to.weekly(AMZN),multi.col=TRUE,theme="white",subset='last 9 months') 
addADX()

You can see that the red line is essentially not included in the plot because it mostly lies below the value of 20. I want to modify the Y axis range of addADX so that it always shows all three lines. 您可以看到图中基本上不包含红线,因为它大部分位于20的值以下。我想修改addADX的Y轴范围,以便它始终显示所有三条线。 How would it be possible? 怎么可能呢?

The input parameters of addADX() only control the computation of the directional movement index - not the graphical parameters which are set according to the average direction index. addADX()的输入参数仅控制方向运动指数的计算, addADX()控制根据平均方向指数设置的图形参数。

A simple workaround to display the positive and negative direction index completely is to compute the directional movement index by yourself with ADX() from the TTR package and then add it to the previous chart with addTA() , which allows more customisation. 一个完整显示正向和负向索引的简单解决方法是,使用TTR包中的ADX()自己计算方向运动索引,然后使用addTA()将其添加到上一个图表中,从而可以进行更多自定义。

library(quantmod)
getSymbols("AMZN")
dat <- to.weekly(AMZN)
candleChart(dat, multi.col = TRUE, theme = "white", subset = "last 9 months")
adx <- ADX(HLC(dat), n = 14, maType = "EMA", wilder = TRUE)[, c("DIp", "DIn", "ADX")]
addTA(adx, col = c("green", "red", "blue"), lwd = c(1, 1, 2), legend = NULL)

ADXaddTA

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM