#include <r.h>
var change(int n)
{
return scale((priceClose(0) - priceClose(n))/priceClose(0),100)/100;
}
var range(int n)
{
return scale((HH(n) - LL(n))/priceClose(0),100)/100;
}
int prevTrend = 0;
var prevPrice = 0;
function run()
{
StartDate = 20140601;
BarPeriod = 60; // 1 hour
LookBack = 100;
PlotBars = -250;
PlotWidth = 1600;
PlotHeight1 = 600;
ColorWin = ColorLoss = 0;
WFOPeriod = 252*24; // 1 year
DataSplit = 90;
NumCores = -1; // use all CPU cores but one
set(RULES);
Spread = RollLong = RollShort = Commission = Slippage = 0;
LifeTime = 3;
if(Train) Hedge = 2;
vars PriceMed = series((priceHigh()+priceLow())/2);
ZigZag(PriceMed, 37*PIP, 16, 0);
var advise = adviseLong(NEURAL+BALANCED, rSign,
change(1),change(2),change(3),change(4),
range(1),range(2),range(3),range(4));
int trend = ifelse(advise>0.5, 1, 0);
if(trend != prevTrend) {
prevTrend = trend;
var prevPrice = (priceClose(0)+priceOpen(0))/2;
if(!Train) {
printf("\n%04d%02d%02d %02d:%02d: %.4f", year(), month(), day(), hour(), minute(), prevPrice);
plotGraph("Pr.ZZ", 0, prevPrice, LINE, RED);
}
}
/*
if(advise > 0)
enterShort();
if(advise < 0)
enterLong();
*/
}