A very simple code aiming to help you size your position, according to the amount you're accepting to lose AND the current ATR.
Why is it important to use ATR size ? Markets move, and having fixed stoploss values will lead to getting stopped out in case of increase.
You also need to size down your trades in case of more volatily, as more points can be taken or lost.
Hope it helps!
Kudos to Racer9 who inspired me :
And it's safer to take round low, than up.