I’m sharing this small code part, in order to add it to any automated trading strategy in ProOrder.
It will buy or sell the exact number of contracts each time. I.e. We want to risk maximum 1% of our equity, sometimes we will put stoploss short or longer, in any case it will know how many pips your are risking, and then calculate from there the number of contracts.
REM Money Management
Capital = 10000
Risk = 0.01
StopLoss = 10 // Could be our variable X
REM Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*Risk)
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
After that just need to change the number of contracts to “PositionSize“, like this:
// BUY order example
IF conditionBuy then
BUY PositionSize CONTRACTS AT MARKET
ENDIF
// SELL order example
IF conditionSell then
SELLSHORT PositionSize CONTRACTS AT MARKET
ENDIF
Hope it helps you,
Cheers