Order executed in the middle of the bar and not at the beginning or at the end of the bar after restarting MT4…
5 replies
Karish
7 years ago #115240
HIi, i got a problem..
The EA is working fine by the rules and opens and close orders on bar open/close,
but when lets say i restart my MT4 platform when it opens again and the rules are met, it will open an order immediately at the middle of the bar without waiting for a new formatted bar..
how do i stop it for happening please?, i want the EA to wait for a new formatted bar and then enter the order (like it should) and not on the first tick when restarting the MT4 platform or so..
thanks..
Karish
7 years ago #137719
that happens to me when i’m using offline charts.., maybe something to do with “sqIsBarOpen” under the “drawStats()” function?…, please help ASAP…, because when i’m im reopening MT4 platform with an EA that works on OFFLINE charts it will just open a new position as soon as the first tick comes in, and wont wait till the new bar opens….,
waiting for some help…!, thank you!…
Karish
7 years ago #137740
Anybody………….?
tomas262
7 years ago #137759
hello,
it seems to me that EA/chart load event causes isBarOpen to be true within DrawStats function. That is why the action is triggered. I will ask Mark to check it
Karish
7 years ago #137775
hello,
it seems to me that EA/chart load event causes isBarOpen to be true within DrawStats function. That is why the action is triggered. I will ask Mark to check it
Thanks thomas, i would love to hear how can i fix that issue ASAP please..!\
thanks again i will wait for an answer..!
Mark Fric
7 years ago #137989
Karish, I looked at it and yes, this is how it works. When you start your EA in the middle of the bar it can open the order immediately, it doesn’t wait for start of a new bar.
The recognition of new bar open checks if it is a first tick of the current bar, which it is when you just started EA in the middle of the bar.
It is actually quite difficult to make it work only for the new open bars and not for the first bar you start your EA with.
It should possible by changing the MQL code a little – find a function drawStats() where the variable sqIsBarOpen is set.
Change the condition like this:
Mark
StrategyQuant architect
Viewing 5 replies - 1 through 5 (of 5 total)