Matped, what period did you use to train? How many wfo cycles did you use? I ask you because I tried to reproduce your figures in order to help you but I got nowhere near, I used this script:

Code:
function TFM()
{
	/* Annual return 245%
	Profit factor 4.23 (PRR 3.61)
	Sharpe ratio 0.88
	Kelly criterion 0.31
	R2 coefficient 0.808
	Ulcer index 10.0%
	Prediction error 36%
	*/
	algo("TFM");
	var mmiPeriod = optimize(100, 25, 600, 25 );
	var lpPeriod = optimize( 90, 30, 150, 6 );
	Stop = optimize(4, 2, 8, 0.5) * ATR(100);
	
	var stopPip = Stop / PIP;
	var minPip = 10;
	Trail = stopPip * minPip;
	TrailSlope = (minPip * 100) / stopPip;
	TrailLock = optimize (0, 0, 75, 5);
	
	vars Price = series(price());
	vars Trend = series(LowPass(Price, lpPeriod));
	vars MMI_Raw = series(MMI(Price, mmiPeriod));
	vars MMI_Smooth = series(LowPass(MMI_Raw, mmiPeriod));
	
	if(Train && ParCycle <= 2) {
		Stop = 4 * ATR(100);
		TakeProfit = 8 * ATR(100);
		Trail = 0;
		TrailSlope = 100;
		TrailLock = 0;
	}
	
	if(falling(MMI_Smooth)) {
		if(valley(Trend)) {
			enterLong();
		}
		else if(peak(Trend)) {
			enterShort();
		}
	}
}

function run(){
	set(PARAMETERS);
	NumWFOCycles = 10;
	LookBack = 600;
	TFM();
	//plotMAEGraph(100);
}



And after I trained (Zorro 1.44) it produced this result:

Code:
Walk-Forward Test TFM EUR/USD

Simulated account   AssetsFix 
Bar period          1 hour (avg 86 min)
Simulation period   07.02.2011-26.04.2016 (31591 bars)
Test period         11.02.2013-26.04.2016 (19386 bars)
Lookback period     600 bars (5 weeks)
WFO test cycles     9 x 2154 bars (18 weeks)
Training cycles     10 x 12205 bars (105 weeks)
Monte Carlo cycles  200
Assumed slippage    10.0 sec
Spread              0.5 pips (roll -0.02/0.01)
Commission          0.60
Contracts per lot   1000.0

Gross win/loss      719$ / -952$ (-2675p)
Average profit      -73$/year, -6.06$/month, -0.28$/day
Max drawdown        -238$ -102% (MAE -245$ -105%)
Total down time     97% (TAE 66%)
Max down time       163 weeks from Mar 2013
Max open margin     40$
Max open risk       35$
Trade volume        493516$ (154060$/year)
Transaction costs   -20$ spr, -2.37$ slp, -0.49$ rol, -27$ com
Capital required    271$

Number of trades    456 (143/year, 3/week, 1/day)
Percent winning     22.8%
Max win/loss        47$ / -17$
Avg trade profit    -0.51$ -5.9p (+79.4p / -31.1p)
Avg trade slippage  -0.01$ -0.1p (+0.9p / -0.3p)
Avg trade bars      30 (+75 / -17)
Max trade bars      376 (22 days)
Time in market      72%
Max open trades     4
Max loss streak     19 (uncorrelated 26)

Annual return       -27%
Profit factor       0.76 (PRR 0.65)
Sharpe ratio        -0.87
Kelly criterion     -2.86
R2 coefficient      0.419
Ulcer index         100.0%
Prediction error    56%

Confidence level     AR   DDMax  Capital

 10%                -40%   147$  182$
 20%                -36%   166$  201$
 30%                -33%   189$  223$
 40%                -29%   216$  249$
 50%                -26%   245$  277$
 60%                -24%   277$  308$
 70%                -21%   313$  343$
 80%                -19%   351$  380$
 90%                -16%   415$  442$
 95%                -14%   482$  506$
100%                -11%   613$  633$

Portfolio analysis  OptF  ProF  Win/Loss  Wgt%  Cycles

EUR/USD:TFM         .000  0.76  104/352  100.0  \\X\XX\X\
EUR/USD:TFM:L       .000  0.63   49/186   89.2  \\/\\\\/\
EUR/USD:TFM:S       .000  0.94   55/166   10.8  \\\\//\\\



Anyway, looking at the manual about TradeMAE it says 'Maximum adverse excursion, the maximum price movement in adverse direction of the trade. Only valid when the trade is open. TradeMAE*TradeUnits is the highest loss of the trade while it was open (aside from trading costs). '

So maybe use

Code:
int maxMAE(var maxPIP){
    if (TradeIsOpen and TradeMAE*TradeUnits > maxPIP*PIP) 
        return 1;
    else 
        return 0;
}