Commit graph

8 commits

Author SHA1 Message Date
google-labs-jules[bot]
8930a479c7 Bolt: optimize terminal API calls and time filtering in EA
Implemented a 1-second cache for terminal and MQL trading permission checks
and pre-calculated time filter bounds in OnInit. These changes significantly
reduce the per-tick overhead of the Expert Advisor by avoiding redundant
environment API calls and expensive time conversions in the OnTick path.
2026-02-27 18:46:27 +00:00
google-labs-jules[bot]
d6fdac641a Bolt: Optimize Daily Limit Checks and OnTick Flow
This commit improves the performance and efficiency of the `ExpertMAPSARSizeOptimized_Improved.mq5` Expert Advisor by:

1.  **Optimizing `CheckDailyLimits`**: Added a `static datetime lastLimitLogDay` flag to throttle logs and alerts. Once a daily limit is reached, subsequent calls for the rest of the day exit immediately, avoiding redundant string formatting, logging, and expensive `Alert()` API calls on every tick.
2.  **Optimizing `OnTick` Flow**: Reordered the execution path to call `CheckDailyLimits()` before `IsTradingAllowed()`. This prioritizes cheap, internal math checks over more expensive terminal environment API calls (`TerminalInfoInteger`, `MQLInfoInteger`), allowing the EA to exit significantly faster when trading is halted by daily limits.

These changes reduce CPU overhead in the "hot path" and eliminate log/alert flooding during high volatility.
2026-02-11 10:57:42 +00:00
google-labs-jules[bot]
9979a00963 Bolt: Optimize ExpertMAPSAR execution flow and resource usage (Retry)
- Pre-calculate daily risk factors (g_lossFactor, g_profitFactor) in OnInit to replace divisions with multiplications in statistics updates.
- Reorder IsTradingAllowed to perform time filter checks before expensive terminal API calls (TerminalInfoInteger, MQLInfoInteger).
- Implement log throttling for trading status messages to prevent flooding during high-frequency ticks.
- Guard new bar debug check in OnTick with log level check to avoid redundant iTime calls.
- Fix invalid LogInfo/LogDebug calls by switching from multiple arguments to string concatenation.
- Optimize Day-Rollover check in OnTick by using casted long for day calculation.
- Add explicit long cast for day calculation to ensure cross-platform consistency.

CI was previously throttled by GitHub API (429), this push triggers a retry.
2026-02-09 19:40:33 +00:00
google-labs-jules[bot]
57af0c49e7 Bolt: Optimize ExpertMAPSAR execution flow and resource usage
- Pre-calculate daily risk factors (g_lossFactor, g_profitFactor) in OnInit to replace divisions with multiplications in statistics updates.
- Reorder IsTradingAllowed to perform time filter checks before expensive terminal API calls (TerminalInfoInteger, MQLInfoInteger).
- Implement log throttling for trading status messages to prevent flooding during high-frequency ticks.
- Guard new bar debug check in OnTick with log level check to avoid redundant iTime calls.
- Fix invalid LogInfo/LogDebug calls by switching from multiple arguments to string concatenation.
- Optimize Day-Rollover check in OnTick by using casted long for day calculation.
2026-02-09 19:37:26 +00:00
google-labs-jules[bot]
393b3ffb39 Bolt: Cache daily limits and optimize time calls in ExpertMAPSARSizeOptimized_Improved.mq5
This commit implements significant performance optimizations in the OnTick execution path of the Expert Advisor:
- Caches daily loss and profit limits in currency units (g_maxDailyLossCurrency, g_maxDailyProfitCurrency) to avoid redundant AccountInfoDouble(ACCOUNT_BALANCE) calls and divisions on every tick.
- Refactors IsTradingAllowed and UpdateDailyStatistics to accept an optional datetime parameter, allowing OnTick to pass a pre-fetched TimeCurrent() value and reducing redundant system calls.
- Preserves standard risk management behavior by updating cached limits whenever statistics are refreshed (init, rollover, trades, and timer).

Verified with scripts/ci_validate_repo.py and scripts/test_automation.py.
2026-02-07 11:45:48 +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