Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R quantmod使用addTA添加光线条_R_Quantmod_Dynamic Chart Series - Fatal编程技术网

R quantmod使用addTA添加光线条

R quantmod使用addTA添加光线条,r,quantmod,dynamic-chart-series,R,Quantmod,Dynamic Chart Series,我想将光线条添加到使用chartSeries创建的图形中。 下面给出了示例数据和预期输出 > head(d1,10) Open High Low Close SMA elderH elderL 2016-01-13 201.35 202.40 194.00 200.90 211.8000 -9.400000 -17.800000 2016-01-14 197.00 201.50 194.30 196.05 208.2722

我想将光线条添加到使用
chartSeries
创建的图形中。 下面给出了示例数据和预期输出

> head(d1,10)
             Open   High    Low  Close      SMA     elderH     elderL
2016-01-13 201.35 202.40 194.00 200.90 211.8000  -9.400000 -17.800000
2016-01-14 197.00 201.50 194.30 196.05 208.2722  -6.772222 -13.972222
2016-01-15 197.80 197.80 181.00 184.30 204.2278  -6.427778 -23.227778
2016-01-18 184.90 188.15 179.15 181.00 200.1444 -11.994444 -20.994444
2016-01-19 182.15 187.80 181.50 182.95 196.3778  -8.577778 -14.877778
2016-01-20 180.65 180.65 171.50 173.65 192.3889 -11.738889 -20.888889
2016-01-21 177.00 178.65 172.05 175.60 188.6833 -10.033333 -16.633333
2016-01-22 179.90 185.40 178.30 184.60 186.4944  -1.094444  -8.194444
2016-01-25 187.90 188.80 182.50 182.95 184.6667   4.133333  -2.166667
2016-01-27 184.40 186.20 181.05 184.40 182.8333   3.366667  -1.783333
> 
预期产量

我搜索了所有可能的帮助,但最终克隆并编辑了“quantmod:::ChartVo”函数来绘制矩形。 虽然我能够实现所需的输出,但我认为这种方法并不正确。谁能用更好的方法来帮助我呢

附言:我没有注意标签,背景和前景的颜色。我更感兴趣的是为
eldersRay
绘制矩形(包括小矩形和大矩形)的方法,如图所示。 对quantmod:::chartVo函数中代码的更改

if(x@params$thin) {
  # plot thin volume bars if appropriate
  segments(x.pos,0,x.pos,Volumes,col=bar.col)
} else {
  #Siva - commented the rect function and added larger rectangles first followed by smaller ones
  #rect(x.pos-spacing/3,0,x.pos+spacing/3,Volumes,col=bar.col,border=border.col)

  up.H <- ifelse(Volumes$elderL>0,Volumes$elderH,0)
  up.L <- ifelse(Volumes$elderL>0,Volumes$elderL,0)

  dn.H <- ifelse(Volumes$elderL<0,Volumes$elderH,0)
  dn.L <- ifelse(Volumes$elderL<0,Volumes$elderL,0) 
  rect(x.pos-spacing/3,0,x.pos+spacing/3,up.H,col=x@params$colors$up.col,border=border.col)
  rect(x.pos-spacing/3,0,x.pos+spacing/3,dn.L,col=x@params$colors$dn.col,border=border.col)

  rect(x.pos-spacing/3,0,x.pos+spacing/3,up.L,col=x@params$colors$dn.col,border=border.col)
  rect(x.pos-spacing/3,0,x.pos+spacing/3,dn.H,col=x@params$colors$up.col,border=border.col)
}
if(x@params$thin){
#如果合适,绘制薄体积条
分段(x.pos、0、x.pos、卷、列=条形列)
}否则{
#Siva-对rect函数进行了注释,首先添加了较大的矩形,然后添加了较小的矩形
#rect(x.pos-spating/3,0,x.pos+spating/3,卷,列=条形列,边框=边框.col)
up.H 0,卷数$0(0)
升0,卷数$elderL,0)
dn.H