I would like to explore the AI functions so I trained and tested with EUR/USD the example from the manual (I am using Zorro 1.28) and I have 3 questions:
void run()
{
BarPeriod = 60;
LookBack = 150;
TradesPerBar = 2;
set(RULES|TESTNOW);
if (Train)
Hedge = 2;
// generate price series
vars H = series(priceHigh()),
L = series(priceLow()),
C = series(priceClose());
// generate some signals from H,L,C in the -100..100 range
var Signal1 = (LowPass(H,1000)-LowPass(L,1000))/PIP,
Signal2 = 100*Fisher(C,100);
Stop = 4*ATR(100);
TakeProfit = 4*ATR(100);
if(adviseLong(DTREE,0,Signal1,Signal2) > 0)
enterLong();
if(adviseShort(DTREE,0,Signal1,Signal2) > 0)
enterShort();
}
Notice that I added if (Train) Hedge = 2; so that it can be properly trained as the manual says, if not, accuracy would result in 0%
Since I am on purpose overfitting it gives 391% AR, 4.14 Sharpe Ratio, 0.91 R2, UI 1%...
Ok, now I add:
NumWFOCycles = 5;
Train and test, and it gives 2% AR, Sharpe of 0.04 and UI of 278%...Not nice.
So, quoting the manual
Often a perceptron can be used where a decision tree fails, and vice versa.
I changed the method to PERCEPTRON, trained and tested without WFO and it gave 19% AR, Sharpe Ratio of 0.28 and R2 0.59
First question: why since I am overfitting on purpose it gives low stats?anyway, now I trained and tested with wfo (same as before, 5 cycles) and I get:
Prediction accuracy: 47%
Rules stored in perceptron1_EURUSD.c
Run perceptron1..
Walk-Forward Test: perceptron1 EUR/USD 2010..2015.
Read perceptron1_EURUSD_1.c perceptron1_EURUSD_2.c perceptron1_EURUSD_3.c. perceptron1_EURUSD_4.c
Monte Carlo Analysis... Median AR 48%
Profit 3982$ MI 157$ DD 2536$ Capital 3993$
Trades 12572 Win 55% Avg +3.6p Bars 27
AR 47% PF 1.15 SR 0.73 UI 13% R2 0.01
Second question: why are the stats of the wfo higher than the ones of the overfitted train? Shouldnīt it be the other way?Then I added reinvesting with this code:
void run()
{
BarPeriod = 60;
LookBack = 150;
TradesPerBar = 2;
NumWFOCycles = 5;
Capital = 1000;
set(RULES|FACTORS|TESTNOW);
if (Train)
Hedge = 2;
// generate price series
while(asset(loop("EUR/USD","USD/JPY"))){
Margin = OptimalF * Capital * sqrt(1 + max(0,WinTotal-LossTotal)/Capital);
vars H = series(priceHigh()),
L = series(priceLow()),
C = series(priceClose());
// generate some signals from H,L,C in the -100..100 range
var Signal1 = (LowPass(H,1000)-LowPass(L,1000))/PIP,
Signal2 = 100*Fisher(C,100);
Stop = 4*ATR(100);
TakeProfit = 4*ATR(100);
if(adviseLong(PERCEPTRON,0,Signal1,Signal2) > 0)
enterLong();
if(adviseShort(PERCEPTRON,0,Signal1,Signal2) > 0)
enterShort();
}
}
trained and tested and I get
Monte Carlo Analysis... Median AR -5%
Profit -19278$ MI -761$ DD 142736$ Capital 113553$
Trades 25050 Win 51% Avg +2.0p Bars 28
CAGR -1% PF 0.97 SR -0.15 UI 39% R2 0.00
perceptron1 run..
Walk-Forward Test: perceptron1 portfolio 2010..2015
Read perceptron1.fac. perceptron1_1.c. perceptron1_2.c perceptron1_3.c. perceptron1_4.c
Monte Carlo Analysis... Median AR -5%
Profit -19278$ MI -761$ DD 142736$ Capital 113553$
Trades 25050 Win 51% Avg +2.0p Bars 28
CAGR -1% PF 0.97 SR -0.15 UI 39% R2 0.00
so,
Third question: Why I am getting a negative result with more assets and reinvesting? Should I train FACTORS and RULES separately? I didnīt find anything in the manual related.Thanks for your help!