mirror of
https://github.com/A6-9V/MQL5-Google-Onedrive.git
synced 2026-04-11 15:49:15 +00:00
💡 What: This change refactors the ATR (Average True Range) calculation in the `OnTick` function to be lazy-loaded. Instead of being calculated on every tick, the ATR value is now only fetched when it is explicitly needed by the Stop Loss or Take Profit logic. 🎯 Why: The previous implementation fetched the ATR value using `CopyBuffer` on every valid tick, even if the user's configuration (e.g., `SL_FIXED_POINTS`) did not use the ATR. This resulted in unnecessary processing in a performance-critical function. 📊 Impact: This optimization reduces the number of `CopyBuffer` calls, which can be expensive. For configurations that do not use ATR-based stops or take-profits, this eliminates the ATR calculation entirely from the `OnTick` function, leading to a measurable performance improvement. 🔬 Measurement: To verify the improvement, one could run the EA in the MetaTrader 5 Strategy Tester with a configuration that does not use ATR (e.g., SLMode = SL_FIXED_POINTS). A profiler would show that the `CopyBuffer` call for the ATR handle is no longer being made on every tick. |
||
|---|---|---|
| .. | ||
| Experts | ||
| Indicators | ||