Yeah I don't know what I was thinking there. It should just be that price[0] is greater/lower than the SMA.
Ok so without the crossover and just the SMA220 I get the following. I thought it was a good test until I realised that it didn't take an long trades using this code.
BackTest First Strike portfolio
Simulated account AssetsFix.dta Bar period 24 hours (avg 2180 min) Test period 03.01.2006-16.07.2016 (2526 bars) Lookback period 220 bars (45 weeks) Monte Carlo cycles 200 Assumed slippage 10.0 sec Capital invested 1000$
Gross win/loss 19984$ / -16179$ (+21500p) Average profit 361$/year, 30$/month, 1.39$/day Max drawdown -703$ 18% (MAE -768$ 20%) Total down time 92% (TAE 75%) Max down time 138 weeks from Jan 2006 Max open margin 471$ Max open risk 161$ Trade volume 4435744$ (421148$/year) Transaction costs -213$ spr, -19$ slp, -272$ rol, -100$ com Capital required 846$
Number of trades 2277 (217/year, 5/week, 1/day) Percent winning 26% Max win/loss 390$ / -40$ Avg trade profit 1.67$ 9.4p (+188.5p / -54.5p) Avg trade slippage -0.01$ -0.0p (+0.7p / -0.3p) Avg trade bars 1 (+3 / -1) Max trade bars 16 (23 days) Time in market 156% Max open trades 10 Max loss streak 25 (uncorrelated 27)
Annual growth rate 16% Profit factor 1.24 (PRR 1.16) Sharpe ratio 0.66 Kelly criterion 1.20 R2 coefficient 0.388 Ulcer index 8.3% Prediction error 32%