Vol = any volatility indicator of your choosing such as ATR
SLmultiplier = a variable of your choosing.
TPmultiplier = a variable of your choosing
Risk = a variable of your choosing: percentage risk of account balance per trade
I hope the rest are self explanatory.
TPsize = Vol * TPmultiplier SLsize = Vol * SLmultiplier SLticks = SLsize / TickSize AmtToRisk = Risk * 0.01 * AccountBalance Lotsize = AmtToRisk/SLticks/TickValue