What is Backtesting
Backtesting is a process by which trading strategies are tested on historical data.
Due to the sheer amount of data and computation need, backtesting is very resource-intensive process.
Using historical data, we can get an idea whether the trading idea/strategy is performing as expected or not.
Backtesting is done as a preliminary step before deploying the strategy in live market.
It is to be noted that backtesting and live trading may produce diverse results due to slippage.
The time duration required to complete a backtest depends on the complexity of the strategy, the timeframe/candle frequency used and the period/range of backtest.
What is the Backtest?
A Backtest is a simulation that evaluates the performance of an investment strategy or trading algorithm on historical data.
Essentially, it allows you to test your hypothesis by seeing how it would have performed in past market conditions.
To conduct a backtest, you will typically start by selecting a time period and gathering relevant data such as stock prices, economic indicators, and news events.
Next, you will apply your chosen investment strategy or algorithm to this historical data set and measure its results.
The goal of a backtest is to identify any flaws in your strategy before investing real money into it.
By analyzing the simulated results of your approach against actual market conditions from the past, you can gain confidence that it could perform well in future scenarios.
What's new with Backtest Engine V2
- Faster speed
- Improved deploy modal allowing you to choose Intraday and Positional strategies
- Add notes to distinguish multiple BT reports of same strategy and date ranges with just one click
- Mobile notifications on completion along with emails
- Longer date range at one go even for strategies with lists
- Reports with more more insightful output variables
- Ability to quickly navigate to Edit strategy from BT page itself
- Nicer UX with min by min updates of completion status of the BT
- Counters now have dates as well for quick analysis of daily PNL
- Summary of BT credits purchased, used and balance with one click to find details of the same from BT page itself.
Tradetron Backtest Engine
Tradetron Backtesting Engine V2 is one of the most powerful backtesting service available in the market.
Tradetron Backtesting Engine is designed to handle complex strategies involving many sets and lot of positions.
Tradetron backtesting universe includes all NSE cash stocks, futures and Index FnO
Backtesting Engine does not support stock options, stock futures, MCX, CDS and NASDAQ
Backtesting Engine does not distinguish between order types MIS, NRML &CNC.
Backtesting Engine does not recognize the following variables/keywords:
- India VIX
- All OI related keywords
- Bid price, Ask price
- Bid-Ask Difference
- Sec
- VWMA
- VWAP Series
- VWAP
Backtesting Engine also does not consider corporate actions, SLM orders, advanced price execution settings, tranching, rollovers and overnight protection positions.
Backtest Parameters
To conduct any backtest in Tradetron there are certain parameters that users have to input for successful backtesting of strategies.
- Date Range – Tradetron has historical data available since 1st Jan 2020 to conduct backtests. We have predefined ranges like last 6months, 18months etc or you can also add a custom date range
- Candle frequency - Users have an option to select their choice of candle frequency from 1min, 5min, 10min, 15min, 30min, 1hr and full day(1D).
If you are backtesting a strategy which uses daily timeframe, it would be advisable to select candle frequency as Full day or lower than Full day.
Similarly, if you are backtesting a strategy which uses multiple time frame like 15min and 1hr, select candle frequency less than or equal to the lowest time frame in the strategy, in this case it would 15min.
The smaller the candle frequency, the more computation is needed which increases the time to complete the backtest.
Note: If your strategy uses time conditions for entry/exit or uses LTP keyword anywhere in the strategy, 1min candle frequency would provide more accurate results.
- Trade Price – Unlike other backtesting services, Tradetron provides the users with the power to select the trade price of execution.
There are two options either Open or Close. Trade price essentially means the price at which the trade is executed.
If you are backtesting a strategy that relies on entry after crossovers or any technical indicators, Open Price would be well suited for the purpose.
If you are backtesting any strategy that relies on entry on close price basis, select Close in Trade Price
- Type – Here, you get an option to select the type of strategy you are backtesting, Intraday or Positional. Kindly select the appropriate option depending on your strategy.
If you select Positional, it will further provide 3 Options. Select the one that best fits your strategy
1. None –Select this, if you are trading stocks which do not have an expiry
2. Weekly- Select this, if you are trading Weekly Options
3. Monthly –Select this, if you are trading monthly Options or futures
Backtest Credit Consumption
Backtests credits usage is calculated based on the backtest period and the no. of underlying in the strategy, if using lists.
For a period of 180 days, backtest credit consumed will be 1.
Similarly, if you backtest for 360 days, Backtest credit consumed will be 2 and so on.
#Criteria 1:
If underlyings in list >= 5 then max. 5 credits for 6 months period
#Criteria 2:
If underlyings in list < 5 then each underlying will consume 1 credit each for 6 month period.
Note - If the list contains more than 20 stocks, the backtest duration is limited to 7 days
Let's understand using the below examples:
1. If a user is backtesting a strategy with Index_fut list with 2 underlying Nifty and BankNifty for 6 months, then the count of underlying is 2 in the list.
So the Backtest credit required will be 2 for 6 months of data
2. If a user is backtesting a list of 20 stocks for 360 days, since no. of underlying is 20 which is greater than 5, the max credit it will consume is still 5 for 6 months of data, so in this case, it will only consume 2*5=10 credits for a period of 360 days even though there are 20 stocks in the list
3. If a user is backtesting a simple banknifty straddle for 360 days, backtest credit consumed will be 2
Backtest Status
Once you have posted for backtest, it will reflect the below status sequentially:
- In Queue - This means that the backtest is in queue and will start soon
- % Completed - This means that the backtest has started and is in the process
- Generating Report – This means that the Backtest is completed and is currently in the process of generating a detailed report with important metrics
- Completed - This simply means that the backtest is complete and you can check your email for reports or can download the same from the backtest page
Note - Once the Backtest is complete, it will move to the Completed section
Interpreting Backtest Report
As soon as the backtest is complete, a comprehensive detailed backtest report is sent to the user’s email address.
This report consists of key performance metrics for the strategy. You can also download the Stats pdf and positions CSV from the backtest page too.
It makes it very convenient for the user to do their own analysis based on the trades taken by the backtest engine.
Backtest report consists of the below stats:
PNL Curve – A PNL curve is a graphical representation of the change in the value of a Profit/loss over a period of time
Capital Required - The total starting capital for the strategy
Total PNL - The total profit/loss generated during the entire backtest period
Drawdown - Drawdown expressed in % terms refers to the degree to which the PNL curve drops from the peak (Highest point) to a trough (Lowest point)
Standard Deviation - Standard deviation is the statistical measure of volatility. It is also expressed in % terms. The lower the Std.dev, the more reliable the strategy.
Sharpe Ratio - Sharpe ratio is a measure for calculating risk-adjusted return. Strategies with higher market excess returns and lower volatility will show higher Sharpe Ratios. So naturally, higher is better.
For Annualized Sharpe Ratio, the Risk-free rate is considered as 0
Total Trading Days - Total no. of trading sessions in the selected backtest period
Win Days - This parameter tells you the no. of profitable days
Loss Days - This parameter tells you the no. of loss days
Win Rate – Simply put, this parameter tells the trading system’s win ratio. The bigger, the better. It is calculated using the formula - < Total profit days / Total trading sessions in Backtest period>
Avg Monthly Profit – Average profit generated per month
Avg Monthly ROI – Average ROI generated per month, Capital is considered as the base of all returns. It is calculated using the formula - < Total PNL/ (Total trading days * 21) >
Total ROI – Total ROI generated for the duration of the backtest.
Max Profit in a Day — Maximum Profit generated in a trading day
Max Loss in a Day – Maximum Loss generated in a trading day
Avg PL Daily – Total PNL/total trading days in the selected backtest period
Avg Profit on Profit Days – Average Profit generated on Profitable days
Avg Loss on Loss Days – Average Loss generated on Loss days
Avg no. of trades (Buy + Sell) per day – Average no. of trades in a day(Only sessions on which strategy took trades are considered)
Month-wise PNL -This shows the month-wise distribution of Profit/Loss over the duration of backtest.
Position CSV– All the positions taken by the strategy during the backtesting period are displayed under this. Additional useful information like condition, price and quantity is mentioned in the report.
Checklist before Backtesting
- Please ensure your strategy does not use the restricted keywords mentioned above.
- Please paper trade the strategy beforehand to check if it takes entry/exits according to your conditions.
- Please ensure that your strategy only includes NSE cash stocks/ Futures or Index FnO.
- Please check if your set exit/Universal exit conditions are proper before backtesting.
- .Keep in mind that backtesting does not follow rollovers, advanced price execution settings, SLM orders, tranching & overnight protection.
- Refrain from editing the strategy while the backtest is in progress.
How to find Backtest ID
Go to the Backtest Page, Click on the BID button and a number should appear. That number is your Backtest ID.
Backtest Credit Refunds
If you have purchased backtest and due to some reason would like a refund of the remaining unused backtest credits, you can email [email protected] and team will refund the amount based on unused credits.
Credit Usage Summary
Credit Usage Summary
With the new Backtest V2 engine, we have also added a new credit usage summary tab to easily get an overview of your backtest credits.
You can click on the Credits and Used section as highlighted in the image to get a detailed report on the backtest credit usage
You can easily monitor how many credits you have left and can also easily purchase new credits using the Buy BT button.
Backtest credits once purchased will not expire and is valid indefinitely.
Frequently Asked Questions On Backtesting
1. What is portfolio backtest?
A portfolio backtest is a process of testing the performance of an investment portfolio by applying historical data and simulations to assess how it would have performed in the past.
This analysis helps investors to evaluate their investment strategies, identify potential risks, and optimize their portfolios.
To perform a portfolio backtest, you need to select a benchmark index that reflects your investment objectives and choose an appropriate time period based on relevant market conditions.
Then, you can use software or spreadsheets to input your portfolio holdings and rebalancing rules for each period.
The backtesting process then calculates returns for each period using the historical prices of assets in your portfolio and compares them against the benchmark index.
You can also incorporate factors such as dividends, taxes, fees, transaction costs into your analysis to get more accurate results.
2. How to backtest a trading strategy?
Backtesting a trading strategy is an important step in evaluating its potential profitability.
Here are the steps to effectively backtest your trading strategy:
Step 1: Define Your Trading Strategy
Start by defining the rules that will govern your trades. This includes deciding on the entry and exit points, stop-loss orders, take-profit targets, and any other relevant trade management rules.
Step 2: Gather Historical Data
Collect historical data for the security or market you want to test your strategy against. The more data you have, the more accurate your results will be.
Step 3: Set Up Your Backtesting Platform
Choose a platform that allows you to input your trading rules and run simulations based on historical data. Some popular platforms for backtesting include MetaTrader4 (MT4), TradingView, and Amibroker.
Step 4: Run Simulations
Input your trading parameters into the backtesting platform and run simulations using historical data. Evaluate how well your strategy would perform over different time frames and market conditions.
Step 5: Analyze Results
After running multiple simulations, analyze the results to determine if there are any patterns or trends in performance.
Look at metrics such as profit/loss ratio, win rate, drawdowns, risk-to-reward ratios, etc., to gain insight into how effective your strategy may be in real-world trading scenarios.
In conclusion, backtesting a trading strategy requires careful planning and analysis of historical data using specialized software tools.
3. What is backtesting in algo trading?
Backtesting in algo trading is the process of evaluating a trading strategy using historical data to simulate how it would have performed in the past.
The purpose of backtesting is to assess whether a particular algorithmic trading system or strategy would have been profitable if applied during a given period.
To conduct backtesting, traders create sets of rules and conditions that dictate when and how trades are executed based on certain market indicators or trends.
These rules are then applied retrospectively to historical price data, allowing traders to see how the strategy would have performed over this specified time frame.
By analyzing these results, traders can gain insights into which strategies work best under different market conditions and refine their algorithms accordingly.
They can also use backtesting as part of their risk management strategy by identifying potential weaknesses before applying them in real-time trading environments.
Overall, backtesting is an essential tool for algo traders looking to optimize their strategies and make more informed decisions about which trades they should execute.
It allows them to test out multiple scenarios without risking any actual capital, helping them build confidence in their ability to succeed while limiting downside risks associated with live-trading experimentation.
4. How much backtesting is enough?
The amount of backtesting needed ultimately depends on the complexity and risk associated with the trading strategy.
A simple strategy may only require a few months of historical data to test its effectiveness, while a more complex or high-risk strategy may require years of data.
It's important to note that backtesting is not a foolproof method for predicting future performance, as market conditions can change rapidly and unexpectedly.
Therefore, it's recommended to conduct multiple rounds of testing using different time periods and scenarios to ensure the results are consistent.
5. What is the purpose of backtesting?
Backtesting serves as a crucial tool for traders and investors to evaluate the effectiveness of their trading strategies.
It involves analyzing historical data to determine how a particular investment strategy would have performed in the past under various market conditions.
The primary purpose of backtesting is to identify potential flaws or weaknesses in trading strategies before they are used in real-world scenarios.
By simulating trades using historical data, traders can measure the profitability and risk associated with specific positions, thereby allowing them to make more informed decisions about future investments.
Additionally, backtesting helps traders optimize their strategies by identifying areas that require improvement or adjustment.
For instance, if a trader's strategy consistently underperforms during certain market conditions, they may need to revise their approach or find new indicators that better predict these events.
Overall, backtesting allows traders and investors to test their ideas empirically while minimizing the risks of live trading.
It enables them to gain a deeper understanding of market behavior and develop more effective strategies that can produce consistent profits over time.