Hey guys,
I am using one EA to open trades and the other EA to close trades. The problem is: if the order is opened and closed on the same bar, I dont want the EA to open it again on the same bar even if the same condition is met.
Could help me by telling how it could be done?
Thanks
Create a variable with global scope
datetime LastBar = 0;
Run this at the start of OnTick()
if(LastBar == Time[0]) { return; } LastBar = Time[0];
Create a variable with global scope
datetime LastBar = 0;
Run this at the start of OnTick()
if(LastBar == Time[0]) { return(rates_total); } LastBar = Time[0];
OnTick is a void function, so a value is not returned
rates_total is only used in indicators as far as I know
and is meaningless in an EA
Quite right - my apologies. Didn't really give it much thought as I typed it out.
Replace return(rates_total) with return.
Edited above post.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey guys,
I am using one EA to open trades and the other EA to close trades. The problem is: if the order is opened and closed on the same bar, I dont want the EA to open it again on the same bar even if the same condition is met.
Could help me by telling how it could be done?
Thanks