MQL5-Google-Onedrive/mt5/MQL5
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
..
Experts Refactor: Pass Indicator Data to Avoid Redundant CopyBuffer Calls 2026-01-27 10:42:19 +00:00
Indicators feat(mql5): cache MTF confirmation to reduce CPU load (#78) 2026-01-10 05:36:08 +07:00