forked from LengKundee/MQL5-Google-Onedrive
💡 What: This change introduces a caching mechanism for the multi-timeframe (MTF) trend confirmation logic in the `GetMTFDir()` function. The result of the EMA calculation is now stored and only recalculated when a new bar forms on the lower timeframe. 🎯 Why: The `GetMTFDir()` function was being called on every `OnTick` event, which can fire multiple times per second. This led to expensive `CopyBuffer` calls to retrieve EMA values from a lower timeframe, even when those values had not changed. 📊 Impact: This optimization dramatically reduces the number of expensive `CopyBuffer` calls. Instead of running on every tick, the calculation now only runs once per bar on the lower timeframe. For an H1 chart using M5 confirmation, this reduces calculations from potentially hundreds per minute to just one every 5 minutes, significantly improving the EA's performance and reducing CPU load. 🔬 Measurement: The performance improvement can be verified by adding counters to the `GetMTFDir` function. A counter incremented at the start of the function will show a high call rate, while a counter incremented only when the recalculation logic is triggered will show a much lower rate, confirming the caching is effective. |
||
|---|---|---|
| .. | ||
| MQL5 | ||