Session Ready
Exercise

Using sigComparison

A sigComparison signal is a simple and useful way to compare two (hopefully related) quantities, such as two moving averages. Often, a sigComparison signal does not create a buy or sell signal by itself (as such a signal would involve buying or selling on every such day), but is most often useful as a filter for when another buy or sell rule should be followed.

In this exercise, you will use sigComparison() to generate a signal comparison that specifies that the 50-day simple moving average (SMA) must be above the 200-day simple moving average (SMA). You will label this signal longfilter, because it signals that the short-term average is above the long-term average.

Instructions
100 XP
  • Use add.signal() to add a sigComparison specifying that SMA50 must be greater than SMA200.
  • Label this signal longfilter.