Step 1g: Goal: determine if equity-curve trading would be helpful
Yes WFO; Yes oversample; Yes maxtrades; Yes all param optimizing; Yes best modifier(s); Yes emode

Similar to other steps in this process, I've extracted the equity-curve trading feature into a modular on-off switch. During this step, I test each of the "emodes" as a layer on top of what has already been built from Step 1f.

When I began researching equity-curve trading, I realized there are many ways to slice-and-dice. Perhaps there is no "right way" and obviously your mileage may vary... so feel free to experiment (and let me know if you come up with something better!)

I tried to optimize the thresholds of these curves, but that never worked very well in my experience. Instead, I came up with a set of wider and narrower curves. It didn't seem to make good logical sense to me that the curves themselves should be optimized, because this is just a filter layer on top of the already-optimizing trade logic.

Instead, as you can see below, I have various curve widths that I will generally test as part of this step and then settle on one. I think the curve width probably relates to the BarPeriod of the strategy, so it may not be the same between strategies. I'm certainly open to suggestions on how this can be improved and/or made more dynamic.

In the meantime, I have the following emode switches that can be easily turned on. This code goes just above the "edge trading logic" section:
Code:
//equity-curve trading
	//checkEquity(1); //emode 1: normal/phantom trading
	//reversedir = checkEquity(2); //emode 2: switch hitter
	//maxtrades = checkEquity(3); //emode 3: reward success
	//checkEquity(4); //emode 4: mean-reversion mode


By simply un-commenting one of the 4 available emodes, you can quickly Train and Test how the bot would perform utilizing phantom trades based on the equity curve.

The actual emode function is below:
Code:
function checkEquity(var emode)
{
	//emode 1 = standard: sets phantom/normal mode only (via Lots)
	//emode 2 = switch hitter: always in market (Lots=1), fades direction (via dir)
	//emode 3 = reward success with weighting: increase trades based on degree of improvement
	//emode 4 = mean reversion: trade when equity curve falls (Lots=1), sit out when it rises (Lots=-1)
	vars EquityCurve = series(EquityLong+EquityShort); //includes all phantom equity
	var dir; //indicates normal trade direction (dir=1) or reverse (dir=-1)

	//narrower curves
	//var slow = 50;
	//var fast = 10;

	//wider curves
	//var slow = 100;
	//var fast = 10;

	//mega-wide curves
	var slow = 200;
	var fast = 10;

	//uber-wide curves
	//var slow = 300;
	//var fast = 10;

	//optimized curves
	//var slow = optimize(50,50,300,12);
	//var fast = 10;

	vars EquityLP = series(LowPass(EquityCurve,fast));
	var EquityLPfalling = LowPass(EquityLP,slow);
	var EquityLPrisingBigger = LowPass(EquityLP,slow*3.2);
	var EquityLPrisingBig = LowPass(EquityLP,slow*1.5);
	plot("EquityLPslow",LowPass(EquityLP,slow),1,BLUE);
	plot("EquityLPfast",LowPass(EquityLP,fast),0,GREEN);
	
	if(EquityLP[0] < EquityLPfalling && falling(EquityLP)) { //drawdown
		if (emode==1) Lots = -1; //set phantom trade mode
		if (emode==2) return 1; //fade: take signals when losing
		if (emode==3) { //reward success with weighting
			Lots = -1; //set phantom trade mode
			return 1; //allow max 1 phantom trade in drawdown
		}
		if (emode==4) Lots = 1; //mean-reversion: start trading when equity curve falls
		
	}
	else { //positive equity curve
		if (emode==1) Lots = 1; //set normal trade mode
		if (emode==2) return -1; //fade: take reverse signals when winning
		if (emode==3) { //reward success with weighting
			Lots = 1; //set normal trade mode
			if (EquityLP[0] > EquityLPrisingBigger && rising(EquityLP)) return 3; //very big rising
			else if (EquityLP[0] > EquityLPrisingBig && rising(EquityLP)) return 2; //big rising
			else return 1; //rising but not yet significantly
		}
		if (emode==4) Lots = -1; //mean-reversion: stop trading when equity curve rises
	}
}



So the process in this Step 1g is to Train and Test once with each emode, and see if there is a noticeable improvement using any of the modes. In the case of this bot, I have chosen emode 1 which improves the AR% to 54% now.

Coming next... Stage 2a: Simulate actual margin and/or reinvestment