// XGBoost on S&P500
#include <r.h>
#include <profile.c>
#include <contract.c>
var neural ........................
{
...................................
...................................
}
function run()
{
NumCores = 8;
set(RULES|PLOTNOW|OPENEND);
StartDate = 20020101;
// EndDate = 20180515;
BarPeriod = 1440;
LookBack = 400;
asset("ES"); // Fantastic results when comment and select it from scrollbox
DataSplit = 90;
WFOPeriod = 25 * DataSplit/(100-DataSplit); /* One month test and one year train, but better profits when lower test period, this made the suspicions */
vars Close = series(priceClose());
var desv = 2;
var volumeDown = marketVol();
var volumeUp = marketVal();
/* And the signals and transformations.............
.......................................
........................................ */
if(Train)
{
Hedge = 2;
NumSampleCycles = 4;
LifeTime = 1;
if(adviseLong(NEURAL+BALANCED, 0,
Sig1,Sig2, Sig3, Sig4,Sig5,Sig6,Sig11,Sig16,Sig17,Sig18,Sig20) > 0.5)
{
enterLong(1);
}
if(adviseShort() > 0.5)
{
enterShort(1);
}
}
if(!Train)
{
var LongPrediction = adviseLong(NEURAL+BALANCED,0, Sig1,Sig2, Sig3,Sig4,Sig5,Sig6,Sig7,Sig11,Sig16,Sig17,Sig18,Sig20);
var ShortPrediction = adviseShort();
if(LongPrediction > 0.5 && ShortPrediction < 0.5)
{ Stop = 4*ATR(20);
TakeProfit = 6*ATR(20);
reverseLong(1);
}
if(ShortPrediction > 0.5 && LongPrediction < 0.5)
{ Stop = 4*ATR(20);
TakeProfit = 4*ATR(20);
reverseShort(1);
}
PlotWidth = 800;
PlotHeight1 = 600;
}
}