QuantiX Pro Help

Tutorial 1: Advanced Backtest

Backtesting is the process of using historical price data to evaluate a strategy. It helps traders and analysts measure the performance of a strategy in terms of profitability and risk. Through backtesting, you can gain deeper insights into the specifications of a strategy and use this knowledge to improve it.
In the previous tutorial, we discussed how to run a backtest in the simplest way possible on our platform. In this tutorial, we aim to explore the comprehensive capabilities of our backtesting engine. This includes further discussion of previously covered topics as well as the introduction of new options to provide users with greater flexibility.
Our backtesting engine is a highly integrated tool that allows you to run backtests on various financial markets including stocks, cryptocurrencies, and Forex. It offers extensive position and money management configurations to ensure sufficient flexibility.
In the following sections, we explain how you can fully leverage the capabilities of our backtesting engine.

Backtest Configurations

To run a backtest with the two defined signals, open New Backtest from Stocks/Crypto section of Backtests menu. Every backtest consists of four main parts:

  • General

  • Signal

  • Position Management

  • Stop Loss and Take Profit

General

This page configures the general parameters of the backtest. Enter a name for the backtest in the Name box and select the market data where the signals are located. Choose as many pairs as you want from the Pair(s) dropdown box. The backtest will be run separately for each selected asset. You can also use group pairs to select multiple pairs in bulk. For more details on these options, read 'Backtest Documentation'.
Once the pairs are selected, use Timeframe to define the timeframe of the backtest. You can select multiple time ranges from Time Range(s) tab. If multiple time ranges are selected, a separate backtest will be run for each time range. Note that only time ranges within the available market data range are supported.
You can set a trading fee to simulate the broker or exchange commissions. Note that fee varies depending on the broker or exchange being simulated.
Leverage option allows you to apply leverage to your trades. There are two modes for applying leverage:

  • Constant mode

  • Conditional mode

In Constant mode, the leverage value remains fixed throughout the backtest. To use this mode, enable Leverage and enter the desired leverage value in the Leverage box.

drawing

When Conditional mode is used, the user can apply different leverage values based on various market situations. To enable this mode, turn Conditional Leverage on and click on the Conditional Leverage box.
In the Conditional leverage window, there is a default signal and a default value is required. The value entered in this box defines the default leverage applied when no specific conditions are met.

drawing

To define leverage values for specific conditions, click on Add New Row, then select a signal and assign a leverage value. When the selected signal is triggered (i.e., the signal's condition is met), the corresponding leverage value will be applied.
You can define multiple pairs of signals and corresponding leverage values to apply different leverage settings based on various market conditions. Note that the priority of added rows follows a top-to-bottom order. This means that if two signals are triggered simultaneously, the leverage value associated with the signal positioned higher in the list will take precedence.

Signal

Here, you can define your long and short entry and exit signals. By default, the system enables long trades, but if you wish to execute short trades, you can turn on Short Trade.
Note that our backtesting engine supports executing long and short trades simultaneously. However, to keep things simple, we will focus only on long trades in this example.
Click on Long Entry and select your buy signal (ma cross buy). Click on Long Exit and select your sell signal(ma cross sell). Once your signals are selected, click Continue to proceed.

Position Management

Position management has two main modules: Position Management and Pyramiding Settings.

  • When a signal contains multiple sub-signals, Entry Threshold and Exit Threshold allows users to specify the minimum number of sub-signals that must be true for the signal to trigger an entry or exit. For more details on these thresholds, refer to the backtest documentation.

  • Using Conditional Thresholds enable threshold adjustments based on other signals, following the same logic as Conditional Leverage. You can use other signals to define different thresholds for different scenarios. If none of the signals in the Conditional Threshold box are true, the default value is applied.

  • Pyramiding enables you to add steps to mitigate the risk of trading. Our pyramiding system supports two modes:

  1. Average Reduction: The system automatically adds a new step if the price drops by a specified percentage.

  2. Signal Based Pyramiding: The system waits for a buy signal, and if the price has dropped by a specified percentage, a new step is added.

In the Pyramiding box, you should define the maximum number of steps allowed for a position. This value must be a positive integer. For example, if you set this value to three, the money allocated for a position will be divided into four parts (since the first part is used to open the position). The size of each step may vary depending on the chosen accumulation type. The remaining three steps will be used if needed to add new positions.
If a sell signal is triggered before all steps are used, only the invested portion of the capital will affect your portfolio. Remember that sell signals sell the strategy holding all at once.
If you enable Conditional Pyramiding, different numbers of steps can be assigned based on different scenarios, following the same logic as Conditional Leverage and Conditional Thresholds.

  • In Pyramiding setting, three accumulation methods are available:

  1. Simple: The size of each pyramiding step is equal.

  2. Martingale: In this method, the size of each pyramiding step increases as the number of step increases. When martingale is used, you need to define a multiplier value.

    Example Calculation:

    If you set:
    Multiplier = 2, number of steps = 2
    Then to calculate the size of each step when $X is dedicated to a position, the following equation must be solved:
    X = BaseStep + BaseStep*2 + BaseStep*2*2
    X = 7*BaseStep => BaseStep = X/7
    The size of the first step is X/7 , the size of the second step is 2/7 *BaseStep, and the size of the third step is 4/7 * BaseStep. As seen, when Martingale is used, the largest portion of the capital is allocated to the last step.

  3. Custom Mode: This mode is similar to martingale but instead of defining a multiplier, the user can select the size of each step.

    Example Calculation:
    If Pyramiding = 2, then you will have 3 steps. When Custom Mode is used, you must define 3 multipliers for these steps. To do so, enter a number in Multiplier box and press enter to set the next one. Let's say you set multipliers as 1,4, and 5

    drawing

    To calculate the size of each step:
    X = BaseStep + BaseStep*4 + BaseStep*5
    X = 10*BaseStep => BaseStep = X/10

    Thus, the allocation per step is:

    1. Step 1 (Opening): 10% of the total capital (X/10).

    2. Step 2: 40% of total capital (4X/10).

    3. Step 3: 50% of total capital (5X/10).

  • Pyramiding Constraints:

    These add extra constraints to pyramiding. There are two types of constraints:

  1. Percentage Cool Down:

    When Percentage cool down is used, the price must drop by at least the specified percentage (use negative integers) before the system is allowed to add a step.

    • If you are using Average Reduction mode, the system will automatically add a step when the price drops by the defined Percentage.

    • In Signal Based Pyramiding, the system waits for a buy signal before adding a new step.

    Percentage Cool Down has a Reference box which determines how the price drop is measured.

    drawing

    You can choose from:

    • Last: Measures the price drop relative to the closing price of the most recently added step.

    • First: Uses the closing price of the point where the position was originally opened.

    • Average: Uses the average closing price of all previous steps as the reference.

    Another setting in Percentage Cool Down is Memory. It controls how price drops are tracked in Signal-Based Pyramiding:

    • If Memory = False, the price must drop by at least the defined percentage for a step to be added.

    • If Memory = True, a step will be added if the price has dropped by at least the defined percentage at any point from the last added step to the current candle.

    Note: When Average Reduction is used, the configuration of the Memory does not matter.

  2. Candle Cool Down:

    When candle cool down is used, there must be at least n candles (Number of Candles box) between the last added step and the new step. To read more about pyramiding, read the backtest documentation.

In the Pyramiding box, the maximum number of steps allowed for a position is defined. This has to be a positive integer value. For example, if you set this value to three, then the money allocated for a position will be broken into four parts (the size of each step may vary with respect to accumulation type) and the first part is used to open the position. The other three steps will be used (if needed) to add new steps. Note that if a sell signal comes before all parts are used, then only the amount of money engaged in the position will affect your portfolio. Remember that sell signals sell the strategy holding all at once. If you turn Dynamic Pyramiding, then different number of steps can be defined for different scenarios. The logic is again the same as that of dynamic leverage and dynamic thresholds. Three accumulation methods are available:

  • Simple: The size of pyramiding steps are equal

  • Martingale: The size of pyramiding steps are increased as the number of step increases. When martingale is used, you need to define a multiplier value. If you use Multiplier value of 2 and set the number of steps to 2, then to calculate the size of each step when $X is dedicated to a position, the following equation must be solved: X = BaseStep + BaseStep*2 + BaseStep*2*2 X = 7*BaseStep BaseStep = X/7 The size of the first step is X/7 , the size of the second step is 2/7 *BaseStep, and the size of the third step is 4/7 * BaseStep. As is seen, when martingale is used, the main part of money is dedicated to the last step.

  • Custom Mode: This is similar to martingale but instead of defining a multiplier, the user can select the size of each step. For example, if you set Pyramiding to 2, you will have 3 steps and when custom mode is used, you need to define 3 multipliers for these steps. To do so, set a number and press enter to set the next one. Let's say you use 1,4, and 5 as your multiplier values. To calculate the size of each step: X = BaseStep + BaseStep*4 + BaseStep*5 X = 10*BaseStep BaseStep = X/10 This way, 10 percent of the money dedicated to the position is used for opening, 40 percent is used for the second step and 50 percent is used for the last one. Pyramiding Constraints adds extra constraints to pyramiding. There are two types of constraints:

  • Percentage Cool Down: When candle cool down is used, the price must drop by at least Percentage percents (use negative integers) for the system to be allowed to add a step. If you are using Average Reduction mode, the system will automatically adda step when the price drops by Percentage percent but in the case of Signal Based Pyramiding, the system waits for a buy signal to add a new step. Reference defines the reference used for measuring the price drop. Use Last to measure the price drop with respect to the close price of the point where the most recent step was added. First uses the close price of the point where the position was opened. Average uses the average close price of all previous steps as its reference. When Memory is False, in the case of Signal Based Pyramiding, the price drop must be at least Percentage percent for the step to be added. If it is set to True, if the price drop has been lower than or equal to Percentage percent from the last added step to the current candle, the step is added. When Average Reduction is used, the configuration of the Memory does not matter.

  • Candle Cool Down: When candle cool down is used, there has to be at least Number of Candles candles between the last added step and the new step. To read more about pyramiding, read the backtest documentation. For this strategy, we use Average Reduction mode with Percentage Cool Down set to -5. Candle cool down is not used. The maximum number of steps is set to 2. Martingale accumulation with multiplier value of 1.5 is used.

Stop Loss and Take Profit

As the name implies, this section enables you to use stop-loss and take-profit orders. Our backtesting engine supports both normal and dynamic stop-loss/take-profit orders. Use positive values for both stop-loss and take-profit percentages.

  • In normal mode, the stop-loss or the take-profit is a fixed value.

  • In dynamic mode, users can leverage other signals to adjust the stop-loss or take-profit values.

With dynamic settings, you can define pairs of signals and stop loss/take profit percentage values. When a signal is triggered, the corresponding value in the pair is used. If none of the signals are triggered, a default value is applied.
Setting stop loss and take profit orders is a challenging, as optimal values vary depending on the market and even specific assets. Specifically, in the cryptocurrency market, due to its high volatility, using stop/loss and take/profit orders is generally not recommended for algorithmic trading. To read more about dynamic stop loss/take profit orders, read backtest documentation.

Last modified: 25 March 2025