Boolean Parameters

Many of the UDFs take a Boolean or binary parameter as a trigger for that function: TradeSystem(), Buy(), CancelAll() are examples. For the TradeSystem() function, the “Start” binary parameter simply enables everything else in the system as the cell reference changes between “0” and “1.”

But the Buy() and Sell() entry functions use a binary parameter with a subtle difference. With entry functions, the importance of this parameter is in how they change rather than what they are. We call this parameter “When” because a new order will be placed whenever that parameter changes to a non-zero integer.

 

After turning a system on, an entry function will enter an order if its parameter changes from “0” to “1.” It will place another order if the parameter changes from “1” to “2.” And, another order if the parameter changes from “2” to “1.” The only number this parameter can change to without entering a new order is “0.”

 

Therefore, traders may want to incorporate a mechanism that increments this parameter in order to keep track of how many orders have been placed while the system has been running. Or, traders may switch this parameter back to “0” after every new order entry.

 

Your choice will depend on what you need to accomplish, your process for debugging, and your organizational needs. In our example above, we can manually modify cell B5 (to any value greater than 0) to trigger a new order. This is a common way to develop trading systems when you need to see what happens when a new order goes in but do not want to wait until your real condition becomes true. However, in most cases, users will reference another cell value for that parameter. For example, we could have an Excel formula that returns “1” if the previous 1-minute bar’s close was above the previous 10-period moving average, or “0” otherwise.