1. More rule mechanics
2. More arguments to ruleSignal
Three more arguments to ruleSignal are the following: orderqty, ordertype, and orderside.
3. Using add.rule()
As you might guess, the orderqty argument specifies how much of an asset to buy or sell. Orderqty is a number that specifies the number of shares of the asset to buy, short (which is when a speculator borrows an asset, sells it, and has to buy it at a later date, hopefully at a lower price), or sell. Upon establishing a position with an enter type of rule, orderqty must take a static value. However, when using an exit rule, orderqty can also take the extremely useful "all" value, which will automatically reduce a position to zero and close out a trade.
The ordertype argument is the sort of ordering mechanism one will use to establish a position. This is not to be confused with the rule type, which is outside the scope of the ruleSignal argument. While ordertype can take multiple values such as market, limit, and other types of orders, for the purposes of this class, we will stick to the market ordertype, which denotes a market order. A market order is one that will buy or sell the asset, no matter what. In contrast, a limit order will only buy the asset if it falls below a certain price, while a stoplimit order will only buy the asset when it rises above a certain price. While some sophisticated traders swear against market orders, they are the go-to order type when you simply want to enter or exit into a position.
Lastly, orderside is an argument quantstrat uses to classify different rules. An orderside of long is a long trade--one that buys an asset in the hopes of selling it back at a higher price for a profit. Similarly, an orderside of short denotes a short trade--one that enters into a position at a high price and sells, in the hopes of buying the asset back at a lower price in the future. Due to the riskiness of short trades, we will focus only on the long side of trades in this class.
4. Let's practice!
In the following exercises, you will get some practice using these arguments.