Thursday, July 25, 2013

Adding technical analysis indicator to stock chart

The quantmod support quite a number of stock technical analysis indicators. The list is shown in table below.
Below discribe the steps to add these indicators to the stock chart created by chartSeries:
1. Create the chart using chartSeries, details in previous post.
2. Use the quantmod name (listed in the table below) to add the indicator, eg:
               addVo()   # to add volume
               addCCI()  # to add Commodity Channel Index
               addBBands()  # to add Bollinger Bands
3. To add customizied indicator use the addTA function, eg:
               addTA(OpCl(AAPL),col='blue', type='h')  #add the Open to Close price change, quantmod OpCl function  

4. The code below show how to create a function to add customize indicator to stock chart using newTA:                addOpCl <- col="green" create="" function="" indicator="" nbsp="" newta="" pcl="" ta="" the="" to="" type="h" use="">               addOpCl()      # to add the custom TA to chart 5. Alternatively, the TA can be added directly in the chartSeries function when creating the chart, eg:                chartSeries(GS, theme="white", TA="addVo();addBBands();addCCI()")   

No comments:

Post a Comment