The reason you are getting the discprency is the nature of how ATR is calculated. ATR has the following definition:
The range of a day's trading is simply [high − low]. The true range extends it to yesterday's closing price if it was outside of today's range.
Note that ATR must have the ability to look back one period. This one period look back requirement means that all ATR calculations will need n+1 periods for warmup calculation.
You can check this yourself by putting say bt.ind.SMA by itself for n periods (5 in this case):
2015-07-08, Close: 30.64, sma: 31.37,
2015-07-09, Close: 30.02, sma: 31.04,
Now add in the ATR with the same period, and you will see the results start one period later.
2015-07-09, Close: 30.02, sma: 31.04, vol: 0.64
2015-07-10, Close: 30.82, sma: 30.88, vol: 0.70
None of this has anything to do with your function, but is a matter of how ATR is calculated.