How to apply multiple TPs to a new chart using a quantum module?

We can draw a candlestick chart using the chart series function. chartSeries(Cl(PSEC))I created some custom values ​​( I1 , I2 and I3 ). which I want to focus (apply) beyond the candlestick pattern. I used addTA()for this purpose

chartSeries(Cl(PSEC)), TA="addTA(I1,col=2);addTA(I2,col=3);addTA(I3,col=4)")

The problem is that it allocates four graphs for Cl (PSEC), I1, I2 and I3 separately instead of the two graphs that I want Cl (PSEC) and (I1, I2, I3)

EDITED

For clarity, I give a sample code with the variable I1, I2, and I3 created for this purpose.

library(quantmod)
PSEC=getSymbols("PSEC",auto.assign=F)
price=Cl(PSEC)
I1=SMA(price,3)
I2=SMA(price,10)
I3=SMA(price,15)
chartSeries(price, TA="addTA(I1,col=2);addTA(I2,col=3);addTA(I3,col=4)")
+4
3

, . , on=2 TA :

library(quantmod)
getSymbols("PSEC")
price <- Cl(PSEC)
I1 <- SMA(price,3)
I2 <- SMA(price,10)
I3 <- SMA(price,15)
chartSeries(price, TA=list("addTA(I1, col=2)", "addTA(I2, col=4, on=2)",
                           "addTA(I3, col=5, on=2)"), subset = "last 6 months")

enter image description here

SMA , on=1 TA.

@hvollmeier, , .

PS: , ?addSMA(), with.col, (Cl - ).

+3

, , 3 SMA SUBPLOT NOT . , newTA. :

PSEC=getSymbols("PSEC",auto.assign=F)
price=Cl(PSEC)

SMA 10,30,50 :

chartSeries(price['2016'])
newSMA <- newTA(SMA, Cl, on=NA)
newSMA(10)
newSMA(30,on=2)
newSMA(50,on=2)

- on. on = NA TA, on 1, . on = NA . SMA , SMA. .. : -).

enter image description here

+2

, , quantmod (chart_Series chartSeries).

Pros: - Graphs look cleaner and better (?) - more flexibility by editing the parameters parsand themesup to chart_Series(see other examples here in the SO section for basic things you can do with parsand themes). Cons: -Not well documented.

PSEC=getSymbols("PSEC",auto.assign=F)
price=Cl(PSEC)
chart_Series(price, subset = '2016')
add_TA(SMA(price, 10))
add_TA(SMA(price, 30), on = 2, col = "green")
add_TA(SMA(price, 50), on = 2, col = "red")


# Make plot all at once (this approach is useful in shiny applications):
print(chart_Series(price, subset = '2016', TA = 'add_TA(SMA(price, 10), yaxis = list(0, 10));
add_TA(SMA(price, 30), on = 2, col = "purple"); add_TA(SMA(price, 50), on = 2, col = "red")'))

enter image description here

+2
source

All Articles