I worked out what was wrong and have everything backtesting correctly will report back on Monday when I test the script to ensure my trade management function is fine.