Hi,
I'm interested in applying Kelly in a real life situation. Let's suppose we have an EA and
we play 0.1 lots (to get a linear result in testing).
Doing back-testing and optimization after 3 -5 years of back-data you get:
Version 1 - Profit 20K, max DD $800
Version 2 - Profit 14K, max DD $300
Version 3 - Profit 11K max DD $250
I calculate Prof / DD and I look for best value, in this case version 2. We can see if we use Lots 0.2 the max DD will be 600 and profit 28K so I will use version 2.
How should I calculate lot optimization from here ?
Kelly Criterion
-
garyfritz
Re: Kelly Criterion
If you want to use Kelly, I strongly suggest you study it and understand it first. For starters, you can't calculate Kelly knowing only the profit and DD.
As Khalid has said before, Kelly position sizing is aggressive and not appropriate for most traders. You should not use it unless you understand thoroughly exactly what you're doing and what risks you're taking on.
As Khalid has said before, Kelly position sizing is aggressive and not appropriate for most traders. You should not use it unless you understand thoroughly exactly what you're doing and what risks you're taking on.
-
jb68
- Trader
- Posts: 71
- Joined: Mon Jan 30, 2012 11:30 pm
Re: Kelly Criterion
I don't necessary want to use Kelly but i'm interested in a practical way to max the profits using more aggressive strategies easy to implement into an EA.
The 1% apply when you have no idea how your system performs. If you have enough back-testing and here I'm talking about back-testing since 2007 onward I think you can risk more.
However I think the graph you posted works in both ways, you can consider max DD correspond to Kelly=1.5 (backtesting with a fixed Lot will give win and DD in Pips fraction as Kelly require).
The 1% apply when you have no idea how your system performs. If you have enough back-testing and here I'm talking about back-testing since 2007 onward I think you can risk more.
However I think the graph you posted works in both ways, you can consider max DD correspond to Kelly=1.5 (backtesting with a fixed Lot will give win and DD in Pips fraction as Kelly require).
-
garyfritz
Re: Kelly Criterion
1% risk is generally safe, assuming your system works. If you've thoroughly backtested the system -- and in most cases, Empty4 backtesting does NOT qualify IMHO -- then you have a good idea how it performs. I suggest you dump your fixed-lot trades to a spreadsheet and add formulas to calculate the equity curve with different risk levels. (That's what I do.) BTW you will need not just the P/L values but also the amount risked for each trade, so you know how many lots to risk to result in risking X% of your account.jb68 wrote:The 1% apply when you have no idea how your system performs. If you have enough back-testing and here I'm talking about back-testing since 2007 onward I think you can risk more.
I don't understand what you mean by "max DD correspond to Kelly = 1.5." For one thing, Kelly is normally expressed as a fraction or percent, between 0.0 and 1.0. For another, DD is not used in the calculation of the Kelly value.However I think the graph you posted works in both ways, you can consider max DD correspond to Kelly=1.5 (backtesting with a fixed Lot will give win and DD in Pips fraction as Kelly require).
-
jb68
- Trader
- Posts: 71
- Joined: Mon Jan 30, 2012 11:30 pm
Re: Kelly Criterion
1% is safe if you are using a linear approach like risking the same amount each time. A system where we reinvest profit is not linear anymore.
Most used function on Ea to optimize lots are something like this:
Amount_to_Risk = account_equity * k (where k is a factor which will give us an amount to risk lets say 1%)
This will reinvest the profit so we will get an exponential curve as a return.
However is we lose the chance to broke our account are 0 on theory and slim in reality because bet cannot be less then a certain amount (0.01)
k can go pretty big in this calculation and return which are exponential will grow accordingly.
As nothing is perfect there is a bad size...
For a linear example if we get the Max DD by loosing 50 times we will recover by winning 25. ( 1:2 bet)
On our exponential system our recovery will be roughly at least after 50 bets. Recovery will take even longer if we go more aggressive.
In the first formula we can say.. account equity= account_start+profit
so
Amount_to_Risk = account_start*k + profit*k
As IronRick said some people are more keen to risk just some part of the account and they might like to risk more of their profit(free money) then initial money(hard worked). Similar result with his example we obtain if we add different coefficients to account start and profit.
Amount_to_Risk= a*account_start*k + b*profit*k
A simple example will be a=0.5 and b=2. This will means we will risk more from every win and is more aggressive then first part but will not work forever. Risking 0.1 of the account as per IronRick will be achieved with a=0.1 and b=1.
Calculating k with Kelly will be K= W - (1-W)/R where W= winning percentage and R average Win/average loss. However W and R are quite complicated to come up with on a normal FX strategy because we may have break even, break_even+ pips, winning after trailing stop, winning with TP. However average win will be total profit/ total wins.
Now here are some real data from a system I played with..
W=45%, R=5.6/4=1.4 so K = 76%. Based on our Kelly we should risk 76% of our account on each trade this system.
As I said before the more aggressive we are, the more time we need to recovery our account from DD. DD is not used in calculation but is the worst thing and we should pick whatever optimization will come up with the best Prof / DD .
Our Kelly, 76% is really aggressive and most of the time our account will be in recovery but in the end will get a pile of money so this will not do any good to our sanity...
I'm more keen to something like.. K=10-20% and using different values for a and b, more like this.
Amount_to_Risk=(0.5 *account_start+2*profit) *k - aggressive to start and grow account
and then move to something more like
Amount_to_Risk=(0.2 *account_start+0.4*profit) *k
After deciding the Amount_to_risk then we can easy calculate Lots based on SL and eventually on $ per pips.
Most used function on Ea to optimize lots are something like this:
Amount_to_Risk = account_equity * k (where k is a factor which will give us an amount to risk lets say 1%)
This will reinvest the profit so we will get an exponential curve as a return.
However is we lose the chance to broke our account are 0 on theory and slim in reality because bet cannot be less then a certain amount (0.01)
k can go pretty big in this calculation and return which are exponential will grow accordingly.
As nothing is perfect there is a bad size...
For a linear example if we get the Max DD by loosing 50 times we will recover by winning 25. ( 1:2 bet)
On our exponential system our recovery will be roughly at least after 50 bets. Recovery will take even longer if we go more aggressive.
In the first formula we can say.. account equity= account_start+profit
so
Amount_to_Risk = account_start*k + profit*k
As IronRick said some people are more keen to risk just some part of the account and they might like to risk more of their profit(free money) then initial money(hard worked). Similar result with his example we obtain if we add different coefficients to account start and profit.
Amount_to_Risk= a*account_start*k + b*profit*k
A simple example will be a=0.5 and b=2. This will means we will risk more from every win and is more aggressive then first part but will not work forever. Risking 0.1 of the account as per IronRick will be achieved with a=0.1 and b=1.
Calculating k with Kelly will be K= W - (1-W)/R where W= winning percentage and R average Win/average loss. However W and R are quite complicated to come up with on a normal FX strategy because we may have break even, break_even+ pips, winning after trailing stop, winning with TP. However average win will be total profit/ total wins.
Now here are some real data from a system I played with..
W=45%, R=5.6/4=1.4 so K = 76%. Based on our Kelly we should risk 76% of our account on each trade this system.
As I said before the more aggressive we are, the more time we need to recovery our account from DD. DD is not used in calculation but is the worst thing and we should pick whatever optimization will come up with the best Prof / DD .
Our Kelly, 76% is really aggressive and most of the time our account will be in recovery but in the end will get a pile of money so this will not do any good to our sanity...
I'm more keen to something like.. K=10-20% and using different values for a and b, more like this.
Amount_to_Risk=(0.5 *account_start+2*profit) *k - aggressive to start and grow account
and then move to something more like
Amount_to_Risk=(0.2 *account_start+0.4*profit) *k
After deciding the Amount_to_risk then we can easy calculate Lots based on SL and eventually on $ per pips.
-
garyfritz
Re: Kelly Criterion
That's a different formula than I use. I use K = AverageTrade / AverageWin.jb68 wrote:Calculating k with Kelly will be K= W - (1-W)/R where W= winning percentage and R average Win/average loss.
AverageTrade = W * AverageWin - (1-W) * AverageLoss, so
K = (W * AverageWin - (1-W) * AverageLoss) / AverageWin = W + (1-W) / (AverageLoss/AverageWin) = W - (1-W)/R. Same formula.
How did you get 76% ?? R = 5.6/4 = 1.35. K = W - (1-W)/R = 0.45 - 0.55/1.35 = 0.0426. That's 4.26%, not 76%! Risking 4.26% of your account would be trading at full Kelly.W=45%, R=5.6/4=1.4 so K = 76%.
(I double-checked the numbers with my Kelly formula and they don't quite match!? AvgTrade = W * AvgWin - (1-W) * AvgLoss = 0.45 * 5.6 - 0.55 * 4 = 0.32. Then Kelly = AvgTrade / AvgWin = 0.32 / 5.6 = 0.057?? It's *close* to 0.0426, but it should be identical. Not sure where I goofed there.)
IF your Kelly was 76%, that would be trading at full Kelly. You have to be crazy to do that. As you said later, trading at 10-20% of full Kelly is a lot more sane. Given your Kelly value of 0.0426 that would be 0.426% - 0.852% of your account, or $42.60 - $85.20 on a $10,000 account.Based on our Kelly we should risk 76% of our account on each trade this system.
-
jb68
- Trader
- Posts: 71
- Joined: Mon Jan 30, 2012 11:30 pm
Re: Kelly Criterion
He he.. sorry you are right, thanks for pointing it out, I used percentage when I was supposed to use 0 - 1.
I decided to play again with Kelly this night. I couldn't replicate that system anymore so I did on another..
This time Kelly was 13% and was calculated right as you said. I put that number based on SL and everything was insane.. After 1100 trades Lot size was 90341 and after that died.. Profit for that trade alone was more than 5 million.
However max relative DD was 80% from 3% on linear mode and as I said system died so I cannot tell if survived till the end. I tried 0.3 Kelly and still makes too much money for Empty4.
I decided to play again with Kelly this night. I couldn't replicate that system anymore so I did on another..
This time Kelly was 13% and was calculated right as you said. I put that number based on SL and everything was insane.. After 1100 trades Lot size was 90341 and after that died.. Profit for that trade alone was more than 5 million.
However max relative DD was 80% from 3% on linear mode and as I said system died so I cannot tell if survived till the end. I tried 0.3 Kelly and still makes too much money for Empty4.
-
garyfritz
Re: Kelly Criterion
80% DD is actually fairly low if you're trading at full Kelly! Try it at 10% or 20% of full Kelly and it shouldn't blow up Empty4. 
-
jb68
- Trader
- Posts: 71
- Joined: Mon Jan 30, 2012 11:30 pm
Re: Kelly Criterion
Unfortunately my Empty4 explode even if I start with $100. Using figures close to Kelly I end up with an amount approaching fast to US debt.
The downsize is actually the max DD and trader happiness. Is well known everybody likes to win so a long period in DD will come with some depression especially when you can be thousands away from the Max.
I will have a look at using different coefficients. Did you look into using a logarithmic function in order to grow fast at the beginning and slow growth at the end?
The downsize is actually the max DD and trader happiness. Is well known everybody likes to win so a long period in DD will come with some depression especially when you can be thousands away from the Max.
I will have a look at using different coefficients. Did you look into using a logarithmic function in order to grow fast at the beginning and slow growth at the end?
-
garyfritz
Re: Kelly Criterion
No, I haven't looked at that. I never liked that "grow fast at the start" approach of Ryan Jones' Fixed-Ratio approach, either. I'm not willing to take huge risks just because my account is small. I want to take good care of my account no matter its size.