Commit graph

4 commits

Author SHA1 Message Date
google-labs-jules[bot]
f18542d9fc Bolt: optimize daily limit checks by caching currency values
This optimization reduces the overhead in the OnTick execution path of
ExpertMAPSARSizeOptimized_Improved.mq5 by caching daily loss and profit
limits in currency.

- Added g_maxDailyLossCurrency and g_maxDailyProfitCurrency global variables.
- Updated UpdateDailyStatistics() to calculate and cache these limits only
  when necessary (initialization, day rollover, trade events, and periodic timer).
- Optimized CheckDailyLimits() to use the cached variables, eliminating
  redundant AccountInfoDouble(ACCOUNT_BALANCE) calls and percentage divisions
  on every tick.

These changes significantly reduce terminal API calls and arithmetic
operations in the EA's most frequent execution path.
2026-02-06 17:25:13 +00:00
google-labs-jules[bot]
2cf5af9902 Bolt: Optimized history processing and time calculations in ExpertMAPSARSizeOptimized_Improved
- Replaced expensive TimeToStruct and StructToTime calls with fast integer math for hour extraction and day-rollover detection.
- Consolidated history scanning into UpdateDailyStatistics to handle both profit calculation and trade counting in a single pass.
- Optimized history property retrieval by using ticket-less variants (e.g., HistoryDealGetInteger(DEAL_MAGIC)) after deal selection.
- Refined trade counting to specifically target DEAL_ENTRY_IN deals for robustness against terminal restarts and cleaner logic.
- Removed redundant history scans in OnTrade handler.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-02-04 11:04:14 +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