What happened when a strategy followed the direction of Tesla's moving average? The notebook uses a triple exponential moving average, or TEMA, with a 20-session setting. When it rises from the previous day, the strategy goes long. When it falls, the strategy goes short. It computes the signal at the close and changes its position at the following open. Original notebook
The cost of switching positions
The Docker replay covered 1,509 open-to-open returns from January 2013 to December 2018. The position changed 255 times. The notebook charges 0.15% for each adjustment equivalent to the full portfolio. Moving from 100% long to 100% short turns over twice the portfolio and costs 0.30%.
The strategy lost 40.79% before costs and 72.45% after costs. URTH, the global equity fund used as the benchmark, gained 37.21% over the same dates. The strategy's largest decline from a peak was 90.19%.
How much the costs weigh
- Strategy before costs
- Strategy after costs
- Reference: URTH
Source: technical report of the test, linked below, and figures from the article itself. Prices exclude dividends.
The sum can be done by hand. Every change of side moves twice the portfolio, and over six years turnover added up to about 509 times its value. At 0.15% per unit, that is about 76 points of accumulated cost, almost 13 a year. A rule that changes position 255 times has to earn that before it starts earning anything.
Here it did not: the rule was already losing before costs. Costs do not explain the sign of the result, but they do explain its size. How to do this sum for any strategy is in execution costs.
How to read the test
The prices exclude dividends. The notebook models commissions and slippage and leaves out financing and stock-borrow charges. Its final row charges for a position change with the following open missing from the sample. The evidence in the report ends at the last observed open.
What the engine measured
Cumulative return
Worst drawdown from a peak
Ratios, with their 95% interval
- Strategy
- Reference: URTH
- Resampling range or 95% interval
Source: technical report of the test, linked below. Prices exclude dividends; the resampling uses the same historical series.
The technical report adds the margin of error to these figures. The Sharpe of the strategy was −0.16, with a 95% interval of −1.01 to 0.70. Against URTH, the average annual difference was −14.88%, with a t-statistic of −0.67: it cannot be told apart from zero.
When the same returns were resampled in blocks, the cumulative return fell between −96.92% and 170.39% in the central 90%, and the worst drawdown between 62.95% and 98.08%. What that resampling measures is explained in Block bootstrap and permutation Monte Carlo.
It may seem odd that losing 72.45% while the reference rises 37.21% "cannot be told apart from zero". The reason is noise. The strategy had an annual volatility of 51.84%, almost three times the reference's, and with six years of data the margin of error is so wide that almost any result fits. Not being able to claim the rule is worse does not make it good: it spent 98.3% of sessions below its previous peak.
Test reports

How to read this document is explained in the guide to the technical report.
How to read both documents is in the guide to the technical report.
See Strateva's services if you want to evaluate a rule with your own data.