This article will describe how to use the different Qualifier Building Blocks in your Quantacula models. As we discussed previously, a Quantacula Building Block Model is composed of Entry and Exit Blocks, each of which can have one or more Condition Blocks attached to them. Qualifiers are a way to provide a certain twist to Conditions. Each Condition Block can accommodate a single Qualifier Block.
This Qualifier causes the associated Condition to resolve to true only if it occurs for a certain number of consecutive bars (trading day on a daily scale). In the example below, we set up a Condition to buy at market open if the RSI (Relative Strength Index) indicator is below 35. Assuming we are backtesting on a daily scale, our Qualifier changes the logic so that the RSI indicator must be below 35 for 3 trading days in a row for the buy to occur.
The Quantacula backtester iterates over the historical data during a backtest, processing the model’s logic one bar at a time. Conditions are evaluated based on the historical data of the current bar being processed. The N Bars Ago Qualifier lets you instead move the Condition test back in history, causing it to be evaluated on previous data. The example below uses two Conditions to enter at market. The logic resolves to: Buy next bar at market open if today’s RSI is below 35 and yesterday’s RSI was below 30.
This Qualifier lets you implement cases where a Condition occurs a certain number of times within a fixed time span. For example, you might take action when closing price moves up 2% or more at least 3 times within the past 10 trading days, as shown below. We use the ROC (Rate of Change) indicator to determine if closing price has moved at least 2% in one day.
This Qualifier broadens a Condition's scope, causing it to resolve to true if it occurred at least once within the specified time span. For example, the model below buys the next bar at market open if the RSI indicator is oversold (below 40), and price has crossed above its moving average some time within the past 5 trading days.
This Qualifier changes the symbol used for indicator calculations in the attached Condition. This lets you take action based on market conditions that are external to the symbol being processed. For example, here we buy at market open if the RSI of QQQ is oversold.