MQL5-Google-Onedrive/mt5/MQL5
google-labs-jules[bot] 0dd702725d Bolt: Optimize OnTick by checking for new bar before CopyRates
💡 What: The optimization implemented
This change introduces a new-bar check at the beginning of the `OnTick` function. It uses a static variable to track the time of the last processed bar and exits early if a new bar has not yet formed.

🎯 Why: The performance problem it solves
The `OnTick` function is executed on every incoming price tick. The previous implementation called the expensive `CopyRates` function on every tick, even if no new bar had formed, leading to significant redundant processing. This is a classic performance bottleneck in MQL5 Expert Advisors.

📊 Impact: Expected performance improvement
This optimization dramatically reduces the EA's CPU consumption. The expensive logic inside `OnTick` will now run only once per bar on the signal timeframe, instead of multiple times per second. This leads to a more efficient and responsive EA, especially in volatile markets.

🔬 Measurement: How to verify the improvement
The improvement can be verified by observing the EA's execution frequency in the MetaTrader 5 terminal's "Experts" tab. Before the change, log messages would appear on every tick. After the change, they will only appear once per new bar.
2025-12-31 17:03:53 +00:00
..
Experts Bolt: Optimize OnTick by checking for new bar before CopyRates 2025-12-31 17:03:53 +00:00
Indicators feat: Add SL/TP modes and risk management to EA 2025-12-26 08:17:39 +00:00