mirror of
https://github.com/A6-9V/MQL5-Google-Onedrive.git
synced 2026-04-11 06:40:57 +00:00
💡 What: This change caches frequently accessed but static symbol properties (like point size, digits, tick value, and lot sizes) in global variables during the Expert Advisor's `OnInit` phase. 🎯 Why: The `OnTick` function and the helper functions it calls (`CalculateSL`, `CalculateTP`, `CalculateLots`) were repeatedly calling `SymbolInfoDouble()` and `SymbolInfoInteger()` on every tick. These function calls have a performance overhead. Since these values do not change during the EA's operation on a given symbol, caching them avoids this redundant work. 📊 Impact: This optimization reduces the execution time of each `OnTick` cycle by eliminating multiple function calls. While the impact per tick is small, it accumulates over time and is a best practice for MQL5 development, leading to a more efficient and robust Expert Advisor. 🔬 Measurement: The improvement can be verified by using the MetaTrader 5 Strategy Tester with profiling enabled. A comparison of the profiling logs before and after the change would show a reduction in the time spent within the `CalculateLots`, `CalculateSL`, and `CalculateTP` functions, and a lower overall number of calls to `SymbolInfo...` functions. |
||
|---|---|---|
| .. | ||
| ExpertMAPSARSizeOptimized_Improved.mq5 | ||
| SMC_TrendBreakout_MTF_EA.mq5 | ||