#define LONG_FIRST
function run() {
if (is(INITRUN)) {
BarPeriod = 80;
BarOffset = 40;
LookBack = 245;
NumWFOCycles = 6;
StartDate = 20130601;
EndDate = 20131230;
set(NFA + TICKS + RULES + TESTNOW + PLOTNOW + LOGFILE);
TradesPerBar = 2;
Weekend = 1;
Hedge = 4;
}
vars ol = series((priceOpen(0) - priceLow(0)) / PIP);
var v00 = APO(ol, 4, 7, MAType_WMA);
var v01 = APO(ol, 148, 245, MAType_TRIMA);
polyfit(0, ol, 24, 2, 1);
var v02 = polynom(0, -1);
TakeProfit = 3 * ATR(100);
Stop = 3 * ATR(100);
int al;
int as;
#ifdef LONG_FIRST
al = adviseLong(PERCEPTRON, 0, v00, v01, v02);
if (al > 0) {
enterLong();
}
as = adviseShort();
if (as > 0) {
enterShort();
}
#else
as = adviseShort(PERCEPTRON, 0, v00, v01, v02);
if (as > 0) {
enterShort();
}
al = adviseLong();
if (al > 0) {
enterLong();
}
#endif
plot("al", al, LINE + NEW , BLUE);
plot("as", as, LINE, RED);
}