MQL5-Google-Onedrive/mt5/MQL5
google-labs-jules[bot] 315e26d24c Bolt: Optimize MQL5 Expert Advisor performance
This commit implements several performance optimizations for the `ExpertMAPSARSizeOptimized_Improved.mq5` Expert Advisor:

1.  **OnTick Gatekeeper Optimization**: Added an early-exit 'new bar' check using the lightweight `iTime()` function at the very beginning of `OnTick`. This prevents expensive terminal API calls and logic from executing on every price tick when not required (when `Expert_EveryTick` is false).
2.  **Event-Driven Statistics**: Relocated the expensive `UpdateDailyStatistics()` call, which performs history scanning, from the high-frequency `OnTick` path to the event-driven `OnTrade()` handler and a periodic `OnTimer()` handler (60 seconds).
3.  **Startup Initialization**: Added an initial call to `UpdateDailyStatistics()` in `OnInit()` to ensure accurate statistics upon EA startup.
4.  **Timer Management**: Enabled `EventSetTimer(60)` in `OnInit()` and added proper cleanup with `EventKillTimer()` in `OnDeinit()`.
5.  **Efficient History Selection**: Refactored `UpdateDailyStatistics()` to use a specifically calculated `todayStart` timestamp for `HistorySelect()`, reducing terminal data retrieval overhead compared to the previous rolling 24-hour window.
6.  **Redundancy Removal**: Removed an expensive and redundant `CopyRates()` call used for bar time tracking at the end of `OnTick()`.

These changes significantly reduce CPU usage and terminal overhead, especially during high-volatility market conditions with rapid tick streams.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-02-02 11:00:25 +00:00
..
Experts Bolt: Optimize MQL5 Expert Advisor performance 2026-02-02 11:00:25 +00:00
Indicators Bolt: optimize indicator OnCalculate performance (revised) 2026-01-31 10:52:36 +00:00