Thanks for the script - this is indeed a bug which happens when you trade always long and never short. The factors are then wrong. This will be fixed in the next update.