0
candleChart(NIFTY, multi.col = TRUE, theme = "white")
addEMA(n = 50, col = "red")
addEMA(n = 200, col = "green")

As I run this code, I get 3 charts. The first one simply plots it, then I get another one with the 50 EMA and then I get a third one with the the 200 EMA. How do I get simply the last chart? The charts I get are here.

The tail of the dataset I use is below:

      Date      Open     High      Low    Close Shares Traded Turnover (Rs. Cr)
  2018-10-03 10982.70 10989.05 10843.75 10858.25     398756507    21225.59
  2018-10-04 10754.70 10754.70 10547.25 10599.25     438202008    23711.57
  2018-10-05 10514.10 10540.65 10261.90 10316.45     625153832    25254.21
  2018-10-08 10310.15 10398.35 10198.40 10348.05     470279031    22130.94
  2018-10-09 10390.30 10397.60 10279.35 10301.05     443795275    18285.41
  2018-10-10 10331.85 10482.35 10318.25 10460.10     373844130    19592.59

then I use the code I mention above.

  • 1
    Hi and welcome to StackOverflow. Could you provide a minimal reproducible example so that we can help you more easily? You can find more about [reproducible example here](https://stackoverflow.com/a/5963610/9956805) – Rekyt Oct 11 '18 at 11:07
  • Hey @Rekyt I have added some of the Data I have used. Thanks! – Harshil Shah Oct 11 '18 at 11:40
  • @HarshilShah what is this object `NIFTY`? – JohnCoene Oct 11 '18 at 13:21
  • @JohnCoene This is an Indian index, similar to the Dow Jones or S&P500. I have retrieved the data from Quandl & assigned the variable NIFTY to it in my R notebook. – Harshil Shah Oct 12 '18 at 09:10

1 Answers1

0

When you want to add an EMA or another TA indicator and you use addEMA (or addXXX) you basically tell the function to take the current chart and add the EMA to it. This will create a new chart. If you are using Rmarkdown or a notebook you will indeed a new plot appearing for every addXXX you use. If you just want 1 plot you need to add all the TA's to the candleChart call like this:

candleChart(NIFTY, multi.col = TRUE, theme = "white", TA = c(addEMA(n = 50), addEMA(n = 200)))
phiver
  • 23,048
  • 14
  • 44
  • 56