OK, so after all this we've come full circle. My original script looks fine, and yet it's not calculating the risk properly. Any ideas??

BTW, as I mentioned above, when I tried to trade the test scrip with lookback >60 it couldn't open any trades.