Below is my next draft at the ONS system. I have attached a chart for just the EUR/USD result. It looks promising with a profit factor of ~1.76, 53% accuracy and ~9 trades/year. However when we trade the portfolio that Rensink traded in his blog, the result is not so rosy. Firstly I had exclude the GBP/JPY cross since it is not available to Zorro (or is it???). Secondly, below is a performance summary.
I now invite comments:
1. Does the code look correct?
2. Should I try to get the GBP/JPY cross included, if this is possible?
3. Should I add script to exclude symbols and / or symbol direction (long / short) that are not profitable in the test period? I don't know too much about equity curve trading, and in this case, the sample size for a given symbol is low (though I will get the other history file shortly.)
4. And, of course, the stop. I will probably test some ATR based stop.
The code:
function run()
{
LookBack = 1000; // Needed for SMA(40).
StartDate = 2007;
while(asset(loop("EUR/USD","GBP/USD","USD/CHF","USD/JPY"))) // Missing "GBP/JPY"
{
BarPeriod = 60;
FrameOffset = timeOffset(ET,0,0,0); // Calculate daily bars with ET close
TimeFrame = 24; // Calculate daily bars
vars dailycl = series(priceClose());
vars sma10 = series(SMA(dailycl,10));
vars sma40 = series(SMA(dailycl,40));
var longentry = HH(10) + (1*PIP);
var shortentry = LL(10) - (1*PIP);
TimeFrame = 1; // Back to 60 min bars
TimeWait = 15; // Remove pending orders at end of market day
if (ldow(ET) == FRIDAY)
{
if (sma10[0] > sma40[0])
{
if (lhour(ET,0) == 1 ) // Rensink says midnight CST.
{
enterLong(1,longentry);
}
}
if (sma10[0] < sma40[0]) // Rensink says midnight CST.
{
if (lhour(ET,0) == 1)
{
enterShort(1,shortentry);
}
}
}
if (ldow(ET) == MONDAY)
{
if (lhour(ET,0) == 1) // Rensink says midnight CST.
{
exitLong();
exitShort();
}
}
}
PlotWidth = 800;
PlotHeight1 = 320;
}
The result for EUR/USD:
BackTest ONS EUR/USD - performance report
Test period 27.02.2008-26.07.2013
Lookback time 936 bars (8 weeks)
Assumed slippage 10.0 sec
Assumed spread 2.4 pips (roll -0.03/0.01)
Contracts per lot 1000
Gross win/loss 124$ / -70$ (+704p)
Average profit 9.89$/year, 0.82$/month, 0.04$/day
Max drawdown -17$ 31% (MAE -21$ 39%)
Total down time 70% (TAE 2%)
Max down time 62 weeks from Mar 2008
Largest margin 5.00$
Trade volume 48006$ (8871$/year)
Transaction costs -8.57$ spr, -3.04$ slp, -0.12$ rol
Capital required 17$
Number of trades 47 (9/year, 1/week, 1/day)
Percent winning 53%
Max win/loss 17$ / -10$
Avg trade profit 1.14$ 15.0p (+4.95$ / -3.19$)
Avg trade slippage -0.06$ -0.9p (+0.02$ / -0.15$)
Avg trade bars 16 (+16 / -16)
Max trade bars 22 (22 hours)
Time in market 2%
Max open trades 1
Max loss streak 4 (uncorrelated 5)
Annual return 79%
Profit factor 1.76 (PRR 1.16)
Sharpe ratio 0.56
Kelly criterion 0.55
OptimalF .1000
Ulcer index 15%
Prediction error 73%
Portfolio analysis OptF ProF Win/Loss
EUR/USD .199 1.76 25/22
EUR/USD:L .261 1.87 14/13
EUR/USD:S .150 1.65 11/9
The result for portfolio:
Test period 01.03.2007-26.07.2013
Lookback time 1000 bars (8 weeks)
Assumed slippage 10.0 sec
Gross win/loss 595$ / -557$ (+512p)
Average profit 5.94$/year, 0.49$/month, 0.02$/day
Max drawdown -122$ 320% (MAE -135$ 354%)
Total down time 92% (TAE 6%)
Max down time 120 weeks from Aug 2009
Largest margin 21$
Trade volume 253780$ (39631$/year)
Transaction costs -50$ spr, -16$ slp, -1.24$ rol
Capital required 104$
Number of trades 266 (42/year, 1/week, 1/day)
Percent winning 49%
Max win/loss 22$ / -31$
Avg trade profit 0.14$ 1.9p (+4.55$ / -4.13$)
Avg trade slippage -0.06$ -0.8p (+0.01$ / -0.13$)
Avg trade bars 16 (+17 / -16)
Max trade bars 22 (22 hours)
Time in market 12%
Max open trades 4
Max loss streak 8 (uncorrelated 9)
Annual return 7%
Profit factor 1.07 (PRR 0.90)
Sharpe ratio 0.13
Kelly criterion 0.28
OptimalF .241
Ulcer index 86%
Prediction error 30%
Portfolio analysis OptF ProF Win/Loss
EUR/USD avg .331 1.81 36/29
GBP/USD avg .099 0.90 30/32
USD/CHF avg .041 0.91 30/38
USD/JPY avg .067 1.00 35/36
EUR/USD .241 1.81 36/29
EUR/USD:L .131 1.36 23/22
EUR/USD:S .532 4.03 13/7
GBP/USD .000 0.90 30/32
GBP/USD:L .000 0.53 16/19
GBP/USD:S .198 1.68 14/13
USD/CHF .000 0.91 30/38
USD/CHF:L .000 0.49 8/10
USD/CHF:S .082 1.31 22/28
USD/JPY .000 1.00 35/36
USD/JPY:L .134 1.44 20/18
USD/JPY:S .000 0.76 15/18