only 1 entry per day

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
raven
Posts: 31
Joined: 17 Oct 2009
Been thanked: 1 time

only 1 entry per day

Postby raven » 12 Nov 2009

When trading on 5 minute bars on a multi-day chart (=day after day is charted on a 5 minute base), how to manage it that only 1 entry per day is made if condition for entry is met? (Problem: conditions are met several times a day but only the first match should be traded.)

Does anybody know? Many thanks in advance.

User avatar
TJ
Posts: 6585
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 971 times
Been thanked: 1907 times

Postby TJ » 12 Nov 2009

just add a counter to the code.

if an order is filled... counter = 1.

if counter is larger than zero, then don't trade anymore.



the above is called pseudo code...
it is plain English... written in semi computer logic.
writing out your thoughts this way will help you to
organize your thoughts into programming codes.

raven
Posts: 31
Joined: 17 Oct 2009
Been thanked: 1 time

Postby raven » 12 Nov 2009

That's a good idea, but to use it on a chart with more than one day with 5 minute bars (as described above) I would have to reset the counter at the end of each day. Otherwise trading would stop after the first trade for all following days. This is a matter especially when backtesting.

Thanks for any suggestion.

User avatar
TJ
Posts: 6585
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 971 times
Been thanked: 1907 times

Postby TJ » 12 Nov 2009

you have the right idea...

you just have to reset the counter everyday !!!


QED

brodnicki steven
Posts: 407
Joined: 01 Jan 2008
Been thanked: 3 times

Postby brodnicki steven » 12 Nov 2009

I'm not a great EL programmer but to reset the counter, I think you could do something simple like-

if date <> date[1] then counter = 0;

Maybe someone else could supply an example of the counter code, to help him out. We're not all programmers here, most are traders, learning to program.

raven
Posts: 31
Joined: 17 Oct 2009
Been thanked: 1 time

Postby raven » 12 Nov 2009

Special thanks to steven for the code. Here is my way (and it works):

variable: counter(0);

condition1 = marketposition <> 0;
if condition1 then counter = counter + 1;
if time this bar = 1000 then counter = 0;

"time this bar" is the time when I want to reset the counter.


Return to “User Contributed Studies and Indicator Library”