Code: Select all
function run()
{
StartDate = 2002;
BarPeriod = 24*60; // 1 day
NumWFOCycles = 5;
set(RULES|TESTNOW|LOGFILE);
if(Train) {
set(HEDGING); // allow long & short
TimeExit = 5; // 5 bars price movement
} else {
Stop = 500*PIP; // large stop distance
TimeExit = 10; // twice the prediction horizon
}
if(adviseLong(PATTERN+2,0,
priceHigh(2),priceLow(2),priceClose(2),
priceHigh(1),priceLow(1),priceClose(1),
priceHigh(1),priceLow(1),priceClose(1),
priceHigh(0),priceLow(0),priceClose(0)) > 30 and dow() != FRIDAY)
enterLong();
if(adviseShort() > 30 and dow() != FRIDAY)
enterShort();
}The trades just exit by reversal, and also after 2 weeks, which is twice the prediction horizon. I believe after 2 weeks any correlation between the price and the pattern is gone. The strategy can certainly be improved by a better exit algorithm.
The signals within a function are certainly mutually exclusive. I haven't tested if Long and Short signals are mutally exclusive, but I think they are - it's highly unlikely that the same pattern gets a positive score both for long and for short trades.