Prorealtime Bank Builder Money Management Code

Below is the new money management code that I have implemented in all my live systems, it combines a bank with a max position size in a way that allows for a max size based on the bank but then limited by the numbers of contracts. This should help to overcome some of the limitations of the previous code when dealing with products with both low and high prices

Code:

Once moneymanagement =0//0 = flat size, 1 = money management
Once Flatstake = 0.5
Once DDPP = 117// Max DD Per Point
Once DDM = 2 // Multiples of max drawdowns to factor into positionsize
Once Capital = 1000//starting bank
Once Maxbank = 5000 //max bank size
Once DPct = 5 //% margin for deposit
Deposit = (open/100)*DPct //Margin per point
Once PRI = 1 // percent to reinvest as a decimal ie 0.5 = 50%
Once Maxsize = 2.5 //max position size (per trade not cumulative if accumulating positions)
Once Minsize = 0.5 //min position size (per trade not cumulative if accumulating positions)
Once Quitsize = -1000 //after strategy has lost more than this value it will not open new trades
Bank = (Capital +(STRATEGYPROFIT*PRI))
if Bank > maxbank then
Bank = maxbank
endif
Positionsize = Bank/((DDM*DDPP)+Deposit)
if positionsize > maxsize then
positionsize = maxsize
endif
if positionsize < minsize then
positionsize = minsize
endif
if moneymanagement = 0 then
positionsize = flatstake
else
positionsize = positionsize
endif
if strategyprofit < quitsize then
quit
endif

Leave a Comment