Ah, no, I had not seen it. Of course, this script will produce a random result. You're not returning anything from your TMF, so it just closes or continues the trade randomly, depending on the printf return value.

A TMF that does nothing must return 0. Omitting the return value won't work.