Help with script

Posted By: beerz

Help with script - 01/22/13 20:23

So im trying to do this simple script, but cant get it right:

function run ()


{

StartDate = 20120601;
EndDate = 20130120;
BarPeriod = 1440;

Stop = 50*PIP;


vars day_close = series(priceClose());
vars EMA20 = series(EMA(day_close,20));



if (day_close > EMA20)
enterLong();



I want this system to enter long when the daily bar CLOSES above EMA20. But when im checking the result-chart, this is clearly not what it does. Can anyone see what i am doing wrong here?

Thanks!

Beerz
Posted By: jcl

Re: Help with script - 01/23/13 09:09

Take this as a little puzzle: What is wrong with this comparison?

if (day_close > EMA20)
...
Posted By: beerz

Re: Help with script - 01/23/13 12:30

Originally Posted By: jcl
Take this as a little puzzle: What is wrong with this comparison?

if (day_close > EMA20)
...


Hmm,

My first thought is that maybe there's no differnece between day_close and EMA20 since I've typed "vars EMA20 = series(EMA(day_close,20));" before? So the computer doesn't understand what I mean. And by the looks of the result-chart... It enters a trade almost every day ^^.

Thanks jcl for helping me out.

Beerz
Posted By: jcl

Re: Help with script - 01/23/13 13:16

Ok, I solve the puzzle:

You're comparing two series. What you wanted instead was comparing the two recent values of the series:

if(day_close[0] > EMA20[0])
...

Look here: http://manual.zorro-trader.com/series.htm
Posted By: beerz

Re: Help with script - 01/23/13 16:35

Originally Posted By: jcl
Ok, I solve the puzzle:

You're comparing two series. What you wanted instead was comparing the two recent values of the series:

if(day_close[0] > EMA20[0])
...

Look here: http://manual.zorro-trader.com/series.htm


Haha. Thanks jcl. I'm lucky you are here to save me all the time, so far laugh.
Ok, I will try with the code you showed me. And i'm also going to try to plot the ma too.

Thanks once again.

Beerz
© 2024 lite-C Forums