mirror of
https://github.com/A6-9V/MQL5-Google-Onedrive.git
synced 2026-04-11 13:20:57 +00:00
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> |
||
|---|---|---|
| .. | ||
| bolt.md | ||
| deploy.yml | ||