Gamestudio Links
Zorro Links
Newest Posts
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
folder management functions
by 7th_zorro. 04/15/24 10:10
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
LPDIRECT3DCUBETEXTUR
E9

by Ayumi. 04/12/24 11:00
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 04/11/24 14:56
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
6 registered members (ricky_k, Nymphodora, rki, 7th_zorro, Volkovstudio, Aku_Aku), 373 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
11honza11, ccorrea, sakolin, rajesh7827, juergen_wue
19045 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Huck's trend catcher #407043
09/05/12 12:08
09/05/12 12:08
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
This simple strategy was suggested on another forum:

Code:
function run()
{
	var *Price = series(price());
	var *LP5 = series(LowPass(Price,5));
	var *LP10 = series(LowPass(Price,10));
	var *RSI10 = series(RSI(Price,10));

	Stop = 50*PIP;
	
	if(crossOver(LP5,LP10) && crossOver(RSI10,50))
		enterLong();
	else if(crossUnder(LP5,LP10) && crossUnder(RSI10,50))
		enterShort();
}



The equity curve:



Feel free to improve...

Re: Huck's trend catcher [Re: jcl] #407082
09/05/12 20:24
09/05/12 20:24
Joined: Feb 2012
Posts: 37
S
stevegee58 Offline
Newbie
stevegee58  Offline
Newbie
S

Joined: Feb 2012
Posts: 37
I found your posts about this on the other forum. It's interesting how using a low pass filter instead of an MA worked better. A moving average is really just a low pass filter anyway...

Re: Huck's trend catcher [Re: stevegee58] #407084
09/06/12 06:58
09/06/12 06:58
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
An EMA is a 1-pole lowpass filter; the LowPass function is a 2-pole filter. A 2-pole filter has constant amplification - and thus zero lag - below the filter frequency. That's why it works better. EMA lags at any frequency.

Re: Huck's trend catcher [Re: jcl] #407805
09/19/12 15:02
09/19/12 15:02

L
liftoff
Unregistered
liftoff
Unregistered
L



You didn't post the optimized script? I believe that one is more profitable.

Re: Huck's trend catcher [Re: ] #407857
09/20/12 08:51
09/20/12 08:51
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Yes, that's the optimized version with 3x higher profit:

Code:
function run()
{
	BarPeriod = 240;
	StartDate = 2006;
	NumYears = 7;
	NumWFOCycles = 12;
	set(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);
	int Delay = 3; 
	
	static int crossed = 0;
	if(crossOver(LP5,LP10))
		crossed = Delay;
	else if(crossUnder(LP5,LP10))
		crossed = -Delay;
		
	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:


Last edited by jcl; 09/24/12 14:38.
Re: Huck's trend catcher [Re: jcl] #407965
09/22/12 10:47
09/22/12 10:47

L
liftoff
Unregistered
liftoff
Unregistered
L



Did a little playing around with the script.
Code:
// Huck Trend Catcher
function HTCS()
{
	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(strstr(Algo,":L") and crossed > 0 && crossOver(RSI10,50))
	{ 
	enterLong();
	 crossed = 0;
	}
	else if(strstr(Algo,":S") and crossed < 0 && crossUnder(RSI10,50))
	{
	enterShort(); crossed = 0;
	}
	else crossed -= sign(crossed);
} 
function run()
{
	Mode = PARAMETERS+TESTNOW+FACTORS;
	BarPeriod = 240;
	StartDate = 2006;
	NumYears = 7;
	NumWFOCycles = 12;
	
	
	if(ReTrain) {
		SelectWFO = -1;
		UpdateDays = 30;
	}
	
//Asset Classes	
while(asset(loop("EUR/USD","USD/CHF","AUD/USD","USD/JPY","GBP/USD","USD/CAD","NZD/USD","AUD/JPY","")))

while (algo(loop(":L",":S")))
{
	if(Train)
	Lots=1;
	else if(strstr(Algo,":L") and OptimalFLong > 0)
	{
	Lots=1;
	Margin = clamp((WinLong-LossLong) * OptimalFLong/2,50,1000);
   }
   else if(strstr(Algo,":S") and OptimalFShort > 0)
   {
   Lots=1;
   Margin = clamp((WinShort-LossShort) * OptimalFShort/2,50,10000);
   }
	else
	Lots=0;
	
	HTCS();
}
}



I know I did something wrong somewhere because the equity curve doesn't look so pretty


Last edited by liftoff; 09/22/12 11:04.
Re: Huck's trend catcher [Re: ] #408053
09/24/12 13:12
09/24/12 13:12
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
Hi jcl,

Been following your thread on babypips and learning your lessons on programming c for backtesting. Thanks for the great work your doing I appreciate it.

I have one question in regards to your code you posted above:

Quote:


function run()
{
BarPeriod = 240;
StartDate = 2006;
NumYears = 7;
NumWFOCycles = 12;
set(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 = Delay;
else if(crossUnder(LP5,LP10))
crossed = -Delay;

if(crossed > 0 && crossOver(RSI10,50)) {
enterLong();
crossed = 0;
} else if(crossed < 0 && crossUnder(RSI10,50)) {
enterShort();
crossed = 0;
} else
crossed -= sign(crossed);
}



The 'Delay' variable is not defined and wont work in Zorro, I understand that it needs to be identified just having a little trouble working out what needs to be done here to rectify your code to acheive that optimised result you posted.

Regards
TankWolf

Edit: Looking over this again and reading what the crossOver and crossUnder functions do is it correct that delay shouldnt actually be there and it should be 1 or -1 because the next part of the code looks to go long if crossed is > 0 since the crossOver function looks if data1 crosses over data2 so then if it does it should assign crossed = 1?

Last edited by TankWolf; 09/24/12 13:25.
Re: Huck's trend catcher [Re: TankWolf] #408055
09/24/12 14:42
09/24/12 14:42
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
I indeed forgot the Delay in the code:

int Delay = 3;

The variable "crossed" is set to 3 or -3, then counted down or up until it's 0. This has the purpose that the signal stays valid until 3 bars after the crossover.

The "static" keyword is important here, as it keeps the content of the "crossed" variable when the function is left. Otherwise, crossed could not be used as a counter because it would be set to 0 every time the run() function is called.

This is a programming trick that was not mentioned in the course. It's however described in the "Variables" chapter of the manual.

Re: Huck's trend catcher [Re: jcl] #408092
09/25/12 07:56
09/25/12 07:56
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
I understand what you are saying about making the int static so it keeps its variable when the function is left, what I dont understand is how the "crossed" variable is counted down or up to 0 from -3,3.

Quote:
static int crossed = 0;
int Delay = 3;
if(crossOver(LP5,LP10))
crossed = Delay;
else if(crossUnder(LP5,LP10))
crossed = -Delay;

if(crossed > 0 && crossOver(RSI10,50)) {
enterLong();
crossed = 0;


The way I read that code is that crossed would become either 3 or -3 after completing the first if/else statement then the next part of the code looks to see if crossed is greater than 0 and the RSI has crossOver 50 from below. If crossed is greater ie (3) the algo goes long. Where does the count down actually take place? Shouldnt there be a loop statement somewhere to count the crossed variable down or up to 0?

Regards
TankWolf

Last edited by TankWolf; 09/25/12 08:58.
Re: Huck's trend catcher [Re: TankWolf] #408097
09/25/12 09:32
09/25/12 09:32
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
It happens here:

crossed -= sign(crossed);

If a trade takes place, crosses is immediately set to 0 for not triggering a trade again. Otherwise, its sign is subtracted, which means that its absolute value is reduced by 1. The sign is -1 or 1 dependent on whether the number is negative or positive.

Re: Huck's trend catcher [Re: jcl] #408772
10/07/12 04:14
10/07/12 04:14
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
I found another trending system funnily enough called Huck Loves Her Bucks which can be seen here on babypips. http://forums.babypips.com/free-forex-trading-systems/39293-huck-loves-her-bucks-system.html

I have used all of the rules except for the profit & stop rules posted. I tried to incorporate them but when I did it made the results worse. This could of been however because of my poor coding. Anyway here is the code & results if anyone wants to play with it further without the profit & stop rules.

Quote:

function run()
{
BarPeriod = 240;
StartDate = 2006;
NumYears = 7;
NumWFOCycles = 12;
set(PARAMETERS|TESTNOW);

asset("EUR/USD");

var *Price = series(priceClose());
var *EMA10 = series(EMA(Price,optimize(10,5,20)));
var *EMA20 = series(EMA(Price,optimize(20,10,40)));
var Stoch50 = Stoch(optimize(14,10,20),optimize(3,1,5),MAType_SMA,optimize(3,1,5),MAType_SMA);

static int crossed = 0;
int Delay = optimize(3,1,5);
if(crossOver(EMA10,EMA20))
crossed = Delay;
else if(crossUnder(EMA10,EMA20))
crossed = -Delay;

if(crossed > 0 && Stoch50 > 50 && Stoch50 < 80) {
enterLong();
crossed = 0;
} else if(crossed < 0 && Stoch50 < 50 && Stoch50 > 20) {
enterShort();
crossed = 0;
} else
crossed -= sign(crossed);
}


Quote:

Annual return 147%
Profit factor 2.37 (PRR 1.85)
Sharpe ratio 1.34
Kelly criterion 1.21
OptimalF .068
Ulcer index 5%
Prediction error 39%

Re: Huck's trend catcher [Re: jcl] #465749
05/11/17 05:33
05/11/17 05:33
Joined: Feb 2017
Posts: 369
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
Originally Posted By: jcl
Yes, that's the optimized version with 3x higher profit:

Code:
function run()
{
	BarPeriod = 240;
	StartDate = 2006;
	NumYears = 7;
	NumWFOCycles = 12;
	set(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);
	int Delay = 3; 
	
	static int crossed = 0;
	if(crossOver(LP5,LP10))
		crossed = Delay;
	else if(crossUnder(LP5,LP10))
		crossed = -Delay;
		
	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:



Sorry for waking up an old thread, but I wanted to see if I could reproduce these results. I'm running with Zorro 1.58, I've copy pasted the code above, and I'm not seeing anywhere near the same equity curve.


Attached Files
Zorro.png (230 downloads)
Last edited by Dalla; 05/11/17 05:33.
Re: Huck's trend catcher [Re: jcl] #465759
05/11/17 09:41
05/11/17 09:41
Joined: May 2017
Posts: 19
P
PeWi Offline
Newbie
PeWi  Offline
Newbie
P

Joined: May 2017
Posts: 19
Hi to all,

I am currently trying the first steps with Zorro after reading the book of jcl.

I copied the optimized script from jcl, started training and testing.

The result I got is about a tenth of jcl (about 1.6k instead of 16k).

What am I doing wrong? I use the free Zorro 1.54 and a demo account of fxcm.

Help or hints would be greatly appreciated ...
Kind regards, Peter

Re: Huck's trend catcher [Re: PeWi] #465760
05/11/17 10:29
05/11/17 10:29
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Hi Pewi - since the English book version comes out soon, I've tested 2 weeks ago all the scripts with the latest Zorro version 1.58. You should get the same results as in the book, with some differences due to different trading costs.

Make sure you have Zorro version 1.58 and also the latest book scripts from the financial hacker website - a few things have been changed in the scripts.

Re: Huck's trend catcher [Re: jcl] #465761
05/11/17 11:11
05/11/17 11:11
Joined: Feb 2017
Posts: 369
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
Not sure what you mean now, I cannot find anything resembling this strategy in among the book scripts? (assuming you mean http://financial-hacker.com/boersenhackerbuch.zip)

Re: Huck's trend catcher [Re: Dalla] #465769
05/11/17 16:17
05/11/17 16:17
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
@Dalla, I did not mean you, but it's the same in your case: Differences are usuaally caused by either different test periods, or by different trading costs. You can see that the curves are somewhat similar, only the profit is lower. I suppose that the result back in 2012 was based on no commission. Also the test periods look different and the default test/training split was probably different in that early version.

Re: Huck's trend catcher [Re: jcl] #465772
05/11/17 17:07
05/11/17 17:07
Joined: May 2017
Posts: 19
P
PeWi Offline
Newbie
PeWi  Offline
Newbie
P

Joined: May 2017
Posts: 19
Hello jcl,

thanks for your quick reply. I will try with Zorro 1.58.

I am a little bit surprised that a relative short script like your optimized version of Huck's trend catcher depends so much of the Zorro version?

Also thanks for the tip with the updated book coming soon. Is there a german version planned also? I am not so familiar with english nor with such statistics nor with the special trading stuff that I am happy if at least the language barrier misses ...

BTW: Are there enough members for a german speaking sub forum?

Kind regards, Peter

Re: Huck's trend catcher [Re: PeWi] #465773
05/11/17 17:33
05/11/17 17:33
Joined: Feb 2017
Posts: 369
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
The german book has been around for some time I think
http://www.amazon.de/Das-B%C3%B6rsenhackerbuch-Finanziell-algorithmische-Handelssysteme/dp/1530310784

Re: Huck's trend catcher [Re: Dalla] #465774
05/11/17 18:08
05/11/17 18:08
Joined: May 2017
Posts: 19
P
PeWi Offline
Newbie
PeWi  Offline
Newbie
P

Joined: May 2017
Posts: 19
Hello Dalla,

by chance I stumbled over the current german version some weeks ago and started to get interested by forex, algorithmic trading and zorro.

Kind regards, Peter

Re: Huck's trend catcher [Re: jcl] #465775
05/11/17 18:47
05/11/17 18:47
Joined: May 2017
Posts: 19
P
PeWi Offline
Newbie
PeWi  Offline
Newbie
P

Joined: May 2017
Posts: 19
Hi jcl,

also with 1.58 I get for Huck's trend catcher and your optimized script only a result of 1.6k and not 16k as you (FXCM demo account). How can such a big difference happen?

Kind regards, Peter

Re: Huck's trend catcher [Re: PeWi] #465778
05/12/17 06:54
05/12/17 06:54
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline OP

Chief Engineer
jcl  Offline OP

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
I don't know, but aside from the other mentioned reasons, a 10 times smaller balance usually results from a 10 times smaller investment. I guess FXCM introduced micro accounts somewhat after 2012.

Re: Huck's trend catcher [Re: jcl] #465929
05/18/17 06:29
05/18/17 06:29
Joined: May 2017
Posts: 19
P
PeWi Offline
Newbie
PeWi  Offline
Newbie
P

Joined: May 2017
Posts: 19
Thanks again for helping; one more of a long chain of failures of a Zorro starter ;-)

Peter

Last edited by PeWi; 05/18/17 06:31.
Page 1 of 3 1 2 3

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1