I can't find any error in the script either. The script is working perfectly for me.
When market is closed, I am unable to check if the issue is related to setting or not. The only issue I can say, you can double check in the configuration window setting if you enabled "double click to trade" or not.
Best of luck.