@jcl: The uninitialized variable doesnot matter its no longer used... Yeah i did work on something else that did not really work...

Anyway the error that it crashes everytime i restart is actually no longer occuring with the script above. My script did close one trade everytime it was restarted and i already removed that mistake in the script above. But it seems like it crashes everytime a trade is closed.