2018年9月15日土曜日

draw the line between given points on candle chart addTA() addLines()



> candleChart(to.weekly(fas_shares * FAS[,4] +spxl_shares * SPXL[,4]+as.xts(c2+c3+c4,index(fas_shares))),theme='white')
> weekly_pf[106]
               open     high      low    close
2016-01-08 796732.6 804098.1 684234.9 684234.9
> length(index(weekly_pf))-106
[1] 140
>  tmp <- as.xts(append(rep(684234.9,106),approx(seq(1,2,1),c(684234.9,2170000),n=140,method="linear")$y),append(rep(as.Date("2016-01-08"),106),last(index(weekly_pf),n=140)))
> addTA(tmp,on=1,legend="slope")
# length(index(weekly_pf)) - 158 = 88
> tmp <- as.xts(append(rep(1189422,158),approx(seq(1,2,1),c(1189422,2170000),n=88,method="linear")$y),append(rep(as.Date("2017-01-06"),158),last(index(weekly_pf),n=88)))
> addTA(tmp,on=1,legend="slope")
> weekly_pf[158]
              open    high     low   close
2017-01-06 1160008 1189422 1160008 1189422
> weekly_pf[210]
              open    high     low   close
2018-01-05 1906271 1991231 1906271 1991231
> plot(addLines(v=c(106,158,210)))
> addTA(as.xts(approx(seq(1,2,1),c(600000,2170000),n=246,method="linear")$y,index(weekly_pf)),on=1,name='2100000')
> addTA(tmp,on=1,legend="slope")


0 件のコメント: