forked from LengKundee/MQL5-Google-Onedrive
💡 **What:** Added an "early exit" check at the beginning of the `OnTick()` function. This ensures the main logic, including the expensive `CopyRates()` call, runs only once when a new bar forms on the signal timeframe. 🎯 **Why:** The `OnTick()` function is executed on every incoming price tick. Previously, it performed heavy calculations on every single tick, even when no new trading information was available. This caused significant and unnecessary CPU load. 📊 **Impact:** This optimization dramatically reduces the Expert Advisor's CPU usage. Instead of executing complex logic hundreds or thousands of times per bar, it now executes only once. This leads to a more efficient and stable EA, especially in volatile market conditions. 🔬 **Measurement:** The improvement can be measured by monitoring the CPU usage of the MetaTrader 5 terminal while the EA is attached to a chart. The CPU load will be substantially lower and more stable after this change. Logging the execution frequency of the `OnTick` logic before and after would show a quantitative drop from many times per second to once per bar period. |
||
|---|---|---|
| .. | ||
| Experts | ||
| Indicators | ||