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

Connected

Exercise

Visualize an indicator and guess its purpose - I

Now you will visualize these indicators to understand why you might want to use the indicator and what it may represent. Recall that a trend indicator attempts to predict whether a price will continue in its current direction, whereas a reversion indicator attempts to predict whether an increasing price will soon decrease, or the opposite.

In this exercise, you will revisit the 200-day SMA. As a refresher, this indicator attempts to smooth out prices, but comes with a tradeoff - a lag. You will plot the prices of SPY and plot a 200-day SMA on top of the price series. Using this information, you will determine if it is a trend indicator or reversion indicator.

The quantmod and TTR packages and price series SPY have been loaded into your workspace.

Instructions

100 XP
  • Plot the closing prices of SPY.
  • Overlay a 200-day SMA of the closing prices using the lines() function and color it red.
  • Is the 200-day SMA a trend or a reversion indicator? Print your answer as either "trend" or "reversion" in the console.