Building an EA based on Huck's Trend Catcher 3

It is based on ForexPhantom’s Amazing Croosover System.

Indicators

5 EMA – YELLOW
10 EMA – RED
RSI (10 - Apply to Median Price: HL/2) – One level at 50.

TIME FRAME

1 Hour Only

[B]PAIRS[/B]
EURUSD

WHEN TO ENTER A TRADE

Enter LONG when the 5 period EMA crosses the 10 period EMA from underneath.
RSI must be approaching 50 from the BOTTOM and cross 50 to warrant entry.

Enter SHORT when the 5 period EMA crosses the 10 period EMA from the top.
RSI must be approaching 50 from the TOP and cross 50 to warrant entry.

[B]STOP[/B]
A 50 pip trailing stop that kicks in after the the trade is triggered.

[B]TAKE PROFIT[/B]
take profits at 200 pips

If you follow Huck’s thread the system has been doing very well and I believe it is still positive for the year.

The C code of that system would look like this:

function run()
{
	var *Price = series(price());
	var *EMA5 = series(EMA(Price,5));
	var *EMA10 = series(EMA(Price,10));
	var *RSI10 = series(RSI(Price,10));

	Stop = 50*PIP;
	Profit = 200*PIP;
	
	int crossed = 0;
	if(crossOver(EMA5,EMA10))
		crossed = 1;
	else if(crossUnder(EMA5,EMA10))
		crossed = -1;
		
	if(crossed == 1 && crossOver(RSI10,50))
		enterLong();
	else if(crossed == -1 && crossUnder(RSI10,50))
		enterShort();
}

But does not look very good. This is the equity curve:


It had a profit in 2011, but most years are not profitable.

the C code?.. nice… where do I have to go to learn how to code in C specifically for trading? Sad to see the true potential of the system though. It held so much promise.

C is very easy to learn. I’m working on a tutorial, it’s almost finished - the first 6 lessons are here: Workshop 1 - Variables

That’s interesting. Just out of curiosity I replace the EMA with a Lowpass filter, and removed the profit target. The system now looks much better. This is the new code:

function run()
{
	var *Price = series(price());
	var *EMA5 = series(LowPass(Price,5));
	var *EMA10 = series(LowPass(Price,10));
	var *RSI10 = series(RSI(Price,10));

	Stop = 50*PIP;
	
	int crossed = 0;
	if(crossOver(EMA5,EMA10))
		crossed = 1;
	else if(crossUnder(EMA5,EMA10))
		crossed = -1;
		
	if(crossed == 1 && crossOver(RSI10,50))
		enterLong();
	else if(crossed == -1 && crossUnder(RSI10,50))
		enterShort();
}

And this is the equity curve:

This looks now much more pofitable, average annual return is 135% and the Sharpe ratio is above 1.

You left out the trailing stop

Nice… The tutorial looks like something I have been searching for for months. will shortening my journey towards automated trading. Thanks so much mate… Think you can really help some people here by creating a thread and posting the lessons, so it can be more interactive.

The trailing stop reduces the profit, just as the profit target.

However the strategy has indeed potential, simple as it is. I have now made a few modifications and run a WFO optimization, which is normally a hard test if a strategy is good. This is the new script:

function run()
{
	BarPeriod = 240;
	StartDate = 2006;
	NumYears = 7;
	NumWFOCycles = 12;
	Mode = PARAMETERS+TESTNOW;
	
	var *Price = series(price());
	var *LP5 = series(LowPass(Price,5));
	var *LP10 = series(LowPass(Price,optimize(10,6,20)));
	var *RSI10 = series(RSI(Price,10));

	Stop = optimize(5,1,10)*ATR(30);
	
	static int crossed = 0;
	if(crossOver(LP5,LP10))
		crossed = 3;
	else if(crossUnder(LP5,LP10))
		crossed = -3;
		
	if(crossed > 0 && crossOver(RSI10,50)) {
		enterLong();
		crossed = 0;
	} else if(crossed < 0 && crossUnder(RSI10,50)) {
		enterShort();
		crossed = 0;
 	} else
		crossed -= sign(crossed);
}

The strategy works well with several different assets, which is also a strong indicator that it stays profitable even when the market changes. This is the equity curve:

It has still 138% annual return on EUR/USD, with Profit Factor = 2.73 and Sharpe Ratio = 1.48.

It looks like your test is opening multiple concurrent trades. That could skew your results a bit.

Sure, any signal triggers a new trade. It makes no sense not to enter a new trade when some previous trade was not yet closed. When I prevent concurrent trades, the strategy is still profitable, but the profit goes down somewhat.

Reading more on the lessons. I ll be programming and optimising this by months end

Does it make sense to add to losing trades as well?

Just saying…

Yes. It does normally not matter if the previous trade is winning or losing. When a signal is triggered, we have a situation where entering a trade has a positive expectancy, regardless of the status of previous trades.

There can be systems with a large correlation horizon where this is different, but that are special cases.

HI,
Just wondering what is a Lowpass filter?

The price curve is often a mixture of cycles with different frequencies; a lowpass filter attenuates all cycles below a given frequency. Thus it has a similar effect as a moving average. In fact an EMA is a 1-pole lowpass filter. The LowPass function used in the script however is a 2-pole filter, which is more complex but has the huge advantage of no lag below the filter frequency. It thus generates signals earlier. We’ll deal with lowpass filters in part 2 of the automated trading course.

That course is here in babypips?

Just look for it in this very forum.

Check this forum…

Looks like promising… Keep up good work.