You can set Stop etc. also in enterLong. The crash was probably caused by the "0.1" - if you don't give an integer here, enterLong assumes that it's a pointer to a trade function, calls a nonexistent function, and consequently crashes.