Session Ready
Exercise

Using add.rule() to implement an entry rule

Excellent! You've mastered every element of the rule building process in quantstrat. While thus far you've added rules step-by-step, now it's time to put it all together and see how well you've been able to absorb the material in this chapter.

The opposite of an exit rule is an enter rule. On enter rules, orderqty cannot be set to "all" because there is no initial position on which to act. In this exercise, you will implement an enter rule that references the longentry signal in your strategy and will buy one share of an asset.

Instructions
100 XP
  • Specify the arguments in add.rule() to implement your new enter rule.
  • Your rule should be triggered when the longentry signal is equal to TRUE.
  • Your rule should buy 1 share of an asset as a "market" order.
  • Your rule side should be long and replace should be FALSE.
  • Your rule should buy on the next day's Open after observing a signal.