Visualize an indicator and guess its purpose - II
The Relative Strength Index (RSI) is another indicator that rises with positive price changes and falls with negative price changes. It is equal to 100 - 100/(1 + RS), where RS is the average gain over average loss over the lookback period. At various lengths, this indicator can range from a reversion indicator, to a trend filter, or anywhere in between. There are various ways of computing the RSI.
As you already know, RSI()
takes in a price series price
and a number of periods n
which has a default value of 14. Some traders believe that the 2-period RSI, also known as the RSI 2, has even more important properties than the 14-period RSI.
In this exercise, rather than plotting this indicator on the actual price series, you'll look at a small, one year subset of SPY and how the RSI interacts with the price. The quantmod
and TTR
packages and SPY
price series have been loaded into your workspace.
This exercise is part of the course
Financial Trading in R
Exercise instructions
- Plot the closing price of
SPY
. - Plot the RSI 2 of the closing price of
SPY
. - Is this 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 price of SPY
plot(___(___))
# Plot the RSI 2
plot(___(___(___), n = ___))
# What kind of indicator?
___