Now that we picked some stocks from our dividend universe, by the way doesn’t necessarily have to be restricted to dividend stocks, we could acquire some shares and invest in them. Once bought, a buy and hold strategy could be adopted. Or alternately, one could follow some kind of strategy in the management of these shares, In other words, it can be sold, then after determining that conditions warrant it, shares could be reacquired. Some kind of definitive logic should undermine the positions one holds in such securities. This really is what is commonly referred as trading strategies, or if applied to historic data, backtesting such a trading strategy.
One would be normally be working market price data, i.e., daily prices. Of course, one could also work with fundamental data, i.e., balance sheet, income statements and so on. We will defer the fundamental analysis for later and instead concentrate on technical analysis.
As expected, there are very good R packages available and we will be using quantmod and its dependencies. Installing this will automatically install dependent packages as well, e,g, the TTR package which contains innumerable functions for coming up with various measures. We will illustrate some of these here. Another advantage of installing quantmod is that it has a function getSymbols, which can be used to get data on a real-time basis from some data providers. Provided of course, that we have either subscribed to or registered api keys with them.
There are a plethora of technical indicators available in the TTR package as documented in this reference guide TTR
Some examples of charts using quantmod. This is for symbol MMM. We will plot the prices which shows in candlestick form, and to the basic price plot, we will add Bollinger Bands, Moving Average Convergence/Divergence (MACD) as well as the ADX also known as the Directional Movement Indicator.
The quantmod package has various other options for charting, including several different color themes etc., which can all be explored at leisure.
Install packages
if(!is.element("quantmod", installed.packages()[,1]) )
install.packages("quantmod")equire (quantmod)
# uses default theme may change via theme="white" etc., need to find hemes
chartSeries(MMM)
addBBands()
addADX()
addMACD()
basic
### Zoom into period Oct 2017 April 2018
### Add the EMA indicator to previous plot
zoomChart(subset='2017-10::2018-04')
addEMA()
As mentioned above, the TTR – Technical Trading Rules package is a dependency which will automatically get installed. This package has many functions for all the common indicators in use by the investment/trading community. A few of these will be illustrated below. A look at the package pdf or description will provide a good exposition of what is available. Most functions operate on just one vector usually a price vector, which could be any of Open, High, Low or Close. Some functions require 3 price vectors, for example the ADX or Directional Movement Indicator needs HLC (High, Low & Close). Some need Volume as well. Note that all of this data will automatically be downloaded by the getSymbols function.
A flavor of indicators produced shown below. These will be immensely useful in developing trading strategies.
Thanx for reading
промокод на мелбет на первый депозит. Click Here:👉 https://mebel-3d.ru/libraries/news/?melbet_2020_promokod_dlya_registracii_besplatno.html
промокод в 1xbet. Click Here:👉 http://www.newlcn.com/pages/news/promo_kod_1xbet_na_segodnya_pri_registracii.html
👉 $5,000 FREE EXCHANGE BONUSES BELOW 📈 👉 PlaseFuture FREE $3,000 BONUS + 0% Maker Fees 📈 + PROMOCODE FOR NEWS USERS OF THE EXCHANGE 👉 [M0345IHZFN] — 0.01 BTC 👉 site: https://buycrypto.in.net Our site is a secure platform that makes it easy to buy, sell, and store cryptocurrency like Bitcoin, Ethereum, and More. We are available in over 30 countries worldwide.