forked from LengKundee/MQL5-Google-Onedrive
💡 What: This commit introduces an 'early exit' guard at the beginning of the `OnTick()` function in the main Expert Advisor. It checks if a new bar has formed on the signal timeframe before proceeding with any further calculations. 🎯 Why: The `OnTick()` function is executed on every incoming price tick. Previously, it would call expensive functions like `CopyRates()` and perform all trading logic on every single tick, even if no new bar had appeared. This resulted in significant redundant computation and unnecessary CPU load. 📊 Impact: This optimization ensures the core trading logic runs only once per bar instead of on every tick. For a typical currency pair, this can reduce the number of executions by a factor of 10-100x or more, leading to a significant reduction in CPU usage and a more efficient EA, especially during volatile market conditions. 🔬 Measurement: The improvement can be measured by profiling the EA's execution time in the MetaTrader 5 Strategy Tester or by observing the reduced CPU load of the terminal when the EA is running on a live chart. The difference will be most noticeable on lower timeframes (e.g., M1, M5) where tick frequency is high. |
||
|---|---|---|
| .. | ||
| SMC_TrendBreakout_MTF_EA.mq5 | ||