Thanks for sharing your system. I took the idea and adapted the algorithm. I thought the same system might work for other currency pairs with different time settings.

The modified version uses Zorros optimize feature to automatically find profitable startHour and endHour pairs. The algorithm thus works using WFO optimization.
The only thing that is not really out of sample is the OptimalF factors.

Even though the drawdowns are less than in the original algorithm the average trade profit is reduced.

Here are my results:



Code:
Walk-Forward Test Test1 portfolio

Simulated account   AssetsFix 
Bar period          1 hour (avg 87 min)
Simulation period   05.04.2007-24.08.2016 (56590 bars)
Test period         16.09.2011-24.08.2016 (29952 bars)
Lookback period     80 bars (3 days)
WFO test cycles     5 x 5990 bars (51 weeks)
Training cycles     6 x 23960 bars (206 weeks)
Monte Carlo cycles  200
Assumed slippage    10.0 sec
Capital invested    10000$

Gross win/loss      127761$ / -112703$ (+9647p)
Average profit      3048$/year, 254$/month, 12$/day
Max drawdown        -1567$ 10% (MAE -1825$ 12%)
Total down time     90% (TAE 93%)
Max down time       14 weeks from Mar 2015
Max open margin     1239$
Max open risk       643$
Trade volume        140985019$ (28538185$/year)
Transaction costs   -7182$ spr, -118$ slp, -88$ rol, -10585$ com
Capital required    2460$

Number of trades    9615 (1947/year, 38/week, 8/day)
Percent winning     50.0%
Max win/loss        597$ / -172$
Avg trade profit    1.57$ 1.0p (+17.0p / -15.0p)
Avg trade slippage  -0.01$ -0.0p (+0.3p / -0.3p)
Avg trade bars      5 (+6 / -5)
Max trade bars      40 (40 hours)
Time in market      178%
Max open trades     10
Max loss streak     12 (uncorrelated 14)

Annual growth rate  20%
Profit factor       1.13 (PRR 1.10)
Sharpe ratio        0.96
Kelly criterion     3.02
R2 coefficient      0.842
Ulcer index         3.7%
Prediction error    124%

Confidence level     AR   DDMax  Capital

 10%                118%  1735$  2591$
 20%                112%  1911$  2728$
 30%                108%  2023$  2816$
 40%                101%  2278$  3014$
 50%                 98%  2382$  3095$
 60%                 95%  2511$  3195$
 70%                 91%  2711$  3352$
 80%                 86%  2963$  3548$
 90%                 79%  3354$  3852$
 95%                 74%  3725$  4142$
100%                 55%  5459$  5493$

Portfolio analysis  OptF  ProF  Win/Loss  Wgt%  Cycles

AUD/USD avg         .070  1.17  1181/1091   42.1  /X/X/
EUR/USD avg         .091  1.08  1244/1315   15.3  /\\\/
GBP/USD avg         .000  ----    0/0      0.0  .....
NZD/USD avg         .045  1.13  1129/1173   12.2  X\/XX
USD/CAD avg         .000  ----    0/0      0.0  .....
USD/CHF avg         .000  ----    0/0      0.0  .....
USD/JPY avg         .087  1.15  1258/1224   30.3  //XX/

ISL avg             .039  1.09  2478/2505   35.6  XXXX/
ISS avg             .054  1.17  2334/2298   64.4  /XXXX

AUD/USD:ISL         .130  1.08  616/606   11.7  /\/\/
AUD/USD:ISL:L       .130  1.08  616/606   11.7  /\/\/
AUD/USD:ISL:S       .000  ----    0/0      0.0  .....
AUD/USD:ISS         .292  1.30  565/485   30.4  /////
AUD/USD:ISS:L       .000  ----    0/0      0.0  .....
AUD/USD:ISS:S       .292  1.30  565/485   30.4  /////
EUR/USD:ISL         .304  1.07  638/641    9.7  /\\\/
EUR/USD:ISL:L       .304  1.07  638/641    9.7  /\\\/
EUR/USD:ISL:S       .000  ----    0/0      0.0  .....
EUR/USD:ISS         .061  1.09  606/674    5.6  /\\\/
EUR/USD:ISS:L       .000  ----    0/0      0.0  .....
EUR/USD:ISS:S       .061  1.09  606/674    5.6  /\\\/
NZD/USD:ISL         .005  0.98  613/666   -0.2  \\/\/
NZD/USD:ISL:L       .005  0.98  613/666   -0.2  \\/\/
NZD/USD:ISL:S       .000  ----    0/0      0.0  .....
NZD/USD:ISS         .176  1.15  516/507   12.4  /\//\
NZD/USD:ISS:L       .000  ----    0/0      0.0  .....
NZD/USD:ISS:S       .176  1.15  516/507   12.4  /\//\
USD/JPY:ISL         .119  1.18  611/592   14.4  /////
USD/JPY:ISL:L       .119  1.18  611/592   14.4  /////
USD/JPY:ISL:S       .000  ----    0/0      0.0  .....
USD/JPY:ISS         .232  1.13  647/632   16.0  //\\/
USD/JPY:ISS:L       .000  ----    0/0      0.0  .....
USD/JPY:ISS:S       .232  1.13  647/632   16.0  //\\/



And here is the code:

Code:
#define LONG	0
#define SHORT  1

bool Reinvest = false;
bool UseOptimalF = true;

var CalculateMargin(int side)
{
	var value = 0.1 * Capital;
	
	if (Reinvest)
	{
		value *= sqrt(Balance / Capital);
		//value *= sqrt(1 + max(0, ProfitClosed/Capital));
	}
	
	if (UseOptimalF)
		value *= ifelse(side == LONG, OptimalFLong, OptimalFShort);

	return value;
}

int hoursLookup[300];

function Initialize()
{
	int count = 0;
	int startHour, endHour;
	
	for (startHour = 0; startHour <= 23; ++startHour)
	for (endHour = startHour + 1; endHour <= 24; ++endHour)
		hoursLookup[count++] = (endHour % 24) * 24 + startHour;
}

int NumOpenTrades(int side)
{
	string currentAsset = Asset;
	string currentAlgo = Algo;	
	
	int count = 0;
	for (open_trades)
	{
		if (strcmp(TradeAsset, currentAsset) != 0 || strcmp(TradeAlgo, currentAlgo) != 0)
			continue;
		
		if ((TradeIsLong && side == LONG) || (TradeIsShort && side == SHORT))
			count++;
	}
	
	return count;
}

TRADE* EnterTrade(int side)
{
	if (side == LONG)
		return enterLong();
	else
		return enterShort();
}

void ExitTrade(int side)
{
	if (side == LONG)
		exitLong();
	else
		exitShort();	
}

function TradeIS(int side)
{
	int index = (int)(optimize(0, 0, 254, 1) / 254 * 299);
	int startHour = hoursLookup[index] % 24;
	int endHour = hoursLookup[index] / 24;
	
	// Exit over the weekend.
	if (dow() == FRIDAY && hour() >= 21)
	{ 
  		exitLong();
 	 	exitShort();
	}	
	
	Stop = 55 * PIP;
	Trail = 10 * PIP;
	
	// Don't trade from 00:00 to 00:00.
	if (startHour == endHour)
		return;
	
	// Trade during the week.
	if (dow() >= 1 && dow() <= 5) 
	{
		Margin = CalculateMargin(side);
		int numOpen = NumOpenTrades(side);
		if (numOpen == 0 && hour() == startHour)
			EnterTrade(side);	
		if (numOpen > 0 && hour() == endHour)
			ExitTrade(side);
	}
}

function run()
{
	set(PARAMETERS + FACTORS);
	
	StartDate = 2007;
	EndDate = 2016;
	BarPeriod = 60;
	Capital = 10000;
	DataSplit = 80;
	WFOPeriod = (312 * 24) * DataSplit / (100 - DataSplit);
	
	if (is(INITRUN))
		Initialize();

	while (asset(loop("AUD/USD", "EUR/USD", "GBP/USD", "NZD/USD", "USD/CAD",  "USD/CHF", "USD/JPY")))
	while (algo(loop("ISL", "ISS")))
	{
		if (Algo == "ISL")
			TradeIS(LONG);
		else if (Algo == "ISS")
			TradeIS(SHORT);
	}
}



Unfortunately the strategy is not really tradeable for the average trader. The average trade profit is just 1.0pip which is way too low. I backtested it also with variable spread and then the strategy fails.

But I think the strategy can work if one does not have to pay commissions.

Last edited by trenki2; 08/27/16 17:46.