I am using the fitness formula from SystemTra.de and I made a small modification on the number or trades. line.
I replaced the fixed value of trades with the formula YearlyReturn.Count * 25, but that formula is not working.
Could somebody tell me, whats wrong on that coding line?
Let me describe the problem more detail, maybe you know a different way to solve.
On the optimizer you can only use one fitness formula for the in sample and out of sample tests.
Normally I make 80% in sample and 20% out of sample test and often I got not enough trades on the out of sample test.
With my formula, I want to count the years and multiplicate it with 25 trades per year.
For example, I have 10 years data and 80% for the in sample test (8 years) and two years for the out of sample test (2 years).
So I need minimum 200 trades for the in sample and 50 trades for the out of sample test.
If I use the fixed value of 200 trades I often get no results on the out of sample test, because there are not so much trades.
Now I was thinking that formula [YearlyReturn.Count] count the years of the test period and I must only multiplicated with 25.
On a other thread I found your fitness formula:
bool posYears = true
for(int i=0;i < YearlyReturn.Count;i++)
{
if(YearlyReturn[i] < 0)
{
posYears = false;
break;
}
}
if(posYears)
{
Fitness = AnnualReturn;
}
else
{
Fitness = double.NaN;
}
That formula is also using the same statement to control the loop?
Now we know, with that statemend we got the years of the simulation, but why is my reduced formula not working?
I tried it agein with an extra variable, but it's also not working, see here:
double vMinTrades = YearlyReturn.Count * 25; // Minimum trades per year
bool ok = NumberOfTrades >= vMinTrades; // Eenought trades?
if (ok)
{
Fitness = SharpeRatio; //or something else // If yes, set the fitness value
}
else
Fitness = 0;
I just checked your formula (the last one you posted today) - it works! - so the problem must be somewhere else.
Periods can be set in the trading system and in the optimizer as well, please check if they are the same. What happens if you just put Fitness=YearlyReturn.Count without the "ok" logic? Will the result be the number of years in your trading system?
Off topic: pls expect an answer to your email some time next week
Now I got the following results, on the fitness column 350 and on the year column 15
The calculation is more or less correct (one year to much), but if I use the "OK" logic it is not working anymore.
I am getting trading systems with lower amount of trades?
Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.