Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.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
在Quantmod中的chartSeries上绘制线_R_Quantmod - Fatal编程技术网

在Quantmod中的chartSeries上绘制线

在Quantmod中的chartSeries上绘制线,r,quantmod,R,Quantmod,这很好: getSymbols("EBAY") chartSeries(EBAY,TA=NULL, theme="white") addTA(EMA(Cl(EBAY)), on=1, col=6) abline(h=50, col = 6) 但这会绘制图表系列,但不会绘制水平线。不知道我错过了什么 S <- as.xts(read.zoo(text="date,open,high,low,close,volume 2017-03-10 18:00:00,442.50,442.50,4

这很好:

getSymbols("EBAY") 
chartSeries(EBAY,TA=NULL, theme="white")
addTA(EMA(Cl(EBAY)), on=1, col=6)
abline(h=50, col = 6) 
但这会绘制
图表系列
,但不会绘制水平线。不知道我错过了什么

S <- as.xts(read.zoo(text="date,open,high,low,close,volume
2017-03-10 18:00:00,442.50,442.50,442.50,442.50,1
2017-03-10 18:01:00,442.50,442.50,442.50,442.50,8
2017-03-10 18:02:00,442.50,442.50,442.50,442.50,2
2017-03-10 18:03:00,442.50,442.50,442.50,442.50,3
2017-03-10 18:04:00,442.50,442.50,442.50,442.50,68
2017-03-10 18:05:00,442.50,442.50,442.50,442.50,20
2017-03-10 18:06:00,442.25,442.25,442.25,442.25,10
2017-03-10 18:07:00,442.50,442.50,442.25,442.25,3
2017-03-10 18:08:00,442.25,442.50,442.25,442.50,2
2017-03-10 18:09:00,442.25,442.25,442.25,442.25,38",
FUN=paste, FUN2=as.POSIXct, header=TRUE, sep=","))

chartSeries(S, theme = chartTheme("white"), type = "candle") #subset = m,TA = NULL)
abline(h=442.3, col = 6) 
#segments(0, 442.3, 90, 442.3)

S您的第一个示例之所以有效,是因为设备上只有一个绘图(OHLC蜡烛)。第二个示例不起作用,因为该设备包括两个图,OHLC蜡烛和低音量条形图

如果要使用类似于
abline
的方法将行添加到
chartSeries
中,则应使用
addLines

chartSeries(S, theme=chartTheme("white"), type="candle")
addLines(h=442.3, col=6)

Charles,你能提供一段代码来复制SYes吗,这很好,但现在我有另一个问题。多个addLines()命令似乎只显示最后绘制的一行。@CharlesStangor:在顶层的交互式会话中对我很好。我猜您正在函数或循环中调用
chartSeries
,需要在
plot
中包装调用。我在一个闪亮的renderPlot()函数中。不确定“在plot中包装调用”是什么意思。我以为plot是一个单独的库。