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