I'm fairly new at the MQL5 language and I've got a problem I can't find a solution to.
I've got a couple of promising strategies but when things are a bit volatile I can enter a position that gets closed out rapidly and then re-enters again on the same bar. This sometimes happens two or three times during a bar. Regularly the first trade is profitable but the subsequent ones are almost invariably loosing ones.
What I need is a bit of code that will stop the platform from opening a position on a bar that has already had a position opened and closed on it but then leaves it free to trade on subsequent bars.
I imagine it should be relatively simple to do but I haven't had enough experience to work it out
If anyone could point me to some code that would do the trick or give me some suggestions as to how to achieve it I'd be most grateful.
use flag i think ..
set this at global variable
inside function (example)
//your code here to send orders
then set the reset flag conditions inside any of event, can be onTick or start or chartEvent or else (example only)
Thanks for the replies. While neither were exactly what I needed they both pointed me in the direction I needed to go to solve the problem and it's now working fine.