MQL5-Google-Onedrive/mt5
google-labs-jules[bot] 0d116d040b Bolt: Remove recursive call in CalculateTP
💡 What: This change removes a dangerous recursive call in the `CalculateTP` function's error handling logic. Instead of calling itself, the function now uses a direct fallback calculation based on the Risk:Reward ratio.

🎯 Why: The original implementation created a risk of infinite recursion if the `CopyBuffer` call for the Donchian channel data failed repeatedly. This would lead to a stack overflow and crash the Expert Advisor—the ultimate performance failure.

📊 Impact:
- Prevents EA crashes: Eliminates the risk of a fatal stack overflow error, ensuring the trading bot remains stable even when indicator data is unavailable.
- Improves performance under failure: Replaces an infinite loop with a constant-time calculation, making the fallback logic instantaneous and efficient.

🔬 Measurement: The improvement can be verified by observing that the EA no longer crashes and logs errors related to stack overflow when the `CopyBuffer` call for the Donchian channel is forced to fail. The logic now correctly and immediately applies the `TP_RR` fallback.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-26 19:06:54 +00:00
..
MQL5 Bolt: Remove recursive call in CalculateTP 2026-01-26 19:06:54 +00:00