Hi Pjotterd.
There was an excellent post about money management but I can repeat it here. It will take into consideration how much your code earned, and place x amount of contract for you vs. your risk. It will accumulate your contract when you win and vice versa.
//REM Money Management
Capital = 1000
Risk = 0.01
StopLoss = 10 // Could be our variable X
// Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*Risk)
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
BUY PositionSize CONTRACT AT MARKET
when the system ask how many contract you want to trade when preparing is the max contract you want to use.
Br. Elsborgtrading