Trading Strategy Backtest

Update 2022/01/04: Backtest is a desktop Windows app I developed in the late 2000s. A couple of colleagues and I were studying futures day trading and we wanted to test strategies against historical data. We collaborated for a couple of years while experimenting, trading and evolving Backtest.

Some screen shots of my Trading Strategy Backtest application which I’ve been developing for the past couple of years. Two books by Robert Pardo provide some of the basis of my automated trading methodology; 1) Design, Testing, and Optimization of Trading Systems and 2) The Evaluation and Optimization of Trading Strategies.

Here’s what led me to develop it

Projects

Projects

Tick data are read in from ascii csv files
Projects

The Strategy tab is the business end of it. The trading strategies have numerous adjustable parameters. The Backtest engine iterates through all specified parameter values as specified here. The product of the sizes of the parameter sets is the total # of cases to be iterated through. This is a pretty standard way of defining/representing this data set. In this example I am testing a “Stochastics with EMA filter” by Robert Colby.
Projects

Results filtering is an optimization of mine. Rather than save the entire result set from the run, we can specify the n best and m worst cases to save where best and worst are the best and worst from specified columns of the result set. The #Threads allows us to take advantage of multi core/CPU architecture. Run time can take anywhere from minutes to days and more. In practice I typically choose strategy parameter sets that generate a few hundred thousand cases which takes 10 or 20 hours to run.
Projects

Projects

The results from a run are presented in a spreadsheet like window.
Projects

Chart shows the price, trades and indicators for the particular iteration.Projects

Pardo presents the correlation between equity curve and “Perfect Profit” as a method of choosing a strategy parameter set for walking forward as a means of guaging the relative robustness of a trading strategy. Perfect Profit is a guage of the maximum possible (theoretically) profit a market can yield for a given time frame. Basically a sum of the price differences between each and every candle for the period. The idea is to choose the strategy that more closely mirrors the market’s ups and downs.
Projects

And the Profit Report.

BackTest Profit Report 37994-Prep420080728.1_0-ES-1-1yr-20080725.txt

BackTest version 1.1.2
Date/Time of run 080728 08:37:02
Project Prep420080728
Instrument file C:mkmtickdataES-1-1yr-20080725.txt
Date Range in file 2007/07/24 – 2008/07/25
Date Range loaded 2007/10/19 – 2008/07/25
Date Range of Trading 2007/10/19 – 2008/07/25
Time Range 0 – 2400
Analysis 37994-Prep420080728.1_0-ES-1-1yr-20080725.txt
Iteration 37994

Instrument

Instrument ES
Tick size 0.25
Tick value 12.50
Contracts/trade 1.00
Slippage (ticks per side) 1.00
Commission ($.$$ per contract round trip) 5.00
Margin 100.00
Initial Acct Size 10000.00

Strategy ColbyStochEma

Strategy Parameters

Begin 830
Exit 1500
Stop 0.00
TrailStop 0
Target n/a
PerfProfMethod 0
RevPos 1
MaType 0
Ema 225
KPeriod 60
KSmooth 5
UpperBand 90
LowerBand 10
###### BackTest Strategy Parameters Begin ######
Strategy: ColbyStochEma
Parameter            Begin        End  Increment
Begin:                 830          0          0
Exit:                 1500          0          0
Stop:                 0.00          0          0
TrailStop:               0          0          0
Target:                n/a          0          0
PerfProfMethod:          0          0          0
RevPos:                  1          0          0
MaType:                  0          0          0
Ema:                   225          0          0
KPeriod:                60          0          0
KSmooth:                 5          0          0
UpperBand:              90          0          0
LowerBand:              10          0          0
###### BackTest Strategy Parameters End ########

The Numbers

Net Long Short
Total Net Profit 15355.00 4950.00 10405.00
Total Gross Profit 26517.50 10780.00 15737.50
Total Gross Loss -11162.50 -5830.00 -5332.50
Total Trades 79 40 39
Num targets 0 0 0
Num stops 0 0 0
Num MOCs 76 38 38
Total Pct Profitable 62.03 60.00 64.10
Win 49 24 25
Loss 30 16 14
Largest Win 1232.50 1232.50 1207.50
Largest Loss -892.50 -892.50 -880.00
Avg Win 541.17 449.17 629.50
Avg Loss -372.08 -364.38 -380.89
Avg Win to Avg Loss 1.45 1.23 1.65
Avg Trade 194.37 123.75 266.79
Max Con Win 9 2 3
Max Con Loss 3 2 3
Avg Win Streak 190.00 194.00 185.00
Avg Loss Streak 223.00 225.00 220.00
Max Drawdown -1297.50 -1375.00 -1287.50
Drawdown Dates 2008/02/11 13:32 2007/11/20 14:59 2008/02/07 14:59
Sterling 11.83 3.60 8.08
Profit Factor 4.80 1.85 2.95
Max Contracts Held 1.00 1.00 1.00
Acct Size Reqd 1297.50 1375.00 1287.50
Return on Acct 153.55 360.00 808.16
PRR 1.72 1.18 1.86
CC Eq PP 0.9843 0.0000 0.0000

Holidays skipped

(2007/11/09) (2007/11/12) (2007/11/21) (2007/11/22) (2007/11/23) (2007/12/24) (2007/12/30) (2008/07/04)

Trades

Date Time Misc Name Price Volume Points Profit Total Total Weekly Total Monthly Equity
10000.00
Fri 2007/10/19 11:19:01 S short entry 1546.00 1
2007/10/19 14:59:00 B MOC 1523.25 1 22.75 1107.50 1107.50 1107.50 11107.50
Mon 2007/10/22 13:04:00 B long entry 1524.00 1
2007/10/22 14:59:00 S MOC 1527.50 1 3.50 145.00 1252.50 11252.50
Wed 2007/10/24 11:16:01 S short entry 1520.50 1
2007/10/24 14:59:00 B MOC 1537.50 1 -17.00 -880.00 372.50 10372.50
Fri 2007/10/26 08:51:01 B long entry 1547.50 1
2007/10/26 14:59:00 S MOC 1554.75 1 7.25 332.50 705.00 -402.50 705.00 10705.00
Thu 2007/11/01 09:45:00 S short entry 1549.00 1
2007/11/01 14:59:00 B MOC 1526.75 1 22.25 1082.50 1787.50 1082.50 11787.50
Wed 2007/11/07 13:20:00 S short entry 1514.00 1
2007/11/07 14:59:00 B MOC 1495.50 1 18.50 895.00 2682.50 12682.50
Thu 2007/11/08 13:02:01 S short entry 1482.25 1
2007/11/08 14:59:00 B MOC 1494.00 1 -11.75 -617.50 2065.00 277.50 12065.00
Tue 2007/11/13 11:36:00 B long entry 1475.25 1
2007/11/13 14:59:00 S MOC 1500.50 1 25.25 1232.50 3297.50 13297.50
Wed 2007/11/14 08:55:01 B long entry 1503.50 1
2007/11/14 14:59:00 S MOC 1487.00 1 -16.50 -855.00 2442.50 377.50 12442.50
Mon 2007/11/19 11:26:01 S short entry 1459.50 1
2007/11/19 14:59:00 B MOC 1452.00 1 7.50 345.00 2787.50 12787.50
Mon 2008/07/21 11:42:01 S short entry 1261.00 1
2008/07/21 14:59:00 B MOC 1259.50 1 1.50 45.00 15355.00 45.00 2587.50 25355.00