1. Learn
  2. /
  3. Courses
  4. /
  5. Financial Trading in R

Exercise

Apply your own indicator

Great job! Now you have a better understanding of indicators as functions that anyone can write. It's time to apply the indicator you created in the previous exercise. To do so, you will make use of the applyIndicators() command.

From debugging to subsetting, knowing how to step inside your strategy is a valuable piece of knowledge. Every so often, you might have an error in your strategy, and will want to track it down. Knowing how to use the applyIndicators() command will help you identify your errors. Furthermore, sometimes you may want to look at a small chunk of time in your strategy. This exercise will help train you to do this as well.

In order to subset time series data, use brackets with the start date, forward slash symbol, and end date. Both dates are in the same format as the from and to arguments for getSymbols() that you used in the first chapter. The quantstrat, TTR, and quantmod packages have once again been loaded for you.

Instructions

100 XP
  • Add the DVO indicator designed in the previous exercise with the default parameters. Label it DVO_2_126.
  • Using applyIndicators(), create a temporary object test containing the indicators that you've already applied. Use the open, high, low, and close of SPY as your test market data.
  • Subset your data between September 1, 2013 and September 5, 2013.