Back Testing

Published Oct 12, 2024

The Back Testing screen can be accessed from the Alerts menu in the Main Menu.

Back Testing is a method traders use to evaluate their trading strategies against historical market conditions. Analyzing the profit or loss generated by a trading system in the past can help traders identify potential risks and reduce the likelihood of losses in real-time trading.

Back Testing

 

The Abacus Back Testing engine evaluates a user’s trading system performance using nearly two dozen scientific profit, loss, and risk measurements. Abacus allows users to define specific instructions for buying, selling, holding, and exiting simulated trades.

How to Run a Back Test:

  1. Enter and verify your buy, sell, and exit scripts.
  2. Click the Back Test button.
  • The Buy Script contains a set of instructions for buying (going long).
  • The Shell Script contains a set of instructions for selling (going short).

 

The scripts required are based on the Abacus programming language. For complete details, refer to the Abacus programming guide.

Note: Clicking on the Script Guide will open the TradeScript Help document, which provides users with guidance on how to write Buy, Sell, and Exit scripts.

Stocko's back-testing

 

Users can add symbols by clicking on the Select Symbol button. This will open the Select Symbol window, allowing users to choose symbols from any exchange for performing Backtesting.

Back Test Results Overview

Some trading strategies may perform well across a wide range of securities but work poorly with certain ones. Possible reasons for this include low market liquidity for a particular stock (low volume), high volatility, or other market factors.

It is a good idea to test your trading strategy across a variety of securities. Just because a strategy isn’t very profitable with one security doesn’t necessarily mean it won’t perform well with another.

The values on the Backtesting page represent various measurements related to the profitability and risk of your trading system when tested using the symbol specified at the top of the backtesting screen. The results provided offer an overall picture of how your strategy might perform if implemented as a live trading system.

Overview of Back Test Outputs

Total Number of Trades

A total number of trades including buying, sell, and exit trades.

Average Number of Trades per Month

An average number of trades per month, including buy-sell, and exit trades.

Number of Profitable Trades

A total number of profitable trades since the beginning of the backtest.

Number of Losing Trades

A total number of non-profitable trades since the beginning of the backtest.

Total Profit

Total profit since the beginning of the backtest.

Total Loss

Total loss since the beginning of the backtest.

Percent Profit

Percentage of profitable trades since the beginning of the backtest.

Largest Profit

Largest single trade profit.

Largest Loss

Largest single trade loss.

Maximum Drawdown

The maximum account drawdown is defined as the percentage retrenchment from the equity peak to the equity valley. A drawdown begins when an equity retrenchment starts and continues until a new equity high is achieved.

Maximum Drawdown (Monte Carlo)

This is similar to the maximum drawdown, except the test is repeated 5,000 times, with each iteration introducing a small random slippage. This method is preferred over the regular drawdown as it accounts for variability and randomness in trading conditions.

Value-Added Monthly Index (VAMI)

The VAMI (Value-Added Monthly Index) reflects the growth of a hypothetical $1,000 in a given investment over time. The index starts at $1,000 at inception. Subsequent month-end values are calculated by multiplying the previous month’s VAMI index by 1 plus the current monthly rate of return.

Where Vami 0=1000 and
Where R N=Return for period N
Vami N = (1 + R N) X Vami N-1

Compound Monthly ROR

The geometric mean represents the monthly average return, assuming the same rate of return for each period. It calculates the equivalent compound growth rate that reflects the actual return data over time.

Standard Deviation

Measure the degree of variation of returns around the mean (average) return. The higher the volatility of the investment returns, the higher the standard deviation will be.

Where R I = Return for period I
Where M R = Mean of return set R
Where N = Number of Periods
M R = (∑ R I) ÷ N
I=1
(∑ (R I – M R) 2 ÷ (N – 1)) ½

Annualized Standard Deviation 

Standard Deviation X (12) ½

Downside Deviation (MAR = 10%)

The downside deviation is similar to standard deviation but focuses only on returns that fall below a defined Minimum Acceptable Return (MAR), rather than using the arithmetic mean.

For example, if the MAR is assumed to be 10%, the downside deviation measures the variation of each period’s return that falls below 10%.

In contrast, the loss standard deviation considers only losing periods, calculates the average return of those losing periods, and then measures the variation between each losing return and this average.

Where R I = Return for period I
Where N = Number of Periods
Where R MAR = Period Minimum Acceptable Return
Where L I = R I – R MAR (IF R I – R MAR < 0) or 0 ( IF R I – R MAR &sup3; 0 )
((S (L I) 2) ¸ N) &frac12;
I = 1

Downside Deviation = ((S (L I) 2) ¸ N) &frac12;

Where NL = Number of Periods where R I – M < 0

Sharpe Ratio

A measure developed by William Sharpe that is defined as the incremental average return of an investment over the risk-free rate. Risk (denominator) is defined as the standard deviation of the investment returns.

Where R I = Return for period I
Where M R = Mean of return set R
Where N = Number of Periods
Where SD = Period Standard Deviation
Where R RF = Period Risk Free Return
M R = (∑ R I) ÷ N
I = 1
SD = (∑(R I – M R) 2 ÷ (N – 1)) &frac12;
I=1
Sharpe Ratio= (M R – R RF) ÷ SD

Sortino Ratio (MAR = 5%)

A return/risk ratio developed by Frank Sortino. Return (numerator) is defined as the incremental compound average period return over a Minimum Acceptable Return (MAR). Risk (denominator) is defined as the downside Deviation below a Minimum Acceptable Return (MAR).

Where R I = Return for period I
Where N = Number of Periods
Where R MAR = Period Minimum Acceptable Return
Where DD MAR = Downside Deviation
Where L I = R I – R MAR (IF R I – R MAR < 0) or 0 (IF R I – R MAR ≥ 0)
DD MAR = ((∑( L I ) 2 ) ÷ N ) &frac12;
I=1
Sortino Ratio = (Compound Period Return – R MAR) ÷ DD MAR
Annualized Sortino ratio (MAR = 5%)
Annualized Sortino = Monthly Sortino X (12) &frac12;

Calmar Ratio

Return/risk ratio. Return (numerator) is defined as the Compound Annualized Rate of Return over the last 3 years. Risk (denominator) is defined as the Maximum Drawdown over the last 3 years. If three years of data are not available, the available data is used.

Sterling Ratio (MAR = 5%)

Return/risk ratio. Return (numerator) is defined as the Compound Annualized Rate of Return over the last 3 years. Risk (denominator) is defined as the Average Yearly Maximum Drawdown over the last 3 years less an arbitrary 10%. To calculate this average yearly drawdown, the latest 3 years (36 months) is divided into 3 separate 12-month periods and the maximum drawdown is calculated for each. These 3 drawdowns are averaged to produce the Average Yearly Maximum Drawdown for the 3-year period.

Where D1 Calmar Ratio = Average Annual ROR /Worst drawdown = Maximum Drawdown for first 12 months
Where D2 = Maximum Drawdown for next 12 months
Where D3 = Maximum Drawdown for latest 12 months
Average Drawdown = (D1 + D2 + D3) / 3
Sterling Ratio = Compound Annualized ROR /ABS ((Average Drawdown -10%))


Frequently Read Articles

Still need help?

South Asian Stocks Ltd. : NSE Member Code 09073, BSE Member Code 6329, MCX Member Code : 55215 , NCDEX Member Code : 1233 NSDL : IN-DP-474-2020 . SEBI Registration No. INZ000164738
Compliance Officer: NSE,BSE,MCX,NCDEX,NSDL : Mr RK Jain , 011-40409999 support@stocko.in
Registered Office : 3rd Floor, Building No.5, Local Shopping Complex, Rishabh Vihar, Near Karkarduma Metro Station. East Delhi – 110092


For any complaints related to South Asian Stocks Ltd email at complaints@stocko.in
Please ensure you carefully read the risk Disclosure Document.
Procedure to file a complaint on SEBI SCORES: Register on SCORES portal. Mandatory details for filing complaints on SCORES: Name, PAN, Address, Mobile Number, E-mail ID. Benefits: Effective communication, Speedy redressal of the grievances