MQL5-Google-Onedrive/mt5/MQL5/Experts
google-labs-jules[bot] ea6b478dfe Refactor: Pass Indicator Data to Avoid Redundant CopyBuffer Calls
This commit optimizes the performance of the `OnTick` function, a critical hot path in the Expert Advisor.

Previously, the helper functions `CalculateSL` and `CalculateTP` would independently call `CopyBuffer()` to fetch the latest ATR and Donchian Channel values. Since these functions are called from `OnTick`, this resulted in multiple, redundant data-fetching operations on the same tick.

This refactoring modifies the function signatures of `CalculateSL`, `CalculateTP`, `OpenBuyTrade`, and `OpenSellTrade`. The required indicator data is now fetched only once at the beginning of `OnTick` and is then passed down as parameters to the functions that need it.

This change significantly reduces the overhead within the `OnTick` loop, leading to more efficient execution.

Additionally, this commit fixes a latent bug in `CalculateTP` where a failure to fetch indicator data would cause an infinite recursion, leading to a stack overflow. The new implementation replaces this with a safe, non-recursive fallback.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-27 10:42:19 +00:00
..
ExpertMAPSARSizeOptimized_Improved.mq5 Improve ExpertMAPSARSizeOptimized EA with enhanced risk management, logging, and safety features 2026-01-19 14:19:52 +07:00
SMC_TrendBreakout_MTF_EA.mq5 Refactor: Pass Indicator Data to Avoid Redundant CopyBuffer Calls 2026-01-27 10:42:19 +00:00