Posted By: Grat
FPI and Zorro - 01/17/18 17:26
Hi,
I testing FPI with Zorro Machine learning - DTREE.
this is after test the 2017.
source:
But I don't know, howto optimize PARAMTERS with FACTOR. Is no working.
I testing FPI with Zorro Machine learning - DTREE.
this is after test the 2017.
source:
Code:
#define _LONG 1 #define _SHORT 2 #define _WRONG -999 //#define _DEBUG_ #define _PLOT_ //#genparam bool Reinvest = true; bool UseOptimalF = true; var CalculateMargin(int side) { var value = 0.03 * Capital; if (Reinvest) { //value *= sqrt(1+Balance / Capital); value *= sqrt(1 + max(0, ProfitClosed/Capital)); } if (UseOptimalF) value *= ifelse(side == _LONG, OptimalFLong, OptimalFShort); return value; } void run(){ BarPeriod = 5; TimeFrame = 12; LookBack = 1800; NumYears = 1; TradesPerBar = 12; MaxLong = MaxShort = 2; //NumWFOCycles = 12; NumCores = -1; //MaxBars = 2400; if(Train) Hedge = 2; set(RULES|TESTNOW|FACTORS); #ifdef genparam set(PARAMETERS); #endif #ifdef _DEBUG_ set(STEPWISE); #endif #ifdef _PLOT_ set(PLOTNOW); PlotScale = 8; //PlotWidth = 400; PlotHeight1 = 450; PlotHeight2 = 120; PlotDate = 20170701; PlotBars = 200; ColorEquity = 0; #endif //set(TICKS|FAST); Capital = 50000; // -- PREPARE fpi asset("EUR/USD"); #ifdef genparam int nLowUS = optimize(800,800,2000); #else int nLowUS = 1000; #endif vars A = series(LowPass(series( priceClose()),nLowUS)); asset("GBP/USD"); #ifdef genparam int nLowGS = optimize(800,800,2000); #else int nLowGS = 1000; #endif vars B = series(LowPass(series( priceClose()),nLowGS)); asset("EUR/GBP"); #ifdef genparam int nLowEG = optimize(800,800,2000); #else int nLowEG = 1000; #endif vars C = series(LowPass(series( priceClose()),nLowEG)); var pom= (1-C[0]*B[0]/A[0])*100; var aTest[2]; aTest[0]=(scale(pom,100)); asset("EUR/USD"); #ifdef genparam int nHiUS = optimize(400,400,1200); int nTP = optimize(2,2,10); #else int nHiUS = 800; int nTP = 2; #endif aTest[1]= 100*HighPass(A,nHiUS); #ifdef _PLOT_ plot("FPI",series(aTest[0]),NEW|BARS,BLUE); plot("HP",series(aTest[1]),NEW|BARS,BLUE); #endif Stop = 5*ATR(100); TakeProfit = nTP*ATR(100); if(adviseLong(DTREE,0,aTest,2) > 0){ Margin=CalculateMargin(_LONG); enterLong(); #ifdef _PLOT_ plot("LONG",priceClose(),MAIN|CROSS,GREEN); #endif } if(adviseShort(DTREE,0,aTest,2) > 0){ Margin=CalculateMargin(_SHORT); enterShort(); #ifdef _PLOT_ plot("SHORT",priceClose(),MAIN|CROSS,RED); #endif } asset("GBP/USD"); #ifdef genparam int nHiGS = optimize(400,400,1200); int nTPGS = optimize(2,2,10); #else int nHiGS = 800; int nTPGS = 2; #endif aTest[1]= 100*HighPass(B,nHiGS); Stop = 5*ATR(100); TakeProfit = nTPGS*ATR(100); if(adviseLong(DTREE,0,aTest,2) > 0){ Margin=CalculateMargin(_LONG); enterLong(); } if(adviseShort(DTREE,0,aTest,2) > 0){ Margin=CalculateMargin(_SHORT); enterShort(); } asset("EUR/GBP"); #ifdef genparam int nHiEG = optimize(400,400,1200); int nTPEG = optimize(2,2,10); #else int nHiEG = 800; int nTPEG = 2; #endif aTest[1]= 100*HighPass(C,nHiEG); Stop = 5*ATR(100); TakeProfit = nTPEG*ATR(100); if(adviseLong(DTREE,0,aTest,2) > 0){ Margin=CalculateMargin(_LONG); enterLong(); } if(adviseShort(DTREE,0,aTest,2) > 0){ Margin=CalculateMargin(_SHORT); enterShort(); } }
But I don't know, howto optimize PARAMTERS with FACTOR. Is no working.