Thanks, that makes sense. I've changed my script to use global variables instead of TradeVars. My script now enters just one trade for the entire simulation period. After it is stopped out, no new trades are entered. Therefore, I think there is an error in the TMF script. Any ideas?

Updated script:
Code:
#define H1 (60/BarPeriod)
#define H24 (1440/BarPeriod)
#define W1 (7200/BarPeriod)
var LastWeekClose;
int CancelOtherTrades;

int myTMF() { //if stopped out, set pending at W1close in opp direction
	if (TradeIsLong and TradeIsStop) {
		//enter at last close
		Entry = LastWeekClose;
		Stop = 30*PIP;
		enterShort(myTMF);
	}
	if (TradeIsShort and TradeIsStop) {
		Entry = LastWeekClose;
		Stop = 30*PIP;
		enterLong(myTMF);
	}
	if(TradeIsPending and CancelOtherTrades == 1)
	return 1;
	if(TradeIsOpen) {
		CancelOtherTrades = 1;
		ThisTrade->manage = 0; // terminate the TMF
	}
	return 0;
}

function frameAlign(BOOL Event){ 
	TimeFrame = 1;
	vars Num = series(0); // use a series for storing Num between calls
	Num[0] = Num[1]+1;    // count Num up once per bar  
	if(!Event) 
	TimeFrame = 0;      // continue current time frame  
	else {
		TimeFrame = -Num[0]; // start a new time frame
		Num[0] = 0;          // reset the counter  
	}
}

function run() {
	set(TICKS);  // normally needed for TMF
	Weekend = 3; // don't run TMF at weekend
	StartDate = 20141201;
	EndDate = 20141231; //preserve 2015 data for OOS testing
	BarPeriod = 60;
	if (is(INITRUN)) CancelOtherTrades = 0;
	
	TimeFrame = W1;
	frameAlign(dow() == 7 and hour() == 23);
	vars closeW1 = series(priceClose());
	LastWeekClose = closeW1[0];
	
	TimeFrame = H1;
	int exitDay = 5;
	int exitHour = 16;
	

	if (!(dow() == exitDay and hour() >= exitHour)) {
		Entry = closeW1[0] + 50*PIP;
		Stop = 30*PIP; 
		if (NumOpenLong == 0) {	enterLong(myTMF, LastWeekClose); } 
		Entry = closeW1[0] - 50*PIP;
		if (NumOpenShort == 0) enterShort(myTMF, LastWeekClose);
	}
	
	if (dow() == exitDay and hour() == exitHour) {exitLong("*"); exitShort("*");}
	
	
	plot("closeW1", closeW1, MAIN, RED);