havent tested it, butjust glancing over and you typoed near the bottom
var% test = $calc($ticks - %ba)
var %test = $calc($ticks - %ba)