Time filter blocks operation
-
Hi
Wanted to know how time filters blocks were working precisely, in particular the "every 'n' bars" one. Because i see that every time, when i use it interferes with my trades not the way i want.
For exemple, the simplest one : https://fxdreema.com/shared/U4lE5nbub
The first construction is gonna buy every time MA5x>MA20
The second one, only time to time even if the last buy order is older than 10 bars

Looks like it's passing to the last blocks with only 1 chance on 10 when there is a cross..
Thanks answering my rookie question -
@seb-0 You are thinking that "every n bars" counts some bars, and after the bars, always passes. That is not the case.
If n=5, then
bar 1 PASS
bar 2 NOT
bar 3 NOT
bar 4 NOT
bar 5 NOT
bar 6 PASS
bar 7 NOT
bar 8 NOT
etc...So you will only get a trade if the PASS happens same time as MA cross.

-
@roar
Alright so when there is a cross, there is 1 chance on 5(oops not 10) that it passes. That's weird cause if you have no chance you can have no trade at all. I guess it's dedicated to work with lasting conditions like "MA5>MA20".
I wanted to be sure before using more complicated structures like loops : once ber bar; pass 'n' times ; turn on a flag. Or the on timer event with loops as well but based on seconds then. It takes more time
-
@seb-0 Yeah it surely takes some time and lots of testing. It's not that bad after all - failed backtest doesn't cost very much real money, lol.
Using a variable would be most efficient in this case. Just make a variable barcount increase +1 on every bar, and set it to zero when opening a trade. Now you can just check condition: barcount > 5
https://fxdreema.com/shared/3dIyLzxCc
This example trades the cross with minimum 5 bars interval. See how I modified the variable inside the regular blocks. -
@roar
Yes fortunately. Better the EA to be as much as you want it to working, before using it on real account.
The way you did it is quicker to build than mine, thanks for the exemple ^^
I hope this topic is gona help other newbies, ill try to stop opening new ones for a moment, you guys must be busy!