Bad_Bond: It works only for the first order. Tehn, he close order while wait the cooldown...
for(int b=1; b>=OrdersTotal(); b++)
- That is an infinite loop (you meant <=)
- The if is unnecessary, no open orders the for does nothing.
- Get in the habit of counting down always. Loops and Closing or Deleting Orders - MQL4 forum
- Your OrderSelect loop means the EA is incompatible with every other, including itself on other charts and manual trading. https://www.mql5.com/en/forum/145507
if(OrderSelect(b-1, SELECT_BY_POS)==true)
You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So Don't write if(bool == true), just use if(bool) or if(!bool). Reading the code out loud becomes "if order is selected is true" You would never say the "is true" part. Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled.if (TimeCurrent() >= (OrderOpenTime()+4500000))
When the order closes your for loop does nothing, so there is no "cooldown." You must remember that before the order closes.static datetime cooldown=0; if(TimeCurrent() < cooldown) return; for(int b=OrdersTotal() - 1; b>=0; --b) if(OrderSelect(b, SELECT_BY_POS) && and my magic number && and my pair ){ #define DAYS52 4500000 // What you wrote #define HOUR1 (PERIOD_H1 * 60) // What you meant "one hour (by exemple)" if (cooldown < OrderOpenTime()+DAYS52) cooldown = OrderOpenTime()+DAYS52; }
thanks a lot
I don't understand why there is no more cooldown...
and why, one year ago, my ea didn't make this error...

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Yo,
I want to take order one by one. I mean when one order is open, he can't open an other while the other is still open.
And i don't want that he can close an order until a few time has spent between the order open time and one hour (by exemple)
So i wrote a code and It seems It works only for the first order. Tehn, he close order while wait the cooldown...
Where i'm wrong ?
Here's my code :