开始使用免费开始使用

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.

本练习是课程的一部分

Financial Trading in R

查看课程

练习说明

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

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Plot the closing price of SPY
plot(___(___))

# Plot the RSI 2
plot(___(___(___), n = ___))

# What kind of indicator?
___
编辑并运行代码