MQL5-Google-Onedrive/mt5/MQL5/Experts
google-labs-jules[bot] 33754cbb24 feat(perf): Optimize OnTick with early new-bar check
💡 What:
Adds a lightweight `iTime()` check at the beginning of the `OnTick()` function. This verifies if a new bar has formed on the signal timeframe before executing more resource-intensive functions like `CopyRates()`.

🎯 Why:
The `OnTick()` function is called for every price tick, which can be very frequent. The previous implementation performed an expensive `CopyRates()` call on every tick, even though the trading logic only needed to run once per bar. This caused significant and unnecessary CPU load.

📊 Impact:
This change drastically reduces the EA's CPU usage. The EA now exits immediately on most ticks after a very cheap check, only proceeding with heavy processing when a new candle appears. This makes the EA more efficient and responsive, especially in volatile market conditions.

🔬 Measurement:
The improvement can be measured by profiling the EA in the MetaTrader 5 Strategy Tester or by monitoring the terminal's CPU usage with the EA attached to a live chart. The average execution time of the `OnTick` function will be significantly lower.
2026-01-04 17:04:04 +00:00
..
SMC_TrendBreakout_MTF_EA.mq5 feat(perf): Optimize OnTick with early new-bar check 2026-01-04 17:04:04 +00:00