Where do you ever set lastDay? If an interrupt occurs, suspending execution, the second TC call could be one greater, resulting in today being lastDay minus one. | static datetime lastDay = 0; datetime today = TimeCurrent() - (TimeCurrent() % 86400); if (today > lastDay) { |
Where do you ever set TotalDailyProfit? If TDP exceeds your target, you return, never closing any trades. | if (TotalDailyProfit >= DailyProfitTarget || isCooldownPeriod) { return; } |
After all trades are closed (you call CloseTrades), you open a new trade. Therefor, there can be no “cool down.” | if (AnalyzeMarket()) { Print("Bullish signal detected. Opening BUY trade."); OpenTrade(ORDER_TYPE_BUY); } else { Print("Bearish signal detected. Opening SELL trade."); OpenTrade(ORDER_TYPE_SELL); } |

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
Hello, I am working on an MQL5 trading bot, but I have an issue with the cooldown period. Right now, my bot activates cooldown immediately after opening a trade instead of waiting for the trade to close.
Here is my OnTick() function:
this is my close trade function;