Exercise

Using sigThreshold - I

In the next two exercises, you will focus on the sigThreshold signal. The sigThreshold signal is mainly used for comparing an indicator to a fixed number, which usually has applications for bounded oscillators, or perhaps rolling statistical scores (for example, for a trading strategy that might choose to go long when a ratio of mean to standard deviation is at -2, or vice versa). Whereas sigComparison and sigCrossover deal with quantities that are usually based off of an indicator that takes values in the same general area as prices, sigThreshold exists specifically to cover those situations outside the bounds of indicators that take values similar to prices.

Furthermore, the sigThreshold() function takes the cross argument, which specifies whether it will function similarly to sigComparison (cross = FALSE) or sigCrossover (cross = TRUE), respectively. In this exercise, you will implement a variant of sigThreshold that functions similarly to sigComparison.

Your job will be to implement a sigThreshold that checks whether or not DVO_2_126 is under 20. This signal will serve as one of the two switches that need to be "on" in order to enter into a long position in the strategy.

Instructions

100 XP
  • Use add.signal() to add a sigThreshold signal specifying that the DVO_2_126 must be under 20.
  • Set cross equal to FALSE.
  • Label this signal longthreshold.