My Zorro Adventure

So after going through the Automated Trading Course one and two, I have decided to focus a bit more on the automated side of things. Programming has always been something I have wanted to learn and the above course offered a bit of it. I am currently learning C++ to move my programming skills to the level that will make this thread blossom. What I plan to do is go over Robopips blog post and start automating all the systems he has reviewed with Zorro.

I hope to bring a lot more people on the Zorro train as we embark on this study and exploration journey together. Take sometime to review the course on babypips and the C++ tuts.

1 Like

First system we are looking at is Hucks Trend Catcher. This one will be a bit easy as jcl365 has done most of the work.

Original Rules
Indicators

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

TIME FRAME

1 Hour Only

PAIRS
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.

STOP
A 50 pip trailing stop that kicks in after the the trade is triggered.

TAKE PROFIT
take profits at 200 pips

The C code for this system as posted by jcl is

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();
 }


Equity Curve



This is system shows us how one can be under the illusion that a system is profitable or not based on when one starts trading it.

Revisied
Jcl made some changes to the system and we ended up with an even more profitable system.


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);
 }

Equity Curve



This system is now highly trade-able with a with Profit Factor = 2.73 and Sharpe Ratio = 1.48.

So now I would like to take this, one step further. Add a lot more assets mainly (“EUR/USD”,“USD/JPY”,“GBP/USD”,“USD/CHF”,“AUD/USD”,“EUR/JPY”,“USD/CAD”,“NZD/USD”,“XAU/USD”,“XAG/USD”). I will also use the re-investment line to help increase the return.

If anyone has got an idea how we can improve this system chim in

Good stuff liftoff!
I’m a bit behind on jcl365’s tutorials, but I hope to finish them and also join you in your thread.

Cheers!

Programming requires many eyes when you are starting out…so this thread should help us see errors -correct them, find simpler ways of doing something in code and a lot more… welcome on board

Hello Guys,

I’ve putting together from some EA that I’ve been testing + some code parts from Dinesh’s codes style and from what I got regarding liftoff’s description here’s a kickoff EA for MT4:

I’m using SAR as trailing stop then:
5 EMA / 10 EMA / RSI (10,HL/2) at 50

Zorro_V1.zip (2.97 KB)

I’m just missing 2 things in the code:

  1. RSI are trading even though the RSI_Prv and RSI_Aft are below or above 50 Level.
  2. Understand what is that func optimize is really doing on the Revised code.

Despite of the 2 missing points , did a backtest and it looks promissing to me.

I wonder how Laguerre RSI might look like with MM on this system.

Cheers.

Work has been so demanding lately. I really hope I can finish up and get back to seeing this thread through…

Two years later I return to continue my work.
Wanted to try the revised the trend catch script on some new price series and the result is as follows.



And the stats


Walk-Forward Test babypipstest1 EUR/USD - performance report

Simulation period   23.01.2006-11.01.2014
Test period         25.06.2008-11.01.2014
WFO test cycles     13 x 641 bars (22 weeks)
Training cycles     14 x 3632 bars (125 weeks)
Lookback time       80 bars (19 days)
Assumed slippage    10.0 sec
Assumed spread      2.4 pips (roll -0.03/0.01)
Contracts per lot   1000

Gross win/loss      2012$ / -1465$ (+7199p)
Average profit      99$/year, 8.22$/month, 0.38$/day
Max drawdown        -246$ 45% (MAE -323$ 59%)
Total down time     84% (TAE 88%)
Max down time       63 weeks from Oct 2008
Largest margin      45$
Trade volume        229271$ (41344$/year)
Transaction costs   -41$ spr, -1.24$ slp, -1.34$ rol
Capital required    226$

Number of trades    224 (41/year, 1/week, 1/day)
Percent winning     46%
Max win/loss        93$ / -56$
Avg trade profit    2.44$ 32.1p (+20$ / -12$)
Avg trade slippage  -0.01$ -0.1p (+0.02$ / -0.03$)
Avg trade bars      59 (+83 / -38)
Max trade bars      302 (10 weeks)
Time in market      159%
Max open trades     9
Max loss streak     8 (uncorrelated 10)

Annual return       52%
Profit factor       1.37 (PRR 1.13)
Sharpe ratio        0.47
Kelly criterion     0.50
Ulcer index         23.8%
Prediction error    35%

Portfolio analysis  OptF  ProF  Win/Loss  Wgt%  Cycles

EUR/USD             .026  1.37  102/122  100.0  X\X/X/X/X/X\X
EUR/USD:L           .000  0.95   43/57    -5.9  \\//\///\//\/
EUR/USD:S           .042  1.72   59/65   105.9  /\\///\///\\\

Not a really trad-able system in hindsight.

I saw Hucks report of her systems performance last year and I tried to replicate it with the same rules on the EURUSD and GBP.
This is the code i used. I believe it captures the system as it is now. If I missed anything, please point it out.


function run(){
	
	set(TICKS);
	BarPeriod = 60;
	Hedge = 2;
	StartDate = 20131214;
	EndDate = 20131220;

	//Trading Edge
	vars Price = series(price());
	vars EMA5 = series(EMA(Price,5));
	vars EMA10 = series(EMA(Price,10));
	vars RSI10 = series(RSI(Price,10));
	
	Stop = 50*PIP;
	Trail = Stop;
	TakeProfit = 200*PIP;
	
	
	//Entry Logic
	if(crossOver(EMA5,EMA10) && RSI10[0]<50)
		enterLong();
	else if(crossUnder(EMA5,EMA10) && RSI10[0]>50)
		enterShort();
		
		
// plot indicators
  plot("EMA5",EMA5[0],NEW,BLUE);
  plot("EMA10",EMA10[0],0,RED);
  plot("RSI10",RSI10[0],NEW,BLACK);
  plot("50",50,0,BLACK);
  PlotWidth = 1200;
  PlotHeight1 = 600;
		
}

This is the EURUSD equity curve.



The GBPUSD equity curve.


If I remember correctly she managed to turn a profit on both EURUSD and GBPUSD for 2013 2013 HLHB Trend-Catcher System Results | Forex Blog: The Loonie Adventures of a Forex Noob. But the automated version seems to show a loss. Am I missing something?

From her chart, she seems to use close(1) instead of price(bid) to trigger her trades. Not sure if you have factored that into your coding.

@NMSS2, Enter on the close of the previous bar? now that is kinda hard. So she sees a crossover and waits for the current bar to close, then sets a limit or stop order equal to the close of the previous bar then hopes price touches the close again to get in? I think I factor that in. will get to it. Thanks NMSS2

Hi LiftOff!

Great initiative!

I’m also with Zorro. I actually registered for some time ago, but I’ve had a break for several months now. So I’m kinda starting over from scratch. It’s an interesting system you’ve got there, the remade version that JCL did shows promising equity curve. By the wal, JCL is truly phenomenal :).

I’m also doing the tutorials to get inspiration and I’m using elements from the tutorials with my own system (though I’m not finished yet).

Yep. Maybe we can just feed off each other and try out some systems here.

Hi,

I borrowed your system and added it to my own Zorro. Though I couldn’t ctrl + c it (the code looked like crap then :D), I had to do it manually.

I’m a little concerned about the difference of the results between yours and my system.

My code looks like this. I’ve removed the NumYears thing since I prefer to use StartDate instead. I also just use set(PARAMETERS)… which means I have to manually click the best button after I’ve clicked the train button.
So, what I can telll, there’s no real difference between our systems, yet the equity curve looks kinda crappy with my system.

Code

function run()
{

BarPeriod = 240;
StartDate = 2006;

NumWFOCycles = 12;
set(PARAMETERS);

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);

plot (“LP1”, LP5[0], 0, RED);
plot (“LP2”, LP10[0], 0, BLUE);
plot (“RSI”, RSI10[0], NEW, BLACK);
PlotWidth = 600;
PlotHeight1 = 300;
}

Equity curve with optimization only:

http://fuskbugg.se/dl/VR3C8U/Equity%20curve%20after%20optimization.jpg

And this is the equity curve after WFO:

http://fuskbugg.se/dl/Tfmhgp/Equity%20curve%20after%20WFO.jpg

Looks kinda weird, doesn’t it?

EDIT: Pictures looked like ****, had to link them instead.

Yep… tells us the system is curvefitted and if we had run it live, then we would have sailed the uneven equity curve in the WFO test.

So i tried playing around with the 3 ducks strategy in zorro and see if its any good. http://forums.babypips.com/free-forex-trading-systems/6580-3-ducks-trading-system.html.
The code I used is as follows.


function run()
{
//	set(TICKS+PARAMETERS);
	BarPeriod = 5;
	StartDate = 2010;
	EndDate =  2012;
	LookBack = 170;
	Hedge = 0;
	
	//First Duck
	TimeFrame = 48;	
	vars Price4H = series(priceClose());
	vars SMA4H = series(SMA(Price4H,60));
	
	//Second Duck
	TimeFrame = 12;
	vars Price1H = series(priceClose());
	vars SMA1H = series(SMA(Price1H,60));
	
	//Third Duck
	TimeFrame = 1;
	vars Price5M = series(priceClose());
	vars SMA5M = series(SMA(Price5M,60));
				
	Stop = 30*PIP;
//	TakeProfit = 2*Stop;
	
	
	if(Price4H[0]>SMA4H[0] && Price1H[0]>SMA1H[0] && Price5M[0]>SMA5M[0]){
		enterLong(1);
	} 
	else if(Price4H[0]<SMA4H[0] && Price1H[0]<SMA1H[0] && Price5M[0]<SMA5M[0]){
		enterShort(1);
	}
}

The EURUSD Equity curve



The stats.


BackTest ThreeDucks EUR/USD - performance report

Test period         18.01.2010-31.12.2012
Lookback time       170 bars (14 hours)
Assumed slippage    10.0 sec
Assumed spread      2.4 pips (roll -0.03/0.01)
Contracts per lot   1000

Gross win/loss      190174$ / -198568$ (-110461p)
Average profit      -2842$/year, -237$/month, -11$/day
Max drawdown        -56529$ -673% (MAE -76896$ -916%)
Total down time     93% (TAE 94%)
Max down time       81 weeks from Oct 2010
Largest margin      7185$
Trade volume        93221637$ (31566620$/year)
Transaction costs   -16767$ spr, -208$ slp, -203$ rol
Capital required    64160$

Number of trades    91938 (31132/year, 599/week, 124/day)
Percent winning     12%
Max win/loss        84$ / -3.05$
Avg trade profit    -0.09$ -1.2p (+18$ / -2.44$)
Avg trade slippage  -0.00$ -0.0p (+0.06$ / -0.06$)
Avg trade bars      559 (+3143 / -223)
Max trade bars      7057 (5 weeks)
Time in market      23824%
Max open trades     1437
Max loss streak     4138 (uncorrelated 99)

Annual return       -5%
Profit factor       0.96 (PRR 0.95)
Sharpe ratio        -0.08
Kelly criterion     -0.13
Ulcer index         123.9%
Prediction error    23%

Portfolio analysis  OptF  ProF  Win/Loss  Wgt%

EUR/USD             .000  0.96  10574/81364100.0
EUR/USD:L           .000  0.80  5267/41108232.2 
EUR/USD:S           .014  1.11  5307/40256-132.2

Not really impressive.

I wanted to try something ideas on the core concept. Here goes a couple. I am not comfortable with the 5M chart so I move up to the 30M chart for entry. I changed the stop loss to the average of the last 100 30M bars * 3. The results are as follows.


BackTest: ThreeDucks EUR/USD 2010..2012
Profit -1388$  MI -42$  DD 10374$  Capital 11476$
Trades 15911  Win 34%  Avg -1.1p  Bars 43
AR -5%  PF 0.97  SR -0.16  UI 82.1%  Error 12%
Generate Chart - please wait... ok

Still no where near impressive.

Maybe the SMA period is the problem so I pick a number that should track the weekly trend (SMA=240), the next one should capture the trend in the last 2 days (SMA=96), and the last one tries to capture the daily trend(SMA=48).


ThreeDucks run..
BackTest: ThreeDucks EUR/USD 2010..2012
Profit 86$  MI 3$  DD 6845$  Capital 7834$
Trades 19333  Win 32%  Avg +0.1p  Bars 57
AR 0%  PF 1.00  SR 0.00  UI 84.8%  Error 13%

Used a lowpass filter in place of the SMA


BackTest: ThreeDucks EUR/USD 2010..2012
Profit 86$  MI 3$  DD 6845$  Capital 7834$
Trades 19333  Win 32%  Avg +0.1p  Bars 57
AR 0%  PF 1.00  SR 0.00  UI 84.8%  Error 13%

Hi again,

Yea, I guess you’re right. Though I’m still confused regarding the difference of the outcomes of both the systems, I mean there’s no difference what I can see, is it?

Nice job with the three duck system. Haha you might wanna post your findings in the duck-thread… and ruin some expactations :D.

Have you also done som discretionary trading yourself?

By the way, I’m going to Norway this summer! To savalen :slight_smile:

With the change in equity curve based on what we did with WFO, it just points out that had we traded the system in the past, and done periodic optimizations, it would not have turned out so well. When you use WFO, the system is optimized periodically and run on “out of sample” data, so it is in a sense not fitted to the data in the “out of sample” set of the data.
LoL, I dont want to get into trouble with anyone, they ll talk me done and I will feel ****. Just want to stimulate some thinking by forcing people to see quick results on adjustments and drop some old held notions.
We will be waiting for you in Norway then. (Y)

Today I will be playing around with the 3 little pigs system.
The page for the system is here http://forums.babypips.com/free-forex-trading-systems/55216-3-little-pigs-trading-system-47.html


//Three Little Pigs and its variants. 
//Liftoff (R)

function run()
{
//	set(PARAMETERS);
	BarPeriod = 240; // 4 Hour bars
	StartDate = 2009;
//	EndDate =  2012;
	LookBack = 2880;
	Hedge = 0;
	
	//First Pig
	vars Price = series(price());
	vars SMAW = series(SMA(Price,1650)); // Weekly Trend (SMA 55)
	
	//Second Pig
	vars SMAD = series(SMA(Price,126));  // Daily Trend (SMA 21)
	
	//Third Duck
	vars SMA4H = series(SMA(Price,34));  // 4 Hour Trend (SMA 34)
	
	vars StopCal = series(ATR(14),14);
	var HighATR = (MaxVal(StopCal,14))/PIP;
	var LowATR =	(MinVal(StopCal,14))/PIP;
				
	Stop = (((HighATR-LowATR)*.25)+((abs(SMA4H[0]-Price[0]))))*PIP;
	Trail = (((HighATR-LowATR)*.25)+((abs(SMA4H[0]-Price[0]))))*PIP;
	
	
	if(Price[0]>SMAW[0] && Price[0]>SMAD[0] && Price[0]>SMA4H[0]){
		enterLong();
	} 
	else if(Price[0]<SMAW[0] && Price[0]<SMAD[0] && Price[0]<SMA4H[0]){
		enterShort();
	}
}

AUDUSD


ThreelittlePigs compiling...............
BackTest: ThreelittlePigs AUD/USD 2009..2014
Profit -426$  MI -11$  DD 426$  Capital 438$
Trades 2383  Win 3%  Avg -2.4p  Bars 2
AR -33%  PF 0.39  SR -4.58  UI 0.0%  Error 35%

EURUSD


ThreelittlePigs run..
BackTest: ThreelittlePigs EUR/USD 2009..2014
Profit -465$  MI -12$  DD 474$  Capital 485$
Trades 2168  Win 4%  Avg -2.8p  Bars 2
AR -32%  PF 0.33  SR -5.39  UI 0.0%  Error 36%

GBPUSD


ThreelittlePigs run..
BackTest: ThreelittlePigs GBP/USD 2009..2014
Profit -398$  MI -11$  DD 407$  Capital 427$
Trades 2130  Win 5%  Avg -2.5p  Bars 2
AR -32%  PF 0.44  SR -4.03  UI 0.0%  Error 35%

NZDUSD


ThreelittlePigs run..
BackTest: ThreelittlePigs NZD/USD 2009..2014
Profit -375$  MI -10$  DD 381$  Capital 398$
Trades 2141  Win 4%  Avg -2.3p  Bars 2
AR -32%  PF 0.39  SR -4.77  UI 3794.7%  Error 35%

USDCAD


ThreelittlePigs run..
BackTest: ThreelittlePigs USD/CAD 2009..2014
Profit -331$  MI -9$  DD 335$  Capital 343$
Trades 2124  Win 4%  Avg -2.1p  Bars 2
AR -32%  PF 0.35  SR -6.03  UI 0.0%  Error 36%

USDCHF


ThreelittlePigs run..
BackTest: ThreelittlePigs USD/CHF 2009..2014
Profit -445$  MI -12$  DD 445$  Capital 455$
Trades 2337  Win 5%  Avg -2.4p  Bars 2
AR -33%  PF 0.39  SR -4.85  UI 0.0%  Error 35%

USDJPY


ThreelittlePigs run..
BackTest: ThreelittlePigs USD/JPY 2009..2014
Profit -204$  MI -5$  DD 207$  Capital 239$
Trades 2115  Win 8%  Avg -1.3p  Bars 2
AR -32%  PF 0.69  SR -1.41  UI 5548.6%  Error 33%

USOil


ThreelittlePigs run..
BackTest: ThreelittlePigs USOil 2009..2014
Profit -4846$  MI -138$  DD 5899$  Capital 6962$
Trades 2097  Win 7%  Avg -3.0p  Bars 2
AR -27%  PF 0.70  SR -1.41  UI 404.2%  Error 34%

Gold and Silver


ThreelittlePigs run..
BackTest: ThreelittlePigs XAU/USD 2009..2014
Profit -280$  MI -9$  DD 503$  Capital 565$
Trades 1741  Win 9%  Avg -21.1p  Bars 2
AR -20%  PF 0.81  SR -0.79  UI 165.4%  Error 34%

ThreelittlePigs run..
BackTest: ThreelittlePigs XAG/USD 2009..2014
Profit -2601$  MI -103$  DD 2601$  Capital 3127$
Trades 1461  Win 6%  Avg -4.7p  Bars 2
AR -40%  PF 0.26  SR -8.27  UI 0.0%  Error 37%