You need at least a lookback of 60 for your example. ATR is a indicator which needs a lookback period.
If you don't use it, you need no lookback. That's why the script without ATR worked.

Attached Files lookback.jpg