function run()
{
StartDate = 2003;
EndDate = 2008;
BarPeriod = 30;
LookBack = 30;
asset("GBP/USD");
int Slow = 20;
int Fast = 1;
int MaxSlow = 60;
int MaxFast = 10;
// no trade costs...
Spread = 0;
Slippage = 0;
RollLong = RollShort = 0;
for(Slow; Slow<=MaxSlow;++Slow){
for(Fast; Fast<=MaxFast;++Fast){
vars Price = series(priceClose()),
Fast = series(SMA(Price,Fast)),
Slow = series(SMA(Price,Slow));
static var BuyLimit,SellLimit,BuyStop,SellStop;
if(crossOver(Fast,Slow)) {
BuyStop = priceHigh() + 1*PIP;
BuyLimit = priceHigh() + 5*PIP;
}
if(crossUnder(Fast,Slow)) {
SellStop = priceLow() - 1*PIP;
SellLimit = priceLow() - 5*PIP;
}
if(!NumOpenLong && Fast[0] > Slow[0] && Price[0] < BuyLimit)
enterLong(1,BuyStop);
if(!NumOpenShort && Fast[0] < Slow[0] && Price[0] > SellLimit)
enterShort(1,SellStop);
if(is(EXITRUN)){
char line[100];
sprintf(line,
"%i,%i,%i,%i\n",
Slow,Fast,WinTotal,LossTotal);
file_append("Data\\NetProfit.csv",line);
}
}
}
}