forked from LengKundee/MQL5-Google-Onedrive
💡 What: This optimization refactors the `OnTick` function to defer the call to `GetMTFDir()` (which performs multi-timeframe analysis) until after a primary breakout signal (SMC or Donchian) is confirmed. 🎯 Why: The `OnTick` function is a performance-critical hot path that runs on every price tick. The `GetMTFDir()` function is a relatively expensive operation. The original code called this function on every new bar, even when no potential trade signal existed, leading to unnecessary computation. 📊 Impact: This change significantly reduces the EA's computational load. The `GetMTFDir()` function will now only be called on the small fraction of bars where a valid breakout signal occurs, instead of on every single bar. This leads to lower CPU usage and a more efficient EA, especially on volatile instruments with many ticks. 🔬 Measurement: The improvement can be verified by adding logging or profiling timers around the `GetMTFDir()` call and observing that it is invoked far less frequently during a backtest or live trading compared to the previous version. The overall `OnTick` execution time, measured in the MetaTrader 5 Strategy Tester, will show a reduction. |
||
|---|---|---|
| .. | ||
| MQL5 | ||