Dear all, I’ve been trying for long to figure out why my code gets divison by zero error. Usually i can’t even start the code without that it goes 1 minute and it shuts down with division by zero error. But on some occasions, dont ask me why, it can start and run, but if i stop and try to run it again it wont work. I’ve narrowed it down to my position sizing calculation, since if i remove this it works fine. But i can figure out how to change the code to have the same position sizing code without causing divison by zero error. The thought is to not risk more that 0,5% of the Equity by setting a stop in relation to ATR on entry. WCS = MyStop InitialEquity = 3000 Equity = InitialEquity+Strategyprofit MyPercRisk = 0.995 MinPositionSize = 1 PositionSize = MinPositionSize*ROUND((Equity-(Equity*MyPercRisk))/(((MinPositionSize*WCS)))) Timeframe (5 minutes) IF NOT ONMARKET THEN IF Z1 or Z2 or Z3 or Z4 or Z5 or Z6 or Z7 or Z8 or Z9 or Z10 THEN MyStop = AverageTrueRange[17](close[3])*ATRMult BUY Positionsize CONTRACTS AT MARKET endif endif IF Z1 or Z2 or Z3 or Z4 or Z5 or Z6 or Z7 or Z8 or Z9 or Z10 THEN MyStop = AverageTrueRange[17](close[3])*ATRMult SELLSHORT Positionsize CONTRACTS AT MARKET endif I would be happy with suggestions that i could try, Best regards Anders