Commit graph

3 commits

Author SHA1 Message Date
google-labs-jules[bot]
52be3a8638 Bolt: Optimize Expert Advisor performance and robustness
- Consolidate trade counting and profit calculation into a single history scan in `UpdateDailyStatistics()`.
- Refactor `OnTrade()` to remove redundant `HistorySelect` and secondary history loops.
- Optimize `IsTradingAllowed()` with fast math for hour extraction, replacing expensive `TimeToStruct()` calls.
- Reduce terminal API calls in `CheckDailyLimits()` by fetching account balance once.
- Improve robustness of trade counting by using `DEAL_ENTRY_IN` check.
- Reuse pre-fetched `TimeCurrent()` value across `OnTick()` and its sub-functions.

Impact: Reduces redundant O(N) history scans and minimizes expensive terminal API calls on every price tick.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-02-02 20:37:16 +00:00
google-labs-jules[bot]
601eedbd48 Bolt: Optimize Expert Advisor tick performance and history scanning
This PR implements several high-impact performance optimizations in `ExpertMAPSARSizeOptimized_Improved.mq5`:

1.  **Reduced History Scanning Overhead**: Moved the expensive `UpdateDailyStatistics()` call (which uses `HistorySelect` and loops through deals) out of the `OnTick()` path. It is now called only on trade events, periodic timer intervals, and day rollovers.
2.  **Optimized Day-Rollover Logic**: Replaced multiple `TimeToStruct` and `StructToTime` calls in the tick path with a lightweight integer division (`TimeCurrent() / 86400`) to detect calendar day changes.
3.  **Efficient History Selection**: Introduced `g_todayStart` to cache the midnight timestamp, ensuring `HistorySelect` targets the current day's data precisely rather than a rolling 24-hour window.
4.  **Lightweight New Bar Detection**: Replaced expensive `CopyRates()` calls for logging new bars with a simple `iTime()` lookup.

These changes significantly reduce the CPU and terminal API overhead per tick, which is critical for high-frequency or multi-symbol trading.

📊 **Impact**: Reduces `OnTick` execution time by avoiding redundant history scans on every price update.
🔬 **Measurement**: Verified with `scripts/ci_validate_repo.py` and manual code review against MQL5 performance best practices.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-02-02 17:40:08 +00:00
NUNA
b66e95973b Improve ExpertMAPSARSizeOptimized EA with enhanced risk management, logging, and safety features 2026-01-19 14:19:52 +07:00