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|
|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 FlatToFlat Trades||1244|
|Total Filled Quantity||60484|
|FlatToFlat Percent Profitable||31.03%|
|Winning FlatToFlat Trades||386|
|Losing FlatToFlat Trades||858|
|Long FlatToFlat Trades||616|
|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|
|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|
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.