Hi there, I am new on MQL4 coding (and any coding) and I wrote this EA, it is not doing wrong, but, when it losses a trade, sometimes the parameters still fit and it would open another order right away and lose like 3 trades in a row. Is there a code that will make the EA to Stop Trading for X ammount of time if a SL is hit? Thanks in advance for your help!
You could save the OrderCloseTime() of the SL trade in a datetime variable and add x minutes to the variable. (Look into OrderSelect for this)
Then, only trade if TimeCurrent() > DoTradeTime. That might work...;)
DoTradeTime=OrderCloseTime()+3600; // one hour // // ok to trade? If(TimeCurrent()>DoTradeTime) return true; else return false;
Alternatively, your code can search OrderHistory, and determine the time of the last order, and do something similar. I try to avoid saving values to variables, to use, say an hour later, so I would probably use OrderHistory method.
You could save the OrderCloseTime() of the SL trade in a datetime variable and add x minutes to the variable. (Look into OrderSelect for this)
Then, only trade if TimeCurrent() > DoTradeTime. That might work...;)
Alternatively, your code can search OrderHistory, and determine the time of the last order, and do something similar. I try to avoid saving values to variables, to use, say an hour later, so I would probably use OrderHistory method.
I was thinking of maybe a way of making it so if a trade losses more than 1% of the account balance, stop trading for 6 hours, something like that, but i am not sure as of how to put that in code 🤔
It's about thinking what you want to achieve and how you might go about doing it, I guess. What information do you need, and how do you get it?
If you type Order into MQL4 reference, you'll see more than a dozen built in functions to deal with Order values....

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there, I am new on MQL4 coding (and any coding) and I wrote this EA, it is not doing wrong, but, when it losses a trade, sometimes the parameters still fit and it would open another order right away and lose like 3 trades in a row. Is there a code that will make the EA to Stop Trading for X ammount of time if a SL is hit? Thanks in advance for your help!