MQL5-Google-Onedrive/mt5/MQL5/Indicators
google-labs-jules[bot] cee78864d6 Bolt: optimize indicator OnCalculate performance (revised)
This commit implements several performance optimizations in the SMC MTF indicator:
1. Robust Early Exit: Added a 'new bar' check using iTime() to skip redundant calculations on every price tick. Handled prev_calculated=0 to ensure full history recalculations when requested.
2. Lazy Loading: Wrapped expensive fractal and Donchian calculations in conditional blocks so they only execute if the respective features are enabled.
3. Efficient Buffer Clearing: Replaced manual O(N) loops with ArrayInitialize() for bulk clearing of indicator buffers on first run.
4. Robustness: Added 'history not ready' checks (iTime == 0) to both the indicator and EA.
5. Cleanup: Removed redundant ArraySetAsSeries calls on static arrays in GetMTFDir and updated comments.

Impact: Reduces CPU usage on every tick by skipping unnecessary logic and improves initialization speed during history loading.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-31 10:52:36 +00:00
..
SMC_TrendBreakout_MTF.mq5 Bolt: optimize indicator OnCalculate performance (revised) 2026-01-31 10:52:36 +00:00