Articles on: Trading Essentials

Backtesting in Altrady

Introduction


Backtesting is the process of testing a trading strategy using historical market data to see how it would have performed in the past. This can help evaluate whether a strategy is potentially profitable before risking real money.
Altrady's backtesting feature simulates real trading in a similar way to our paper trading paper trading. However, it uses its own simulated balances, and does not require a live or paper account.
During backtesting, the candle history for the market is shown, one candle at a time, at your selected speed. This allows the trader to create or change orders in the same way as you would during live trading, mimicking the trading strategy you want to test.
Almost all order types and features can be used with backtesting; the exception is OCO orders.


Contents

Video Overview
Background
Starting a Backtesting Session


Video Overview


Background

Four Altrady widgets are used for backtesting. When Backtesting mode is enabled, these widgets are used to manage and control the backtest session, and are not available for regular use:

  • Chart Widget (with Backtest control bar): Create and control backtesting; start and stop sessions; start and stop candle replay, adjust replay timing; edit orders in the chart; create alerts.
  • Trading widget (with message at the top: Backtesting): Create and edit orders for the backtest session; view balances
  • Position Info widget: view analytics for positions created during the current session
  • Backtest widget: Manage, edit, view and select backtest sessions. Start a new session.



Starting a Backtesting Session


Using the Chart


Within the Trading Terminal, there is a button labelled Replay at the top of the Chart widget. Backtesting mode can be activated by interacting with it.


  1. Click on the Replay icon displayed at the top of the chart. This will allow the Replay start-time to be selected.


  1. Click before the desired candle on the chart, to set the Replay start-time accordingly.


  1. A new window will appear on-screen. To enter backtesting mode, click on Backtest.


To immediately enter backtesting mode in the future, tick Remember my choice, before clicking Backtest.


  1. In the following window, adjust the parameters for the backtesting session as desired.


A) A name for the session being created, can be specified here.
B) The market to create the backtesting session can be chosen here.
C) A quote currency balance to start the backtesting session with, can be specified here.
D) A base currency balance to start the backtesting session with, can be specified here.
E) A start date/time for the backtesting session can be defined here.
F) An end date/time for the backtesting session can be defined here.
G) These Random Bar buttons. They can be used to set a random date for both the Start and End dates, respectively.


Once all parameters have been specified as desired, click Create.



  1. Once Create has been clicked, the chart should change and the most recent data shown on the chart, should correlate with the Start date/time that was set. The backtesting controls should also be visible at the bottom of the chart.



Backtesting Controls


There are multiple controls available when backtesting mode is activated. These controls, along with their functions, are explained below.



  1. Switch to Replay Mode


Clicking this button would switch from Backtesting Mode to Replay Mode.


To learn more about Replay Mode, refer to the following article:


  1. Start Time


Clicking this button would allow a new start time to be set, for the current Backtesting session.


This works similarly to the Replay button in the Chart widget, which entails clicking before a candle on the chart, to set the start time.


  1. Random Bar Dropdown Menu


The downward pointing arrow can be clicked, to display an option titled Random Bar.


Clicking this button, would set the start time for the backtesting session to a random date/time.


  1. Back to Start


This button works similarly to a restart button, for the backtesting session.


Clicking this button would restart the backtesting session from the start time that is currently set on it.


  1. Play


This button allows the backtesting session to be played or paused.


When the backtesting session is playing, this button will be displayed as a pause button. When the backtesting session is paused, this button will be displayed as a play button.


  1. Step


This button allows the backtesting session to be skipped forward by one-step-at-a-time.


Clicking this button would skip to the next candle/bar in the backtesting session.


  1. Auto-Resume


This button allows the backtesting session to either be paused or un-paused automatically, once an event has occurred during the backtesting session.


When it is enabled, the session will not be paused once an event has occurred (e.g. order fill, alert trigger).


When it disabled, the session will be paused each time an event occurs (e.g. order fill, alert trigger) and the session will need to be un-paused manually.


  1. Replay Speed


This button allows for the playback speed in the backtesting session to be altered. The speed selected determines how fast each candle/bar is drawn on the chart during playback.


  1. Exit Backtesting


This button would exit the backtesting session, but would not terminate it.


Once exited, the backtesting session can be resumed from the Backtest widget when desired.


To learn more about the Backtests widget, refer to the following article:


The Backtests Widget


This widget is used for managing backtesting sessions. It also enables backtesting data to be viewed more closely.
For the Altrady default layouts, the widget will be enabled automatically.
For custom layouts, it will not be enabled by default. The first time a backtesting session is started, a message will be shown, suggesting that the Backtest widget be enabled.


Enabling the Backtests Widget


  1. In the Trading Terminal, click on the Widgets button in the top-right.


  1. In the dropdown menu that is displayed, tick the box next to Backtests.


  1. The Backtests widget will appear on-screen and may be grouped with other widgets by default.



Saving and Resuming Backtesting Sessions


By default, all backtesting sessions are saved and can be resumed, if they have not yet been marked as Finished.


Progress within a backtesting session will not be saved unless trading has occurred within it.


To resume a backtesting session:


  1. In the Backtests widget, navigate to the Running section.


  1. Find the the desired backtesting session to be resumed. This can be done by searching for a backtesting session by name, or by scrolling through the list of running backtesting sessions.


  1. To resume a chosen backtesting session, click on the green Resume button next to the desired session.
  2. On the following window, click Yes to resume the backtesting session. The market the backtesting session was started on, will be opened in the Chart and the session will be resumed from where the last trade occurred.







Frequently Asked Questions


How Does Backtesting Compare to Live Trading?


Since backtesting relies on previous market history, orders are filled solely against the price displayed on the chart. The order book is not used. Therefore, orders do not need to be matched against orders from other traders, in order for them to be filled. Once the price exceeds the order price by one step the order will be marked as filled.


This is in contrast to live trading, whereby orders do need to be matched against other orders in the market, for them to be filled. This means that in a live scenario, the actual fill prices of certain orders will be different (e.g. with Market orders), some orders may take longer to fill, even when the price in the market has reached their price (e.g. Limit orders), and in some cases there would not be enough liquidity in the order book for an order to fill.


Lastly, the fee rate considered in backtesting is the same as paper trading.


Why Are My Results Different to a Live Position?


Results shown in backtesting may differ with results from a live position.


This is due to the fact that orders are not matched against orders from other traders when backtesting (i.e. there is no order book), the fee rate used is not the same fee rate used by the exchange and the only consideration for orders being filled or not, is whether the price in the market has reached the order price.


Does it Matter Which Trading Account is Selected?


This does not matter in backtesting, as trading accounts are not utilized in backtesting mode.


Instead, balances are defined before the backtesting session is started and used only for the backtesting session.


Can I Use the Base Scanner in Backtesting Mode?


If the Base Scanner is included in your subscription, Bases can be seen on the chart in backtesting mode and manual base trading can be backtested.
The data that is available for bases is the same as is available outside of backtesting mode. Only the most recent 1000 hours (~6 weeks) of bases are available.


Does it Work for Futures?


Yes, backtesting mode works on Futures exchanges, even without a Futures account.
Liquidation Price, Margin, and leverage are shown in the Position Info widget. The Liquidation Price is an estimated price assuming isolated margin mode and may differ from the exchange.
Also, liquidations are not actioned--the price is shown for information only. A price alert can be set at the liquidation price to let you know whether your position would have been liquidated.
For all Futures exchanges, hedge mode is enabled by default and cannot be changed. To mimic one-way mode, only open positions in one direction at the same time.


Can more than one position or order be tested at the same time?


Yes. Each time a new smart order is created and placed, a new position will be shown in the Position Info widget, tracking each position separately.
This will also work for hedged positions on futures markets.



Updated on: 04/07/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!