This is the first test of the algorithm, so there is no ‘curve fitting’ of the data. This is the raw output of the original algorithm, without adjustments or amendments to fit the market data.
Curve fitting is when you get the results of a back test and then adjust the algorithm to perform better with the data set. The problem is that the performance is then specific to that data set alone, and is unlikely to produce the same results going forward.
Whether this algorithm would produce the same results going forward is unknown. However it can be said that I have not adjusted the algorithm to fit the data set. The data set was an arbitrary choice of the last 2000 days in the US crude oil markets.
The algorithm looks for momentum in the market either upwards or downwards, and buys or sells accordingly. If the trend continues the algorithm will increase position size. All trades are then closed at 8pm (UK time) each night, so near the close of the US session. Trading starts from 9am UK time, each day.
There is a stop loss based on market volatility, and average range of the market.
The algorithm does not do much assessment of whether the market is in a trend or range before placing a trade. It looks for momentum in either direction. So performance could be improved (reducing draw-downs) by having daily monitoring of the algorithm/markets, and manually intervening if markets are clearly range bound.
As it is a trend following algorithm, it works on the principle of being wrong more than right, but being much more profitable on those correct occasions. In general markets are range bound more than they trend, but strong trends can be profitable enough to outweigh any previous losses.
The chart below illustrates returns over the past 2000 days in the US (CL) crude oil markets. Crude Oil was chosen as it has a tendency to trend, more so than the stock market. The final day of the test was 10th January 2020.
As can be seen the returns are profitable throughout, there is no negative balance. However this could be luck with a good starting point. If the algorithm was started at a time of heavily range-bound markets, there could have been an initial loss.
The maximum position size is around 30 lots of the CL contract (US crude oil). With most brokers to trade one lot of the CL contract intra-day, requires a $1000 maintenance margin. So in theory this back test could have been done with an initial balance of $30,000. However realistically around $40k or $50k would be required to cover any potential initial loss, and costs.
The peak balance was $937240, so very close to one million. With some adjustments one million could have been achieved, however I don’t want to adjust the algorithm in hindsight, just to fit this data set.

These results are purely a demonstration of how an algorithm can find patterns in the market based on a set of ideas, and trade them profitably. Unfortunately past performance is not a guarantee of future performance, and a different result may be found over another time period.
However, some key interesting points in regards to these results are:
- The returns are fairly smooth, there is not a huge amount of volatility in the performance
- The algorithm was based around an idea, not a data set. It wasn’t even created for the crude oil market. The algorithm was created to maximise on any trending market. Crude Oil was chosen after the algorithm was made, as in theory it should trend more than a stock market. However no reference to any data set was made, when creating the algorithm.
- The algorithm has not been ‘curve fitted’ post testing.
- Performance and draw-down could be improved by daily monitoring of market conditions.
- The algorithm could be manually implemented only in times of strong trends.
- The algorithm has survived well in all market conditions.
A more detailed output from the test results can be found below. The amount of commission for each trade was taken to be $5, this is high, and probably twice what would be considered an industry standard. The maximum draw-down shown is the maximum from any peak to any trough, in performance. Fortunately this occurred with profit capital already in the account. The maximum loss in a day, is shown as the flat-to-flat loss.
If the $5 commission cost per trade is ignored, the maximum profit achieved (equity peak) is $1,074,960.
As the account was always in profit, any draw-downs and losses were covered by previous gains. There would be cause for concern if the algorithm started in a time of a big loss, or draw-down, as it would be initial capital being lost, not profit. This is perhaps the key issue, and would be the issue with any successful algorithm. Some risk could be mitigated by manually implementing the algorithm each day, and trying to avoid strongly range bound markets.
Trade Statistics | First Fill 2014-11-03 |
Contract: CLG0-NYMEX | Last Fill 2020-01-10 |
Continuous Back Adjusted contract | 2000 Day Test |
Currency Value ($) | |
Closed Trades Profit/Loss | 617230 |
Closed Trades Total Profit | 7571170 |
Closed Trades Total Loss | -6953940 |
Profit Factor | 1.09 |
Equity Peak | 937240 |
Equity Valley | 617230 |
Maximum Runup | 572600 |
Maximum Drawdown | -320010 |
Maximum FlatToFlat Trade Open Profit | 276510.03 |
Maximum FlatToFlat Trade Open Loss | -47389.96 |
Average Trade Open Profit | 517.65 |
Average Trade Open Loss | -344.55 |
Average Winning Trade Open Profit | 911.22 |
Average Winning Trade Open Loss | -187.23 |
Average Losing Trade Open Profit | 243.07 |
Average Losing Trade Open Loss | -454.3 |
Maximum Trade Open Profit | 4690 |
Maximum Trade Open Loss | -3460 |
Highest Price During Positions | 79.8 |
Lowest Price During Positions | 26.05 |
Total Commissions | 151210 |
Total Trades | 30242 |
Total FlatToFlat Trades | 1244 |
Total Filled Quantity | 60484 |
Percent Profitable | 41.10% |
FlatToFlat Percent Profitable | 31.03% |
Winning Trades | 12428 |
Winning FlatToFlat Trades | 386 |
Losing Trades | 17814 |
Losing FlatToFlat Trades | 858 |
Long Trades | 14368 |
Long FlatToFlat Trades | 616 |
Short Trades | 15874 |
Short FlatToFlat Trades | 628 |
Average Trade Profit/Loss | 20.41 |
Average FlatToFlat Trade Profit/Loss | 496.17 |
Average Winning Trade | 609.2 |
Average FlatToFlat Winning Trade | 18506.11 |
Average Losing Trade | -390.36 |
Average FlatToFlat Losing Trade | -7606.21 |
Average Profit Factor | 1.56 |
Average FlatToFlat Profit Factor | 2.43 |
Largest Winning Trade | 3705 |
Largest FlatToFlat Winning Trade | 258010 |
Largest Losing Trade | -3415 |
Largest FlatToFlat Losing Trade | -46340 |
Largest Winner % of Profit | 0.05% |
Largest FlatToFlat Winner % of Profit | 3.61% |
Largest Loser % of Loss | 0.05% |
Largest FlatToFlat Loser % of Loss | 0.71% |
Max Consecutive Winners | 121 |
Max Consecutive Losers | 254 |
Average Time In Trades | 4:47:02 |
Average Time In Winning Trades | 6:42:39 |
Average Time In Losing Trades | 3:26:23 |
Longest Held Winning Trade | 8:20:12 |
Longest Held Losing Trade | 8:38:43 |
Total Quantity | 30242 |
Winning Quantity | 12428 |
Losing Quantity | 17814 |
Avg Quantity Per Trade | 1 |
Avg Quantity Per FlatToFlat Trade | 24.31 |
Avg Quantity Per Winning Trade | 1 |
Avg Quantity Per FlatToFlat Winning Trade | 33.85 |
Avg Quantity Per Losing Trade | 1 |
Avg Quantity Per FlatToFlat Losing Trade | 20.02 |
Largest Trade Quantity | 1 |
Largest FlatToFlat Trade Quantity | 100 |
Maximum Open Position Quantity | 100 |
Last Trade Profit / Loss | -505 |
Number of Open Trades | 0 |
Open Trades: Open Quantity | 0 |
Open Trades: Average Entry Price | 0 |
Consecutive Winners | Frequency |
1 Winners | 86 |
2 Winners | 47 |
3 Winners | 33 |
4 Winners | 34 |
5 Winners | 19 |
6 Winners | 19 |
7 Winners | 13 |
8 Winners | 27 |
9 Winners | 13 |
10 Winners | 18 |
11 Winners | 12 |
12 Winners | 12 |
13 Winners | 10 |
14 Winners | 11 |
15 Winners | 13 |
16 Winners | 11 |
17 Winners | 15 |
18 Winners | 12 |
19 Winners | 8 |
20 Winners | 4 |
21 Winners | 9 |
22 Winners | 5 |
23 Winners | 12 |
24 Winners | 9 |
25 Winners | 9 |
26 Winners | 9 |
27 Winners | 5 |
28 Winners | 10 |
29 Winners | 6 |
30 Winners | 6 |
31 Winners | 10 |
32 Winners | 4 |
33 Winners | 4 |
34 Winners | 7 |
35 Winners | 6 |
36 Winners | 1 |
37 Winners | 2 |
38 Winners | 5 |
39 Winners | 2 |
40 Winners | 9 |
41 Winners | 3 |
42 Winners | 4 |
43 Winners | 3 |
44 Winners | 7 |
45 Winners | 2 |
46 Winners | 2 |
47 Winners | 6 |
48 Winners | 2 |
49 Winners | 4 |
50 Winners | 1 |
51 Winners | 3 |
52 Winners | 2 |
53 Winners | 3 |
54 Winners | 2 |
55 Winners | 1 |
56 Winners | 1 |
57 Winners | 2 |
58 Winners | 3 |
59 Winners | 5 |
60 Winners | 3 |
61 Winners | 2 |
62 Winners | 2 |
64 Winners | 2 |
65 Winners | 2 |
66 Winners | 1 |
67 Winners | 1 |
68 Winners | 1 |
69 Winners | 3 |
70 Winners | 2 |
71 Winners | 1 |
73 Winners | 1 |
74 Winners | 1 |
75 Winners | 1 |
76 Winners | 1 |
78 Winners | 1 |
79 Winners | 1 |
80 Winners | 1 |
83 Winners | 2 |
84 Winners | 1 |
89 Winners | 1 |
91 Winners | 1 |
101 Winners | 1 |
104 Winners | 2 |
111 Winners | 1 |
114 Winners | 1 |
116 Winners | 1 |
121 Winners | 1 |
Consecutive Losers | Frequency |
1 Losers | 83 |
2 Losers | 44 |
3 Losers | 33 |
4 Losers | 24 |
5 Losers | 21 |
6 Losers | 22 |
7 Losers | 13 |
8 Losers | 17 |
9 Losers | 10 |
10 Losers | 11 |
11 Losers | 7 |
12 Losers | 11 |
13 Losers | 9 |
14 Losers | 9 |
15 Losers | 6 |
16 Losers | 9 |
17 Losers | 3 |
18 Losers | 7 |
19 Losers | 4 |
20 Losers | 7 |
21 Losers | 3 |
22 Losers | 11 |
23 Losers | 13 |
24 Losers | 6 |
25 Losers | 16 |
26 Losers | 7 |
27 Losers | 6 |
28 Losers | 9 |
29 Losers | 6 |
30 Losers | 8 |
31 Losers | 11 |
32 Losers | 4 |
33 Losers | 5 |
34 Losers | 5 |
35 Losers | 3 |
36 Losers | 7 |
37 Losers | 6 |
38 Losers | 5 |
39 Losers | 4 |
40 Losers | 10 |
41 Losers | 3 |
42 Losers | 3 |
43 Losers | 3 |
44 Losers | 6 |
45 Losers | 4 |
46 Losers | 1 |
47 Losers | 2 |
48 Losers | 2 |
49 Losers | 3 |
50 Losers | 1 |
51 Losers | 5 |
52 Losers | 4 |
53 Losers | 4 |
54 Losers | 3 |
55 Losers | 3 |
56 Losers | 4 |
57 Losers | 1 |
58 Losers | 3 |
59 Losers | 3 |
60 Losers | 1 |
61 Losers | 4 |
62 Losers | 3 |
63 Losers | 3 |
64 Losers | 1 |
65 Losers | 1 |
66 Losers | 2 |
67 Losers | 4 |
68 Losers | 1 |
70 Losers | 1 |
72 Losers | 1 |
73 Losers | 2 |
74 Losers | 3 |
75 Losers | 1 |
76 Losers | 2 |
77 Losers | 2 |
78 Losers | 2 |
79 Losers | 2 |
80 Losers | 2 |
81 Losers | 1 |
82 Losers | 1 |
83 Losers | 1 |
86 Losers | 2 |
87 Losers | 1 |
88 Losers | 1 |
90 Losers | 2 |
91 Losers | 2 |
92 Losers | 2 |
93 Losers | 2 |
94 Losers | 2 |
95 Losers | 1 |
97 Losers | 2 |
101 Losers | 1 |
103 Losers | 1 |
104 Losers | 1 |
105 Losers | 2 |
106 Losers | 1 |
107 Losers | 2 |
108 Losers | 1 |
110 Losers | 1 |
111 Losers | 1 |
113 Losers | 1 |
114 Losers | 1 |
117 Losers | 2 |
119 Losers | 2 |
121 Losers | 2 |
133 Losers | 1 |
136 Losers | 1 |
139 Losers | 1 |
142 Losers | 1 |
160 Losers | 1 |
168 Losers | 1 |
178 Losers | 1 |
197 Losers | 1 |
212 Losers | 1 |
235 Losers | 1 |
254 Losers | 1 |
Looking at the Crude Oil markets over this 6 year period, it can be seen from the chart below that it seems to include most market conditions. Bull, Bear, and range bound markets all factor heavily during these years. So it seems to be a reasonable test of the algorithm in all market conditions.
Below is the Crude Oil chart over the back-test period.
This chart shows the CL futures contract, which is the product that the algorithm bought and sold.
Leave a Comment