Thanks jcl! I've set the CancelOtherTrades variable back to 0 after all trades are cancelled. However, the TMF as written doesn't enter trades in the opposite direction at the weekly close. I'm sure the solution must be a simple one, but I just don't know what I'm missing. Is it something to do with the "Entry" parameter not being used correctly in the TMF?