Commit graph

1 commit

Author SHA1 Message Date
google-labs-jules[bot]
8c04cff704 feat: Add new bar check to OnTick() to prevent redundant calculations
💡 What: This change introduces a check at the very beginning of the `OnTick()` function. It uses the lightweight `iTime()` function to see if a new bar has formed on the signal timeframe and exits immediately if it hasn't.

🎯 Why: The `OnTick()` function is executed on every incoming price tick, which can be very frequent. The core logic of the EA, including the expensive `CopyRates()` call and subsequent indicator calculations, only needs to run once per bar. This change prevents these expensive operations from running needlessly on every tick.

📊 Impact: This optimization drastically reduces the EA's CPU usage. Instead of running the entire calculation logic multiple times per second, it will now run only once when a new bar appears. This makes the EA far more efficient and reduces the load on the MetaTrader terminal.

🔬 Measurement: The performance improvement can be verified by observing the "Experts" tab in the MT5 terminal. Before this change, any log/print statements inside `OnTick` would fire on every price update. After this change, they will only fire once at the beginning of each new bar.
2026-01-06 10:36:15 +00:00