Backtesting in Altrady
Introduction
Backtesting is the process of testing a trading strategy using historical market data to evaluate its past performance. This helps assess whether a strategy might be profitable—without risking real money.
Altrady’s backtesting simulates trading similarly to paper trading, but uses its own simulated balances. No live or paper account is required.
The market’s candle history is replayed one bar at a time at your chosen speed. You can place or modify orders as if trading live, making it easy to test strategies under realistic conditions.
All standard order types are supported, except OCO and Trailing Stop orders.
Contents
Starting a Backtesting Session
- Enabling the Backtests Widget
- Backtest Widget Settings
- Information Shown in the Backtests Widget
- Starting a Backtesting Session
- Saving Backtesting Sessions
- Viewing Details for Backtesting Sessions
- Resuming Backtesting Sessions
- Stopping a Backtesting Session
- Marking Backtesting Sessions as Finished
- Deleting Backtesting Sessions
Placing Orders and Starting a Position During a Backtesting Session
Editing a Position During a Backtesting Session
- Comparing Backtesting Session Results
- Comparing Position Results in the Backtests Widget
- Comparing Position Results in the Position Info Widget
- How Does Backtesting Compare to Live Positions
- Why Are My Results Different to a Live Position?
- Does it Matter Which Trading Account is Selected
- Can I Use the Base Scanner in Backtesting Mode?
- Does it Work for Futures?
- Can More Than One Position or Order Be Tested at Once?
Video Overview
Background
Four widgets are used in backtesting. While active, these widgets are dedicated to the session and unavailable 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 (Replay Button)
- In the Trading Terminal, click the Replay icon at the top of the Chart widget.
- Click before the desired candle to select a start time.
- The Start replay session window will appear. Click Backtest to enter backtesting mode.
- In the Create Session window:
A) Name the session
B) Choose the market
C) Set the starting quote currency balance
D) Set the starting base currency balance
E) Define the start date/time
F) Define the end date/time
G) Use the Random Bar buttons to auto-generate start/end dates, respectively.
Click Create.
- The chart will reload based on the start time, and the backtesting controls will appear below.
Using the Chart (Right-Click Context Menu)
- Right-click on the chart, at the point where the backtesting session is to be started from, to display the context menu.
- Click Start replay from here.
- The Start replay session window will appear. Click Backtest to enter backtesting mode.
- In the Create Session window:
A) Name the session
B) Choose the market
C) Set the starting quote currency balance
D) Set the starting base currency balance
E) Define the start date/time
F) Define the end date/time
G) Use the Random Bar buttons to auto-generate Start/End dates, respectively.
Then click Create.
- The chart will reload based on the start time, and the backtesting controls will appear below.
Backtesting Controls
- Switch to Replay Mode: Exits backtesting and returns to replay mode.
- Start Time: Click before a candle to set a new start time.
- Random Bar: Randomly sets a start time.
- Back to Start: Restarts the session from the defined start time.
- Play/Pause: Toggles playback. Icon changes based on state.
- Step: Moves forward by one candle/bar.
- Auto-Resume:
- Enabled: Session continues after events (e.g. fills, alerts).
- Disabled: Session pauses after events until resumed manually.
- Replay Speed: Adjusts playback speed.
- Exit Backtesting: Leaves the session without ending it. Resume anytime from the Backtests widget.
The Backtests Widget
Use this widget to manage and resume sessions, and view detailed backtesting data.
For default layouts, it is enabled automatically. In custom layouts, a prompt appears the first time backtesting is launched.
Enabling the Backtests Widget
- Click the Widgets button in the top-right.
- In the dropdown, tick Backtests.
- The widget appears on-screen, grouped with others by default.
Backtest Widget Settings
- To access the backtest widget's settings, click on the cog icon in the top-right section of the widget.
- Once clicked, two settings will be displayed on-screen:
A) Smart trading mode
Once a backtesting session is resumed, this setting will be automatically enabled. Disabling it, will disable backtesting mode.
B) Quick start from chart
When this option is enabled, it prevents the Create Session window (shown in Step 2 here: Using the Chart) from being displayed, when a backtesting session is started from the Chart widget.
When enabled, the backtesting session start date/time will be according to where was clicked on the chart, as explained within the following section: Using the Chart. The end date/time will be the current date/time.
The quote and base currency amounts assigned within the session, will be the default amounts that are normally presented in the Create Session window.
Information Shown in the Backtests Widget
- + New: clicking this button allows for the creation of a new backtesting session.
- Running/Finished: toggling between running/finished, will display a list of backtesting sessions that have been marked as finished or are still running.
- Search Bar: search for a session by name.
- Name: the backtesting session's name is indicated within this column.
- Market, Resolution: the market that the backtesting session was started on, is indicated within this column.
- Positions: the number of positions started within the backtesting session is displayed within this column.
- Win rate: the number of losing (i.e. positions with negative closing PnL) or winning positions (i.e. positions with positive closing PnL) are displayed within this column.
- PnL: the profit and loss gained within the entire session is displayed within this column.
- Progress: how far the backtesting session has progressed, is displayed within this column.
- Resume: clicking this button allows for the resumption of an existing backtesting session (it will not be clickable if the session is already resumed).
- Details: clicking this button allows for further details to be viewed regarding the specific session.
Starting a Backtesting Session
- Click + New.
- The Create Session window will be displayed and there will be no start date set for the session. To specify one, click on the set start date field to display a calendar and choose a date/time. If needed, specify an end date/time as well.
- Click Create. The chart widget will be opened and the session will be started.
Managing Backtesting Sessions
Saving Backtesting Sessions
Backtesting sessions are saved automatically as trading occurs.
Viewing Details for Backtesting Sessions
- In the Backtests widget, click on either Running or Finished.
- Click on Details next to the desired session.
- Details regarding the selected session will be shown. The available options will vary depending on the status of the session (i.e. running not resumed, running and resumed, finished not stopped, finished and stopped)
A) Back button: returns to the Backtests widget's main window, where a list of running or finished sessions is shown.
B) Session name edit button: allows the session's name to be modified.
C) Stop: stops the session and disables backtesting mode simultaneously.
D) Delete: unavailable for resumed positions (for more information on deleting sessions, refer to the following section: Deleting Backtesting Sessions).
E) Finish: marks the current session as finished (for more information on marking sessions as finished, refer to the following section: Marking Backtesting Sessions as Finished).
A) Back button: returns to the Backtests widget's main window, where a list of running or finished sessions is shown.
B) Session name edit button: allows the session's name to be modified.
C) Resume: resumes the session and opens the chart widget (for more information on resuming a session, refer to the following section: Resuming Backtesting Sessions).
D) Delete: deletes the session (for more information on deleting a session, refer to the following section: Deleting Backtesting Sessions).
A) Back button: returns to the Backtests widget's main window, where a list of running or finished sessions is shown.
B) Session name edit button: allows the session's name to be modified.
C) Stop: stops the session and disables backtesting mode simultaneously.
D) Delete: unavailable for resumed sessions (for more information on deleting sessions, refer to the following section: Deleting Backtesting Sessions).
A) Back button: returns to the Backtests widget's main window, where a list of running or finished sessions is shown.
B) Session name edit button: allows the session's name to be modified.
C) Delete: deletes the session (for more information on deleting a session, refer to the following section: Deleting Backtesting Sessions).
- Analytics data is also shown on the details page. The analytics data shown therein is explained below.
A) Positions: the number of positions opened within the backtesting session are indicated here.
B) Win Rate: the percentage of winning positions (i.e. positions that closed with a positive PnL) vs losing positions (i.e. positions that closed with negative PnL) is displayed here.
C) PnL %: the total profit and loss percentage (includes all positions taken) for the entire backtesting session, is displayed here.
D) PnL: the total profit and loss (includes all positions taken) in the selected display currency is shown here, for the entire backtesting session.
E) Timeframe: the chart timeframe that the backtesting session was started on (e.g. 1 minute, 1 hour, 1 day), is displayed here.
F) Progress: how far the backtesting session has progressed is displayed here (if no trading occurs during the session, there will be no progress recorded).
G) Status: the current status of the session is displayed here (i.e. running, finished).
H) Replay start: the start date/time that was selected for the session is displayed here.
I) Replay end: the end date/time that was selected for the session is displayed here.
J) Last saved time: the last saved time within a stopped session is displayed here (the label for this metric will change depending on whether the position is resumed or stopped).
K) Current time at: the current time within a resumed session is displayed here (the label for this metric will change depending on whether the position is resumed or stopped).
Resuming Backtesting Sessions
- In the Backtests widget, open the Running section.
- Find the desired session by name or scroll the list.
- Click Resume next to the session.
- Click Yes to confirm. The chart widget will be opened and the session will resume on the same market, from the last trade point.
Stopping a Backtesting Session
- Resume a backtesting session as described in the following section: Resuming Backtesting Sessions. Then, navigate back to the Backtests widget, where the resumed session will be shown.
- Click on the Stop button.
- The session will be stopped and backtesting mode will be disabled simultaneously.
Marking Backtesting Sessions as Finished
- In the Backtests widget, open the Running section.
- Find the backtesting session to be marked as finished and resume it, as described here: Resuming Backtesting Sessions.
- The chart widget will be opened and the session will resume on the same market, from the last trade point.
- Return to the Backtests widget, where details for the resumed backtesting session will be shown. Click Finish to mark the session as finished.
- The session can then be viewed in the list of finished sessions.
Deleting Backtesting Sessions
Backtesting sessions can be deleted from within the Details page of a session.
- Access the Details page for the relevant session, as described within this section: Viewing Details for Backtesting Sessions.
- Click on the red dustbin (i.e. delete) icon.
- Click Yes to confirm that the session is deleted in the next window.
Placing Orders and Starting a Position During a Backtesting Session
Placing orders during a backtesting session, functions in the same as it does outside of a backtesting session. The following step-by-step process will make use of the Trading widget and chart to place orders.
Information regarding the position started, can be viewed in the Position Info widget.
- Once the Backtesting session has been started, choose whether to start a Long position, by placing a Buy order first or a Short position by placing a Sell order first.
- Choose the desired order type from the top of the Trading widget.
- Indicate the price (if relevant) and size of the order to be placed.
- If needed, add a Take Profit order and set it up as desired.
- Add a Stop Loss order if needed and set it up as desired.
- Add any Expiration/Auto close conditions if required.
- Click Place Order to place the order.
Editing a Position During a Backtesting Session
Editing a position during a backtesting session functions in the same way as it does outside of a backtesting session.
- Click on an open/pending order on the chart. To modify the price of an order, drag the order to the desired price, via the white part of the order handle.
- Navigate to the Trading widget, which will now be in edit mode. Additional changes can be made to the position here. To confirm the changes, scroll to the bottom of the widget and click Place Order.
- If Auto-Confirm orders is disabled at the bottom of the Trading widget, a confirmation window will be displayed. Click Confirm to proceed with the changes.
Comparing Backtesting Results
The results of different backtesting sessions and the positions taken within them, can be compared within the Backtests widget.
The Position Info widget can be used to study in-depth analytics for positions taken within a session.
Comparing Backtesting Session Results
- On the backtest widget's main page, a list of running or finished sessions is shown.
- To compare the results between different running or finished sessions, the metrics displayed within the available columns (e.g. Market, Resolution, Positions, Win rate, PnL, Progress), can be referred to.
Comparing Position Results in the Backtests Widget
- Access the details page for a backtesting session where trading has occurred.
- A list of positions will be viewable underneath the backtesting session's analytics. The columns within this section are explained below.
A) Time/duration: the time that the position was started is displayed here, along with its duration.
B) Cost: the cost of starting the position in quote currency and the currently selected display currency, is shown here.
C) PnL: the profit and loss percentage incurred within the position is displayed here.
D) PnL: the profit and loss amount incurred within the position is displayed here, in quote currency and the currently selected display currency.
Comparing Position Results in the Position Info Widget
- Ensure that a session where trading has occurred is resumed.
- Navigate to the Position Info widget.
- Use the Position field to switch between positions taken within the session, to see analytics data relevant to each one.
- To view further analytics, in regard to PnL Breakdown and Investments, click to open each section and scroll down.
Frequently Asked Questions
How Does Backtesting Compare to Live Trading?
Backtesting fills orders based solely on chart price, without an order book. Orders are filled once price crosses the order price.
In live trading, orders must match with real market orders, which can affect fill timing, execution price, and success due to liquidity.
Backtesting uses the same fee rate as paper trading.
Why Are My Results Different to a Live Position?
Differences occur because backtesting doesn’t use real market depth or exchange fees. Fills are based only on price crossing the order level.
Does it Matter Which Trading Account is Selected?
No. Balances are manually set before starting and don’t rely on actual trading accounts.
Can I Use the Base Scanner in Backtesting Mode?
Yes, if included in your subscription. Bases appear on the chart, and manual base trading can be tested. Only the latest ~1000 hours (~6 weeks) of base data is available.
Does it Work for Futures?
Yes. It works even without a Futures account.
- Liquidation price, margin, and leverage are shown. The Liquidation Price is an estimated price assuming Isolated margin mode and may differ from the exchange.
- Liquidations are not actioned--the price is shown for information only. A price alert can be set at the liquidation price, to help understand whether the position would have been liquidated.
- Hedge mode is always enabled; to simulate one-way mode, open positions in one direction only, at a single time.
Can More Than One Position or Order Be Tested at Once?
Yes. Each new smart order opens a separate position shown in the Position Info widget. Hedged futures positions are also supported.
Why Can't I Edit My Stop Loss with Protection: Follow Take Profit or Protection: Break Even After it Has Trailed?
Attempting to modify the Stop price for a Stop Loss with either of these protection types, after trailing has occurred, will display the following window:
- Clicking this button will reset the Stop price to the level it was moved to, after trailing occurred. The position will still be in edit mode after this is clicked. The edit will need to be cancelled thereafter, or any other changes to the position will still need to be confirmed, by clicking Place Order.
- Clicking this button will disable protection for the Stop loss and will allow it to be moved as desired. The position will still be in edit mode after this is clicked. Place Order will still need to be clicked to confirm that the protection is removed, alongside any other changes that might be made to the position.
Related Articles
Updated on: 24/07/2025
Thank you!