“Doesn't work” is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless. How To Ask Questions The Smart Way. (2004) When asking about code Be precise and informative about your problem
Nothing wrong with your code, except you need to call close only when valid.
Either you are not calling the function, or you are looking in the wrong place («DataFolder»\MQL4\Files vs. «DataFolder»\Tester\Files).
Please enable the necessary setting in your browser, otherwise you will not be able to log in.