System´"jumps over" trades

Posted By: beerz

System´"jumps over" trades - 01/27/13 07:59

Hi,

So, ive been playing around with different types of script in purpose to get mor exeperienced in programming. Right now, im doing this following script when I saw a problem occured:

function run ()


{

StartDate = 20110601;
EndDate = 20130120;
BarPeriod = 1440;

Stop = 50*PIP;
Trail = 40*PIP;
TrailLock = 1;


vars day_low = series(priceLow());
vars day_high = series(priceHigh());
vars day_close = series(priceClose());
vars EMA50 = series(EMA(day_close, 50));




if (day_close[0] < day_low[1] && day_close[0] < EMA50[1])
enterShort();


plot ("EMA50", EMA50[0], 0, RED);

}

It looks like it "jumps over" some trades, where (as i can see) it should've executed a trade since all conditions where true. Look at following link where I marked to see what I mean. http://postimage.org/image/kp13ttrmz/

Can someone explain why this is happening?

Thanks

Beerz
Posted By: Petra

Re: System´"jumps over" trades - 01/27/13 12:31

Weekend, probably?
Posted By: jcl

Re: System´"jumps over" trades - 01/28/13 10:18

It happens often that a trade does not execute as you expect - either due to a bug in your code, or because trading is not allowed due to weekend or other reasons. Your code, as far as I see, is ok.

You can often quickly find the reason when you activate LOGFILE, and/or use the printf function so that you see if you attempted to open a position on a Saturday, or if the if(..) condition was true or not.
Posted By: TankWolf

Re: System´"jumps over" trades - 01/28/13 11:26

Maybe due to lack of a long enough lookback period thats been the cause of problem trades for me before. Not only that but your code compares EMA(1) which is the value for yesterday's EMA and won't be the exact value as shown on your plot line I don't believe. Check your printf values as Jcl says to be sure though.
© 2024 lite-C Forums