// Machine learning ////////////////////////////
#include <profile.c>
function run()
{
StartDate = 2010;
EndDate = 2018;
BarPeriod = 1440; // 1 day
BarZone = WET; // Western European midnight
Weekend = 1; // don't merge Friday and Sunday bars
asset("EUR/USD");
NumTrainCycles = 2;
if(TrainCycle == 1) set(RULES);
else if(TrainCycle == 2) set(PARAMETERS);
else if(TrainCycle == 0) set(RULES|PARAMETERS);
if(Train) Hedge = 2; // for training, allow long + short
LifeTime = 3; // one week
MaxLong = MaxShort = -1;
int nTr=optimize(50,0,100);
Stop = optimize(1,1,50);
if(adviseLong(PATTERN+FAST+2+RETURNS,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)) > nTr)
enterLong();
if(adviseShort() > nTr)
enterShort();
if (is(EXITRUN)){
if (TrainCycle == 2)
watch("nExit Cycle 2------------------");
if (TrainCycle == 1)
watch("nExit Cycle 1------------------");
if (TrainCycle == 0)
watch("nExit Cycle 0------------------");
}
if (is(FIRSTRUN)){
if (TrainCycle == 2)
watch("n----- Cycle 2------------------");
if (TrainCycle == 1)
watch("n----- Cycle 1------------------");
if (TrainCycle == 0)
watch("n----- Cycle 0------------------");
}
}