Frist, As is, your int tmf() is not a "trade-management function". It is not called as an argument in an entry/exit statement, so it is just a normal function.
As a normal function, it has no access to Trade variables , incl. TradeIsEntry.

Second, TradeIsEntry has a value when a trade is entered with "Entry"; Entry has to be set to a value.
Review the manual on Entry.

I did not run nor experimented with the code. Just first observations..