1 registered members (AndrewAMD),
1,268
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Huck's trend catcher
[Re: jcl]
#407805
09/19/12 15:02
09/19/12 15:02
|
liftoff
Unregistered
|
liftoff
Unregistered
|
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,986 Frankfurt
jcl
OP
Chief Engineer
|
OP
Chief Engineer
Joined: Jul 2000
Posts: 27,986
Frankfurt
|
Yes, that's the optimized version with 3x higher profit:
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
|
liftoff
Unregistered
|
liftoff
Unregistered
|
Did a little playing around with the script.
// 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
TankWolf
Junior Member
|
Junior Member
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:
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: jcl]
#408092
09/25/12 07:56
09/25/12 07:56
|
Joined: Sep 2012
Posts: 99
TankWolf
Junior Member
|
Junior Member
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. 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.
|
|
|
|