This is wrong:
vars BSpread = series(APrice - BPrice);
Correct would be this:
var BSpread = APrice - BPrice;
Also wrong:
vars APrice = series(priceClose()) ;
Correct:
var APrice = priceClose();
Remove all those "series" and your code is a lot better. Use no functions if you do not know what they do and how to use them.