Help with a script

Posted By: sabgto

Help with a script - 10/11/12 23:49

I’m just trying to understand the mechanics of “Zorro”. I took “the7 strategy” http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=408401#Post408401 and simplifying de code I have this:

function run(){
BarPeriod = 1440;
StartDate = 20120701;
NumDays = 60; // only two months in order to limit the output

var *pH = series(priceHigh());
var *pL = series(priceLow());
var *EMA5H = series(EMA(pH,5));
var *EMA5L = series(EMA(pL,5));

Stop = (HH(2) - LL(2));

if(priceOpen() > *EMA5H && priceClose() < *EMA5H && priceLow() > *EMA5L){
Entry = priceLow(0) - (5*PIP);
enterShort();
} else if(priceOpen() < *EMA5L && priceClose() > *EMA5L && priceHigh() < *EMA5H){
Entry = priceHigh(0) + (5*PIP);
enterLong();
}

plot("EMA5H", *EMA5H, 0, BLUE);
plot("EMA5L", *EMA5L, 0, BLUE);
}

When priceOpen < EMA5L and priceClose > EMA5L and priceHigh < EMA5H it should enterLong(). In the result chart I found this.



It seems to be that the condition to enterLong is satisfied however no enterLong order is executed. Could someone tell me if I have a mistake in the code or what is going on ?.

What should I do to post my code in a "code box" ?

Thanks.
Posted By: Gattaca

Re: Help with a script - 10/12/12 07:16

That's interesting. I took your script and put in some printfs for debugging, and I think too, it should trigger at this bar.

Code:
function run(){
BarPeriod = 1440;
StartDate = 20120701;
NumDays = 60; // only two months in order to limit the output
set(LOGFILE);
var *pH = series(priceHigh());
var *pL = series(priceLow());
var *EMA5H = series(EMA(pH,5));
var *EMA5L = series(EMA(pL,5));

Stop = (HH(2) - LL(2));

printf("#\n%d %d   %f %f %f  %f  %f\n",day(0),month(0),priceOpen(),priceClose(),priceHigh(),*EMA5L,*EMA5H);
if(priceOpen() > *EMA5H && priceClose() < *EMA5H && priceLow() > *EMA5L){
printf("#\n %s" ,"EnterShort");
Entry = priceLow(0) - (5*PIP);

enterShort();
}
 if((priceOpen() < *EMA5L) && (priceClose() > *EMA5L) && (priceHigh() < *EMA5H)){
printf("#\n %s ","EnterLong");
Entry = priceHigh(0) + (5*PIP);

enterLong();
}

plot("EMA5H", *EMA5H, 0, BLUE);
plot("EMA5L", *EMA5L, 0, BLUE);
}

Posted By: jcl

Re: Help with a script - 10/12/12 11:04

July 14 was a saturday. The FXCM simulation does not accept trades on weekends, so no trade was executed.

Add the line

g->nWeekend = 0;

for executing trades also on weekends.

BTW, for a code box click on "Switch to full reply screen", then you have all the format options.
Posted By: sabgto

Re: Help with a script - 10/12/12 16:02

Thanks for your fast answer. No trades on weekand is fine. Congratulations JCL I think Zorro is a very very good job.
© 2024 lite-C Forums