Something is wrong with your TMF parameter. You can use it for enterLong, but not for exitLong. Unexpected trades are probably caused by the Entry variable.