mirror of
https://github.com/A6-9V/MQL5-Google-Onedrive.git
synced 2026-04-11 08:20:58 +00:00
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> |
||
|---|---|---|
| .. | ||
| ExpertMAPSARSizeOptimized_Improved.mq5 | ||
| SMC_TrendBreakout_MTF_EA.mq5 | ||