I get the wrong results with the wrong script and the right results with the right script. Here is it:

Code:
var objective()
{
	return ((var)(NumWinLong+NumWinShort))/(NumLossLong+NumLossShort);
}


function run()
{
	assetList("AssetsFix.csv");
	set(PARAMETERS|LOGFILE|TESTNOW);
	BarPeriod = 5;
	LookBack = 100;
	NumWFOCycles = 20;
	NumCores = -2;
	PlotHeight1 = 340;
	PlotWidth = 800;
	
	set(BINARY);
	
while (asset(loop("EUR/USD")))
{	
	WinPayout = 75;
	LossPayout = 0;
	Spread = Commission = 0;
	LifeTime = 1;
	int TimePeriod = optimize(20,10,100);
	var Threshold = 0.01*(HH(TimePeriod)-LL(TimePeriod));

	if(NumOpenLong+NumOpenShort == 0) 
	{
		if(HH(TimePeriod) - priceClose() < Threshold)
			enterShort();
		else if(priceClose() - LL(TimePeriod) < Threshold)
			enterLong();
	}
}
}