Get startedGet started for free

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.

This exercise is part of the course

Financial Trading in R

View Course

Exercise instructions

  • 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.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Plot the closing prices of SPY
___(___(___))

# Overlay a 200-day SMA
lines(___(___(___), n = ___), col = ___)

# What kind of indicator?
___
Edit and Run Code