## Testing Optimal f

Discussions about Money Management and Risk Control.
ratio
Roundtable Knight
Posts: 338
Joined: Sun Jan 15, 2006 11:07 pm

### Testing Optimal f

Well I was curious to program a system that would calculate the unit size using the "optimal f" calculation.

It appear that it look good when you apply it to your system when you know what was your biggest losing trade. However In trying to apply it in an ongoing trading journey, as per the included script does. This script look at the past history of trade as it is advencing in time, and calculate the current Optimal f, given what we know at that time. As you will see and if you experiment, hopefully you wont encounter, a bigger (biggest losing trade) or you will go bankrupt pretty fast.

Any comment, anybody have traded with this "Optimal f"

The result in the table below are for a sample trading system that follow trend line. The contract is Feeder Cattle.

The First Chart is for a single contract per trade.
The third is with Optimal f (and unfortunately the 3rd trade was a bigger loser than the first one)

Also you have the modified Multi money manager that implement the Optimal f
==================================
VARIABLES: adjustedEquity, riskEquity, dollarRisk TYPE: Money
VARIABLES: loopf,Optimalf,p TYPE: FLOATING
VARIABLES: HPR,TWR,PREVTWR TYPE: FLOATING
VARIABLES: LargestLosing TYPE:FLOATING

IF algorithm = FIXED_FRACTIONAL THEN

' Compute the risk equity.

' Compute the dollar risk.
dollarRisk = entryRisk * instrument.bigPointValue

' Adjust the unit to this percentage.
IF dollarRisk = 0 THEN
unitSize = 1
ELSE
unitSize = riskEquity / dollarRisk
ENDIF

ELSE IF algorithm = SINGLE_CONTRACT THEN

' Just use a single contract.
unitSize = 1

ELSE IF algorithm = VOLATILITY_ADJUSTED THEN

' Compute the risk equity.

' Compute the dollar risk.
dollarRisk = averageTrueRange * instrument.bigPointValue

' Adjust the unit to this percentage.
IF dollarRisk = 0 THEN
unitSize = 1
ELSE
unitSize = riskEquity / dollarRisk
ENDIF
ELSE IF algorithm = OPTIMAL_F THEN

LargestLosing = 0

endif
next

PRINT "============================================================"
PRINT "Date= " + test.currentdate + " total trade = " + test.totaltrades + " LargestLosing = " + largestlosing
if LargestLosing < 0 and test.totaltrades >= 2 THEN
loopf = 0.00
TWR = 1
PREVTWR = 0
while TWR >= PREVTWR
PREVTWR = TWR
loopf=loopf+0.01
TWR = TWR * HPR
PRINT "loopf=" + loopf + " HPR=" + HPR + " TWR= " + TWR + " Trade Proft=" + test.tradeprofit[looptrade] + " Largest losing=" + largestlosing

next

endwhile

unitsize = asinteger(system.tradingequity / (abs(largestlosing) / loopf))

ELSE
unitsize = 1

ENDIF

PRINT "UNITSIZE ======> " + unitsize + " Optimal f = " + Loopf
ENDIF

' Set to filter the trade if the unitsize is zero
IF unitSize = 0 THEN unitSize = FILTER
Attachments
FCOneCOntract.png (16.68 KiB) Viewed 8619 times
FCVolatility.png (16.21 KiB) Viewed 8619 times
Optimal f
FCOptimal.png (17.9 KiB) Viewed 8619 times

Tim Arnold
Posts: 8624
Joined: Tue Apr 06, 2004 1:41 pm
Location: Boston, MA
Contact:
You will certainly go bust trading with Optimal F as a unit size. That is way too much heat for futures.

BARLI
Roundtable Knight
Posts: 650
Joined: Sat Jan 17, 2004 6:01 pm
Location: USA
Tim, what from your experience works best for futures, if system has a win per. of 60%?

sluggo
Roundtable Knight
Posts: 2986
Joined: Fri Jun 11, 2004 2:50 pm
Maybe it would be a good idea to find out more about a system than just its "winning percentage", before choosing a betsize.

BARLI
Roundtable Knight
Posts: 650
Joined: Sat Jan 17, 2004 6:01 pm
Location: USA
Short term, 2 days hold on avg, PF 1.4 . Win 62% Los 38%

sluggo
Roundtable Knight
Posts: 2986
Joined: Fri Jun 11, 2004 2:50 pm
I'd run some Monte Carlo equity curve resampling studies at various betsizes, and have a look at the (depth of drawdown) and (length of drawdown) plots. I would ask myself "Can I Keep Going When This Happens?" If not, turn down the heat, run the studies again, and look at the plots again.

But hey, that's just me. Others would approach it differently, I'm sure.
Attachments
mcsetup.png (11.76 KiB) Viewed 6683 times

BARLI
Roundtable Knight
Posts: 650
Joined: Sat Jan 17, 2004 6:01 pm
Location: USA
makes sence to me too, but doesn't Monte Carlo leave much space to a chance? What about exhaustive run?

sluggo
Roundtable Knight
Posts: 2986
Joined: Fri Jun 11, 2004 2:50 pm
Here's a comprehensive discussion about Monte Carlo resampling of equity curves: http://www.tradingblox.net/Files/MC_res ... _Nbars.pdf