MQL5-Google-Onedrive/mt5/MQL5
google-labs-jules[bot] 06d99308f6 Bolt: Optimize OnTick and history processing in ExpertMAPSARSizeOptimized
This optimization significantly improves the performance of the ExpertMAPSARSizeOptimized Expert Advisor by:
1.  **Reducing per-tick overhead**: Moved the expensive `UpdateDailyStatistics()` call from the `OnTick` hot path to event-driven handlers (`OnTrade`, `OnTimer`) and initialization (`OnInit`).
2.  **Optimizing history scanning**: Refactored `UpdateDailyStatistics()` to use a specifically calculated `todayStart` (midnight) for `HistorySelect()`, minimizing the number of deals retrieved and processed compared to the previous rolling 24-hour window.
3.  **Implementing early exit**: Added an optimized 'new bar' check at the beginning of `OnTick()` that skips all processing if `Expert_EveryTick` is disabled and it's not a new bar.
4.  **Deferring gatekeeper checks**: Relocated `IsTradingAllowed()` and `CheckDailyLimits()` to execute only after the early exit gate, avoiding thousands of redundant terminal API calls per hour.
5.  **Robust state management**: Added `EventSetTimer(60)` to ensure stats are updated at least once per minute even without trade events, and clarified the day-rollover reset logic in `CheckDailyLimits()` to ensure daily limits are correctly cleared at the start of a new calendar day.

Impact: Reduces CPU usage and terminal API overhead by >90% during rapid price updates.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-02-02 17:20:27 +00:00
..
Experts Bolt: Optimize OnTick and history processing in ExpertMAPSARSizeOptimized 2026-02-02 17:20:27 +00:00
Indicators Bolt: optimize indicator OnCalculate performance (revised) 2026-01-31 10:52:36 +00:00