Tutorial 2: Create a Strategy
To allow users to process technical indicators and other features, including candle patterns and price patterns, QuantiX offers an extensive list of processing functions. These functions enable users to implement trading strategies by defining conditions based on different features. Various conditions can be combined to create a trading strategy.
In this tutorial, we discuss QuantiX processing functions and demonstrate how to use them to implement a number of trading strategies. To use these functions, select the Edit option from the Actions menu in the Market Data Table. For more information on adding features to market data, please refer to the first tutorial.
Processing Functions Offered by the QuantiX Platform
There are a relatively large number of functions on our platform that allow you to develop your strategies. The following functions are available on the platform:
Advanced Labelling: Used to assign labels to candles based on feature values.
Age: Measures the duration for which a technical indicator has continuously maintained a condition.
Aggregation: Used to aggregate values of multiple numeric columns.
Arithmetic: Used to apply arithmetic operators (addition, subtraction, multiplication, division, exponentiation, remainder) between two numeric columns.
Cross: checks whether two lines intersect.
Diameter: Used to measure the distance between two lines.
History: Keeps track of previous states in columns.
Majority: Evaluates a categorical column (a column that contains labels) and checks if at least a certain number of candles in a user-defined window are identical.
Memory: Remembers a particular label of a candle for a specified duration.
Middle: Returns the middle value (the average value) of two lines.
Mix: Combines the information of different columns.
Normalized Slope: Normalizes the rate of change between any two candles to a range from -50 and 50.
Pivot: Identifies price pivots.
Shift: Moves any column (including both numeric and categorical columns) along the time axis.
Sort: Checks the order of the values of an arbitrary number of input lines.
To read more about these functions and how they are used, refer to the documentation. Note that QuantiX also offers a range of exclusive technical indicators that can be used for strategy development. The functions above, along with our exclusive indicators, enable users to employ quantitative analysis for trading and increase their profits.
Simple Strategy with RSI and CCI
Advanced Labelling allows you to break ranges of features by using thresholds and <, >, == operators and label candles based on the values of features. To use this function, you need to define the followings:
References: The columns in the market data that are involved.
Conditions: Labeling conditions are expressed here.
Not Matched Value: The label given to candles when none of the conditions in Conditions is met.
Output Column Name: The name given to the column where added labels are stored in.
For example, assume that we want to define a strategy that uses RSI and CCI indicators. The strategy states that When RSI is greater than 70, regardless of CCI, it is a sell signal. When RSI is below 30 and CCI is below -100, it is a buy signal. To implement this strategy with Advanced Labelling function:
Add RSI and CCI to your market data (from Add Feature tab) if they are not already added. Use rsi and cci as the name of the columns.
Select Advanced Labelling function from the features list.
Select RSI and CCI columns from References dropdown box.
Write no-action in Not Matched Value text box. This way, when neither buy nor sell conditions is true, the label given to the candle will be no-action.
Write cci_rsi_strategy in Column Name textbox. This will be the name of the column where the labels will be stored. In other words, this column contains the strategy's labels. Note that capital letters are not allowed in the names of the market data columns.
Define the strategy by defining suitable conditions.
How to Define Conditions
When a condition defined by Advanced Labeling becomes true, a label associated with the condition is assigned to the corresponding candle. Users can add as many conditions as they want. To add a condition, click on the Conditions box and then click on the Add Expression button.
In the Add Expression window, define a label and specify its condition in the "Condition" field. For example, to define a buying condition, enter buy in the Label box and use the built-in Helper Keyboard to write the following condition: rsi<30 and cci<-100
Now click on Add and the condition will be added to the Conditions box. Click on Add Expression again to add sell condition. To do so, write sell in the label box and for the condition use the followings: rsi>70
.
Note that you can also use < and == to create conditions. Moreover, instead of using and, you can use or operator to make different conditions. If rsi column is selected as the first column in References and cci is selected as the second one, the buy and sell conditions can also be defined in the following manner:
buy expression: {0}<30 and {1}<-100
sell expression: {0}>70
To read more about Advanced Labelling, please read its documentation page.
MA Cross Strategy
The MA cross strategy uses a fast and a slow moving average to identify trends in the market.
According to the strategy, when the fast moving average is below the slow moving average and then crosses above it, an upward trend begins. Conversely, when the fast moving average is above the slow moving average and then crosses below it, a downward trend begins. To define this strategy using the QuantiX platform:
Add two moving averages with different window lengths using the SMA function. Create two moving averages: one with a window length of 9, named fast and another with a window length of 20, named slow.
Use the Cross function to identify moving average (MA) crosses. In the Cross function window, set First Feature to fast and Second Feature to slow. Set the Column Name to ma_cross_strategy.
When you click the Add button in the Cross function window, a column named ma_cross_strategy will be added to the data. To view it, click on Grid go to the Columns tab, select ma_cross_strategy and press Apply. This will display a table containing not cross, cross over, and cross under. Additionally, you can use the filter icon to select specific labels:
Cross under indicates that the fast moving average moves below the slow moving average, while cross over means the fast moving average moves above the slow one. In other words, cross under can be used as the strategy's sell signal, and cross over can be used as the buy signal.
Trading Signals
A signal is an entity that can open or close a trading position. Signals can also be used to modify backtest settings, such as stop loss or take profit percentage values, during a backtest. To run a backtest, you need at least an entry signal and an exit signal.
We implemented MA cross strategy and added a column named ma_cross_strategy to the market data. This column contains the labels not cross, cross over, and cross under. To use these labels for trading assets, we first need to create buy and sell signals from this column.
To do this, open Signal Maker from Data Analysis menu and in opened window click on Add.
Let's start by creating buy signal:
In the Signal Name box, enter ma cross buy.
Select the market data where ma cross strategy column was added.
Choose the timeframe for which the signal is being defined in the Timeframe box.
Click on ADD and select ma cross strategy from the Categorical Feature box.
Open the Label dropdown box and select cross over.
Click Add and then Create to finalize your buy signal.
The same procedure applies to the sell signal:
Name it ma cross sell.
Select ma cross strategy again but this time choose cross under as the label.
Click Create to complete the process.
To read more about Signal Maker, read the documentation of this tool.