提交图

53 提交

作者 SHA1 备注 提交日期
google-labs-jules[bot]
d6fdac641a Bolt: Optimize Daily Limit Checks and OnTick Flow
This commit improves the performance and efficiency of the `ExpertMAPSARSizeOptimized_Improved.mq5` Expert Advisor by:

1.  **Optimizing `CheckDailyLimits`**: Added a `static datetime lastLimitLogDay` flag to throttle logs and alerts. Once a daily limit is reached, subsequent calls for the rest of the day exit immediately, avoiding redundant string formatting, logging, and expensive `Alert()` API calls on every tick.
2.  **Optimizing `OnTick` Flow**: Reordered the execution path to call `CheckDailyLimits()` before `IsTradingAllowed()`. This prioritizes cheap, internal math checks over more expensive terminal environment API calls (`TerminalInfoInteger`, `MQLInfoInteger`), allowing the EA to exit significantly faster when trading is halted by daily limits.

These changes reduce CPU overhead in the "hot path" and eliminate log/alert flooding during high volatility.
2026-02-11 10:57:42 +00:00
google-labs-jules[bot]
9979a00963 Bolt: Optimize ExpertMAPSAR execution flow and resource usage (Retry)
- Pre-calculate daily risk factors (g_lossFactor, g_profitFactor) in OnInit to replace divisions with multiplications in statistics updates.
- Reorder IsTradingAllowed to perform time filter checks before expensive terminal API calls (TerminalInfoInteger, MQLInfoInteger).
- Implement log throttling for trading status messages to prevent flooding during high-frequency ticks.
- Guard new bar debug check in OnTick with log level check to avoid redundant iTime calls.
- Fix invalid LogInfo/LogDebug calls by switching from multiple arguments to string concatenation.
- Optimize Day-Rollover check in OnTick by using casted long for day calculation.
- Add explicit long cast for day calculation to ensure cross-platform consistency.

CI was previously throttled by GitHub API (429), this push triggers a retry.
2026-02-09 19:40:33 +00:00
google-labs-jules[bot]
57af0c49e7 Bolt: Optimize ExpertMAPSAR execution flow and resource usage
- Pre-calculate daily risk factors (g_lossFactor, g_profitFactor) in OnInit to replace divisions with multiplications in statistics updates.
- Reorder IsTradingAllowed to perform time filter checks before expensive terminal API calls (TerminalInfoInteger, MQLInfoInteger).
- Implement log throttling for trading status messages to prevent flooding during high-frequency ticks.
- Guard new bar debug check in OnTick with log level check to avoid redundant iTime calls.
- Fix invalid LogInfo/LogDebug calls by switching from multiple arguments to string concatenation.
- Optimize Day-Rollover check in OnTick by using casted long for day calculation.
2026-02-09 19:37:26 +00:00
google-labs-jules[bot]
ca2fcb7cee Bolt: Optimize lot calculation and margin clamping
- Pre-calculate inverse of initial margin in OnInit to avoid division in hot path.
- Refactor CalculateLots to apply margin clamping before normalization.
- Consolidate rounding and clamping logic into a single execution path.
- Remove redundant NormalizeDouble and duplicate calculations.
2026-02-08 19:20:35 +00:00
google-labs-jules[bot]
393b3ffb39 Bolt: Cache daily limits and optimize time calls in ExpertMAPSARSizeOptimized_Improved.mq5
This commit implements significant performance optimizations in the OnTick execution path of the Expert Advisor:
- Caches daily loss and profit limits in currency units (g_maxDailyLossCurrency, g_maxDailyProfitCurrency) to avoid redundant AccountInfoDouble(ACCOUNT_BALANCE) calls and divisions on every tick.
- Refactors IsTradingAllowed and UpdateDailyStatistics to accept an optional datetime parameter, allowing OnTick to pass a pre-fetched TimeCurrent() value and reducing redundant system calls.
- Preserves standard risk management behavior by updating cached limits whenever statistics are refreshed (init, rollover, trades, and timer).

Verified with scripts/ci_validate_repo.py and scripts/test_automation.py.
2026-02-07 11:45:48 +00:00
google-labs-jules[bot]
f2fb340adf Bolt: Optimized SMC_TrendBreakout_MTF indicator performance
This optimization improves the execution efficiency of the `SMC_TrendBreakout_MTF` indicator by:
- Replacing the manual buffer clearing loop in `OnCalculate()` with the native `ArrayFill()` function.
- Replacing the `CopyTime()` call in `GetMTFDir()` with the lighter `iTime()` function for MTF bar timestamp checks.
- Refactoring input-based logic (Donchian lookback and signal bar index) into global cached variables initialized in `OnInit()`, avoiding redundant calculations on every new bar.

These changes reduce CPU overhead and improve the indicator's responsiveness, especially when attached to multiple charts or using lower timeframe confirmations.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-02-06 10:52:52 +00:00
GenX FX Trading System
382a5e492c
Bolt: optimize EA execution path and lot calculation (#254)
- Pre-calculated constants in OnInit() to replace recurring divisions and point-conversions in the trade execution path.
- Optimized CalculateLots(), CalculateSL(), and CalculateTP() by using pre-calculated factors and inverses.
- Consolidated lot limit checks into a single range check.
- Reduced mathematical operations in OnTick() and trade functions.
- Verified with repository CI and automation test scripts.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-02-05 02:53:34 +07:00
google-labs-jules[bot]
2cf5af9902 Bolt: Optimized history processing and time calculations in ExpertMAPSARSizeOptimized_Improved
- Replaced expensive TimeToStruct and StructToTime calls with fast integer math for hour extraction and day-rollover detection.
- Consolidated history scanning into UpdateDailyStatistics to handle both profit calculation and trade counting in a single pass.
- Optimized history property retrieval by using ticket-less variants (e.g., HistoryDealGetInteger(DEAL_MAGIC)) after deal selection.
- Refined trade counting to specifically target DEAL_ENTRY_IN deals for robustness against terminal restarts and cleaner logic.
- Removed redundant history scans in OnTrade handler.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-02-04 11:04:14 +00:00
google-labs-jules[bot]
601eedbd48 Bolt: Optimize Expert Advisor tick performance and history scanning
This PR implements several high-impact performance optimizations in `ExpertMAPSARSizeOptimized_Improved.mq5`:

1.  **Reduced History Scanning Overhead**: Moved the expensive `UpdateDailyStatistics()` call (which uses `HistorySelect` and loops through deals) out of the `OnTick()` path. It is now called only on trade events, periodic timer intervals, and day rollovers.
2.  **Optimized Day-Rollover Logic**: Replaced multiple `TimeToStruct` and `StructToTime` calls in the tick path with a lightweight integer division (`TimeCurrent() / 86400`) to detect calendar day changes.
3.  **Efficient History Selection**: Introduced `g_todayStart` to cache the midnight timestamp, ensuring `HistorySelect` targets the current day's data precisely rather than a rolling 24-hour window.
4.  **Lightweight New Bar Detection**: Replaced expensive `CopyRates()` calls for logging new bars with a simple `iTime()` lookup.

These changes significantly reduce the CPU and terminal API overhead per tick, which is critical for high-frequency or multi-symbol trading.

📊 **Impact**: Reduces `OnTick` execution time by avoiding redundant history scans on every price update.
🔬 **Measurement**: Verified with `scripts/ci_validate_repo.py` and manual code review against MQL5 performance best practices.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-02-02 17:40:08 +00:00
google-labs-jules[bot]
39a12f19fd bolt: optimize OnTick execution and data retrieval in EA
This commit implements several performance optimizations in the SMC_TrendBreakout_MTF_EA.mq5 Expert Advisor:

1.  **Early Exit for Open Positions**: Moved the PositionSelect check to the top of the OnTick handler, immediately after the new bar check. This skips expensive indicator data fetching (CopyRates, CopyBuffer) when a position is already open.
2.  **Minimized Data Payload**: Reduced the number of bars fetched from 3 to 2 for CopyRates and all CopyBuffer calls. The current strategy logic only requires the current and previous bars.
3.  **Lazy Evaluation of Prices and Indicators**: Deferred SymbolInfoTick and ATR fetching until a trade signal is confirmed.
4.  **Atomic Price Retrieval**: Replaced non-standard Ask/Bid variables with SymbolInfoTick for more efficient and robust price retrieval in MQL5.

These changes significantly reduce terminal overhead and data transfer per tick, particularly improving performance during optimization and backtesting.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-02-01 17:22:31 +00:00
google-labs-jules[bot]
40c687fdb8 Bolt: defer terminal state checks in OnTick
Optimized the OnTick hot path in SMC_TrendBreakout_MTF_EA.mq5 by moving TerminalInfoInteger and MQLInfoInteger calls below the iTime() new bar check. This prevents redundant API calls on every price tick, saving CPU resources during high volatility.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-02-01 10:55:54 +00:00
google-labs-jules[bot]
a42da11111 Bolt: Lot Size Calculation & Static Buffer Optimization
- Optimized lot size calculation by pre-calculating constants in OnInit.
- Converted local arrays in OnTick to static to reuse memory.
- Implemented one-time ArraySetAsSeries calls using a static flag.
- Removed redundant close array and accessed rates directly.
- Deferred ATR CopyBuffer until signal confirmation.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-31 19:07:36 +00:00
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
google-labs-jules[bot]
c320caca35 Bolt: Optimize object management and fix fractal detection in SMC Indicator
What:
- Introduced a cached object counter `g_objCount` in `SMC_TrendBreakout_MTF.mq5`.
- Updated `OnInit`, `DrawHLine`, and `DrawText` to maintain this counter.
- Refactored `SafeDeleteOldObjects` to use the cached counter and native `ObjectsDeleteAll()` for efficient bulk removal.
- Fixed a bug in fractal detection logic where `EMPTY_VALUE` was incorrectly identified as a valid swing point.

Why:
- The original `SafeDeleteOldObjects` performed two $O(N)$ passes over every object on the chart using relatively slow scripted functions (`ObjectName`, `StringFind`) on every new bar. This created a performance bottleneck on charts with many objects.
- The fractal bug caused incorrect swing point identification, leading to false signals and unnecessary processing of invalid data.

Impact:
- Significantly reduces CPU usage on new bars by avoiding redundant iterations over chart objects.
- Improves indicator accuracy and reliability by ensuring only valid fractal points are used for signal calculation.

Measurement:
- Verified via code review and manual inspection of the logic.
- Repository integrity confirmed by `ci_validate_repo.py` and `test_automation.py`.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-30 19:18:07 +00:00
google-labs-jules[bot]
80466584ba Bolt: Use native ArrayMaximum/ArrayMinimum for Donchian calculation
💡 What: Replaced manual `for` loops in `HighestHigh` and `LowestLow` with native `ArrayMaximum` and `ArrayMinimum` functions in `mt5/MQL5/Indicators/SMC_TrendBreakout_MTF.mq5`.
🎯 Why: Native MQL5 functions are implemented in optimized C++ and are significantly faster than loops executed in the MQL5 scripting layer.
📊 Impact: Improves the performance of Donchian channel calculation, reducing indicator overhead per bar.
🔬 Measurement: Verified with existing CI validation and code inspection.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-30 17:33:07 +00:00
GenX FX Trading System
290ff8a49d
Merge pull request #225 from A6-9V/bolt-lazy-load-ema-5322101291294523587
 Bolt: Lazily load EMA confirmation indicators in OnTick
2026-01-30 07:17:07 +07:00
google-labs-jules[bot]
107f9a68e4 refactor(EA): Apply DRY principle to CalculateSL function
Refactored the CalculateSL function in the SMC Trend Breakout EA to merge the logic for SL_ATR and SL_SWING modes.

The original implementation had redundant code blocks for these two modes. This change consolidates the logic into a single, more efficient path, improving code readability and maintainability. While the performance impact is negligible, this change aligns with best practices for writing clean and efficient code.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-29 19:06:42 +00:00
google-labs-jules[bot]
a737c2a0c9 feat(perf): Bolt: Lazily load EMA confirmation indicators in OnTick
Lazily loads the EMA confirmation indicator data in the `OnTick` function.

This change refactors the `OnTick` function to first check for a primary trade signal (Donchian Channel breakout) before fetching the data for the secondary confirmation indicators (EMAs).

This avoids two expensive `CopyBuffer()` calls on every new bar, reducing unnecessary processing and improving the overall efficiency of the EA, especially in non-trending markets where trade signals are infrequent. The functional logic remains identical.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-29 17:33:31 +00:00
google-labs-jules[bot]
adbc7e159f feat(perf): Bolt: Cache Account Info in OnTick
This optimization caches account information (balance, equity, free margin) by fetching it once at the start of the `OnTick` function. This data is then passed down as arguments to the trade execution and lot calculation functions.

This change reduces the number of `AccountInfoDouble()` calls from three to one per tick when a trade signal is evaluated, lowering the execution time of the `OnTick` function and making the EA more efficient.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-29 10:49:50 +00:00
google-labs-jules[bot]
e36e50aa5a feat(performance): Optimize OnTick with iTime New Bar Check
Refactored the `OnTick()` function to use the lightweight `iTime()` function for the new bar check *before* the expensive `CopyRates()` call.

The original implementation called `CopyRates()` on every single price tick, which is highly inefficient. The `OnTick` function is a performance-critical hot path, and this caused unnecessary resource consumption.

This change reduces CPU usage by preventing the `CopyRates()` data-copying operation on the vast majority of ticks. The EA now only performs expensive calculations once per bar, as intended.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-28 17:32:20 +00:00
google-labs-jules[bot]
591d8f1289 feat(ea): Defer ATR calculation in OnTick
Implements a performance optimization in the `SMC_TrendBreakout_MTF_EA` Expert Advisor.

The `CopyBuffer` call to fetch the Average True Range (ATR) indicator is deferred until a trade signal (`buySignal` or `sellSignal`) is confirmed. This avoids executing the call on every tick, reducing unnecessary processing in the performance-critical `OnTick` function.

The implementation was also refactored to remove code duplication by combining the signal checks into a single block, adhering to the DRY principle.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-28 10:38:16 +00:00
google-labs-jules[bot]
f313fcd390 feat: Optimize OnTick by passing indicator values
- Refactors `OnTick` to fetch indicator data once.
- Passes indicator values as arguments to `CalculateSL` and `CalculateTP`.
- Eliminates redundant `CopyBuffer` calls in a hot path.
- Fixes a critical infinite recursion bug in `CalculateTP`'s fallback logic.

Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-27 19:50:17 +00:00
GenX FX Trading System
92d12f8cbc
Merge branch 'main' into bolt-optimize-price-retrieval-6851558663357307352 2026-01-26 15:25:27 +07:00
google-labs-jules[bot]
4abce0677b Bolt: Consolidate redundant CopyRates calls in OnTick
💡 What: This optimization consolidates two separate `CopyRates` calls within the `OnTick` function into a single call.

🎯 Why: The original code fetched bar data twice on every new bar—once to check the timestamp and again to get closing prices. This created unnecessary overhead in a performance-critical function.

📊 Impact: Reduces data fetching operations by 50% within the `OnTick` new-bar logic, leading to a more efficient EA, especially in volatile markets with frequent ticks.

🔬 Measurement: The improvement can be verified by observing that only one `CopyRates` call is present at the beginning of the `OnTick` function, and the data is reused correctly.
2026-01-25 19:18:04 +00:00
google-labs-jules[bot]
da1eeae4a4 Bolt: Cache static symbol properties to improve performance
- **What:** Cached static symbol properties (e.g., point size, digits, lot size constraints) in global variables during `OnInit`.
- **Why:** The `SymbolInfo...()` functions were being called repeatedly in performance-critical trading functions, adding unnecessary overhead.
- **Impact:** This change reduces the number of expensive function calls in the `OnTick` hot path, resulting in a measurable performance improvement.
- **Measurement:** The improvement can be verified by profiling the EA's execution time, which will show a reduction in the time spent in the refactored functions.
2026-01-25 17:06:45 +00:00
google-labs-jules[bot]
9665d7e394 feat(performance): Use Ask/Bid globals in OnTick for efficiency
Replaces the `SymbolInfoDouble()` function calls for fetching ask and bid prices with the predefined `Ask` and `Bid` global variables inside the performance-critical `OnTick` function.

This change avoids the overhead of function calls on every tick, leading to a small but meaningful reduction in execution latency. This is a standard MQL5 optimization for high-frequency code paths.
2026-01-24 19:40:47 +00:00
google-labs-jules[bot]
2935acfa7c feat(performance): Optimize OnTick by removing redundant price calls
💡 What: Refactored the `OpenBuyTrade` and `OpenSellTrade` functions to accept `ask` and `bid` prices as arguments. This eliminates redundant `SymbolInfoDouble()` calls within these functions.

🎯 Why: The `OnTick()` function is a performance-critical "hot path" that executes on every price tick. The original code fetched the `ask`/`bid` prices in `OnTick` and again within the trade functions, causing unnecessary function call overhead in a high-frequency loop.

📊 Impact: Reduces redundant function calls within the `OnTick` execution path. While a micro-optimization, this improves the overall efficiency of the EA by ensuring prices are fetched only once per tick.

🔬 Measurement: This can be verified by code inspection, observing that `SymbolInfoDouble(_Symbol, SYMBOL_ASK)` and `SymbolInfoDouble(_Symbol, SYMBOL_BID)` are no longer present in `OpenBuyTrade` and `OpenSellTrade` and that the values are passed down from `OnTick`.
2026-01-24 17:29:13 +00:00
NUNA
b66e95973b Improve ExpertMAPSARSizeOptimized EA with enhanced risk management, logging, and safety features 2026-01-19 14:19:52 +07:00
NUNA
5aeb1cfa35 Add dev container setup, cloud deployment configs, and Jules deployment automation 2026-01-19 09:53:30 +07:00
google-labs-jules[bot]
9a772e0ae3 feat(perf): Defer MqlRates array allocation in OnTick
**What:** The `MqlRates rates[400]` array declaration is moved from the top of the `OnTick` function into the conditional `if` block where it is actually used.

**Why:** The `OnTick` function is a performance-critical "hot path." The previous implementation allocated a large array on the stack on every single tick, even if the function exited early and the array was never used. This created unnecessary memory overhead on the most common, lightweight execution path.

**Impact:** This change reduces stack memory allocation for the majority of `OnTick` calls. While the impact per call is small, it accumulates significantly over time in a high-frequency trading context, leading to a more efficient EA.

**Measurement:** The improvement can be observed by profiling the EA's execution time per tick, particularly in scenarios where the `UseSMC` and `SLMode == SL_SWING` inputs are disabled. The optimized code will show a small but consistent reduction in execution time on the lighter path.
2026-01-16 01:39:39 +07:00
google-labs-jules[bot]
b314c56005
feat(perf): Cache signal timeframe in OnInit to optimize OnTick (#109)
Moves the signal timeframe calculation from the performance-critical `OnTick` function to the `OnInit` function.

The signal timeframe is determined by user input (`SignalTF`) and the chart's period, neither of which change during the EA's runtime. Calculating this on every tick is a small but unnecessary overhead.

This commit caches the calculated timeframe in a new global variable `gSignalTf` during initialization, ensuring the logic runs only once. The `OnTick` function now uses this cached value, removing the redundant computation from the EA's hot path.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: GenX FX Trading System <199350297+Mouy-leng@users.noreply.github.com>
2026-01-16 01:38:49 +07:00
google-labs-jules[bot]
4f58722a3c
feat(perf): Use iClose for faster price reads in OnTick (#106)
💡 What: Replaced an expensive `CopyRates()` call with the lightweight, native `iClose()` function in the `OnTick` "light" execution path.

🎯 Why: The previous implementation used `CopyRates()` to fetch an array of bar data, even when only a single closing price was needed. This created unnecessary overhead (memory allocation, data copying) on every tick where complex analysis was disabled.

📊 Impact: This change significantly reduces the computational overhead of the EA in its most common operational mode. Using `iClose` is orders of magnitude faster than `CopyRates` for fetching a single value, leading to lower CPU usage and faster tick processing.

🔬 Measurement: The improvement can be verified by profiling the EA in the MetaTrader 5 Strategy Tester. Executing the EA with `UseSMC=false` and `SLMode != SL_SWING` will show a measurable decrease in the average `OnTick` execution time compared to the previous version.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-15 18:49:59 +07:00
google-labs-jules[bot]
cd4d124107
Bolt: Defer expensive data loading in OnTick (#103)
💡 What: This optimization refactors the `OnTick` function to conditionally load expensive historical data (`CopyRates` and `CopyBuffer` for fractals) only when required by the enabled features (SMC or Swing SL).

🎯 Why: The previous implementation loaded up to 400 bars of price data and 300 bars of fractal data on every new bar, regardless of the EA's configuration. This caused unnecessary processing overhead for users who were not using the features that required this deep historical analysis.

📊 Impact: Reduces the execution time of the `OnTick` function significantly for common configurations (e.g., Donchian Breakout only). This leads to lower CPU usage and potentially faster reaction to trading signals, as the EA spends less time on unnecessary data processing.

🔬 Measurement: The performance improvement can be measured by using the MetaTrader 5 Strategy Tester and profiling the EA's execution time with and without the `UseSMC` and `SLMode == SL_SWING` options enabled. The execution time per tick will be substantially lower when these features are disabled.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-15 03:16:50 +07:00
google-labs-jules[bot]
9a26dbc7e2
feat(perf): Bolt: Lazily load ATR calculation in OnTick (#105)
This commit optimizes the MQL5 Expert Advisor by deferring the Average True Range (ATR) calculation until it is explicitly required for Stop Loss or Take Profit calculations.

Previously, the ATR was calculated via an expensive `CopyBuffer` call on every tick, regardless of whether the selected SL/TP mode used it.

This change introduces a `GetATR()` helper function that lazy-loads and caches the ATR value for the duration of a single `OnTick` event. This ensures the `CopyBuffer` call is only executed when needed, reducing unnecessary processing on the vast majority of ticks.

Additionally, this commit introduces critical safety checks to ensure that if the SL or TP calculations fail (e.g., because a valid ATR could not be fetched when required), the EA will abort the trade rather than placing an order with an invalid risk profile. This enhances the robustness and safety of the trading logic.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-15 03:16:06 +07:00
google-labs-jules[bot]
86d38c0d54
feat(perf): Use lazy calculation for fractal swing search (#102)
💡 What: This change wraps the fractal swing high/low search loop in a conditional.

🎯 Why: The loop was executing on every new bar, even when the features requiring this data (SMC signals or Swing SL) were disabled.

📊 Impact: For users with `UseSMC=false` and `SLMode!=SL_SWING`, this completely eliminates the fractal search calculation (~300 loop iterations) on every bar, reducing CPU usage in the performance-critical `OnTick` function.

🔬 Measurement: To verify, run the EA in the MetaTrader 5 Strategy Tester. With the affected inputs disabled, a profiler would show the fractal search loop is no longer executed within the `OnTick` function.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-14 22:19:26 +07:00
google-labs-jules[bot]
501ca14833
feat(perf): Cache MinStopDistancePrice in OnInit (#101)
This commit optimizes the EA by pre-calculating the minimum stop distance in the `OnInit` function and caching it in a global variable.

This avoids the overhead of calling the `MinStopDistancePrice` function on every tick within the `OnTick` function, which is a performance-critical hot path. The calculated value is static for the lifetime of the EA, making it a perfect candidate for caching.

The now-redundant `MinStopDistancePrice` function has been removed.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-14 03:51:04 +07:00
google-labs-jules[bot]
61e319253f
feat(perf): Cache G_POINT with fallback in OnInit to optimize OnTick (#100)
- **What:** This change moves the fallback logic for the `G_POINT` variable from the `OnTick` function to the `OnInit` function. Instead of checking if `G_POINT` is valid on every tick, it is now checked once at initialization, and a fallback to `_Point` is used if necessary.

- **Why:** The `OnTick` function is a performance-critical hot path. Removing the conditional check from this function reduces the number of operations performed on every price tick, leading to a small but measurable performance improvement.

- **Impact:** This micro-optimization reduces CPU usage by eliminating a redundant conditional check in the `OnTick` function. The impact is most noticeable in high-frequency trading scenarios.

- **Measurement:** The performance improvement can be verified by profiling the `OnTick` function before and after the change in the MetaTrader 5 Strategy Tester. The optimized version will show a slightly lower execution time per tick.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-14 00:35:37 +07:00
google-labs-jules[bot]
18e3fd66e2
Bolt: Defer MTF confirmation until after primary signal (#99)
💡 What: This change refactors the `OnTick()` function to defer the call to `GetMTFDir()` (which performs a multi-timeframe confirmation) until after a primary trading signal (SMC structure break or Donchian breakout) has been identified on the main timeframe.

🎯 Why: The `OnTick()` function is a performance-critical "hot path" that runs on every price tick. The original code called `GetMTFDir()` unconditionally on every new bar, executing a `CopyTime` operation even when no potential trade existed. This created unnecessary processing overhead.

📊 Impact: This optimization significantly reduces the EA's processing load. The `GetMTFDir()` function will now only be called on the rare occasion that a primary signal occurs, avoiding the `CopyTime` call on >99% of bars. This leads to lower CPU usage and a more efficient EA, especially in volatile markets.

🔬 Measurement: The improvement can be verified by adding logging or profiling counters around the `GetMTFDir()` call. In a backtest over a long period, the "optimized" version will show a dramatically lower count of calls to this function compared to the "unoptimized" version.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-14 00:16:49 +07:00
google-labs-jules[bot]
d00d1ed51b
feat(perf): Optimize Donchian calculation with native indicator (#98)
Replaced the manual `iHighest`/`iLowest` logic in the `OnTick` function with the more performant, native `iDonchian` indicator.

This optimization involves:
- Initializing the `iDonchian` handle once in `OnInit`.
- Using `CopyBuffer` to fetch the pre-calculated channel values in `OnTick`.
- Releasing the indicator handle in `OnDeinit` for proper resource management.

This change significantly reduces the computational load in the EA's most critical function by offloading the calculation to the terminal's optimized, compiled code, which only recalculates when necessary.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-13 22:35:57 +07:00
google-labs-jules[bot]
b8f1a7f2b3
Bolt: Cache Donchian lookback validation (#94)
💡 What: This change caches the validated `DonchianLookback` input parameter in a global variable during `OnInit()`.

🎯 Why: The `DonchianLookback` value was being validated on every single tick inside the performance-critical `OnTick()` function. Since this input value doesn't change after the EA is initialized, this check is redundant and adds unnecessary overhead to a hot path.

📊 Impact: This is a micro-optimization that removes a small, unnecessary calculation from a high-frequency code path. By moving the validation to `OnInit()`, the check is performed only once at startup, making the `OnTick()` function slightly leaner and more efficient on every execution.

🔬 Measurement: The improvement can be verified by code inspection. The ternary operator `(DonchianLookback < 2 ? 2 : DonchianLookback)` has been removed from `OnTick()` and is now executed only once within `OnInit()`, with the result stored in the `gDonchianLookback` global variable.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-12 20:28:29 +07:00
google-labs-jules[bot]
3fe2d901ee
fix(MQL5): Correct off-by-one error in Donchian lookback (#87)
This commit corrects a subtle off-by-one error in the array boundary check for the Donchian channel lookback period.

The original condition `if(donStart + donCount >= needBars)` would incorrectly cause an early exit if the required number of bars for the lookback precisely matched the number of available bars in the array. This prevented valid signals from being processed at the edge of the dataset.

The condition has been changed to `if(donStart + donCount > needBars)`, which is the correct boundary check. This ensures the calculation proceeds when exactly enough data is available and only exits if there is insufficient data, improving the EA's robustness.

This issue was identified during a code review for a separate performance optimization attempt.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-11 02:10:59 +07:00
google-labs-jules[bot]
ce6f9c4ae7
Bolt: Add early exit to OnTick to prevent redundant calculations (#76)
💡 What: Added a lightweight new-bar check using `CopyTime()` at the very beginning of the `OnTick()` function. If a new bar hasn't formed since the last execution, the function exits immediately.

🎯 Why: The original code called the expensive `CopyRates()` function on every single price tick, even though the core logic only needs to run once per bar. This caused significant and unnecessary CPU load, especially during volatile periods.

📊 Impact: This change dramatically reduces the EA's CPU usage. Instead of executing heavy data-copying functions multiple times per second, it now only does so once when a new bar appears. This can lead to a >99% reduction in processing within the `OnTick` handler, improving backtesting speed and reducing the risk of missed ticks in live trading.

🔬 Measurement: The improvement can be verified by observing the EA's processing time in the MetaTrader 5 Strategy Tester's "Profile" tab. Before this change, the `OnTick` function would have a much higher total execution time and frequency of calls. After the change, both metrics will be significantly lower for the same testing period.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-10 05:41:07 +07:00
google-labs-jules[bot]
3bad7e84e8
feat(mql5): cache MTF confirmation to reduce CPU load (#78)
Improves performance by caching the multi-timeframe (MTF) confirmation result.

Previously, the MTF confirmation logic (checking EMA crosses on a lower timeframe) was executed on every price tick. This involved expensive `CopyBuffer` calls, leading to unnecessary CPU usage.

This change introduces a caching mechanism where the MTF result is only recalculated when a new bar forms on the lower timeframe. This drastically reduces redundant computations, resulting in a more efficient Expert Advisor and Indicator, especially in volatile market conditions. The `CopyTime` function is used to efficiently check for a new bar on the `LowerTF`.

A bug in the initial implementation where the `_Symbol` was missing from the `CopyTime` call has been fixed and verified.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-01-10 05:36:08 +07:00
google-labs-jules[bot]
4d34289b02 feat(perf): Cache MTF confirmation to reduce redundant calculations
Implements a caching mechanism for the multi-timeframe (MTF) trend confirmation in `GetMTFDir`.

The trend direction from the lower timeframe is now calculated only when a new bar forms on that timeframe, instead of on every tick of the main chart. The result is cached and returned on subsequent calls until the next lower timeframe bar appears.

This avoids expensive and redundant `CopyBuffer` calls, significantly improving the EA's performance and efficiency, especially when the signal timeframe is much shorter than the confirmation timeframe. Logic was carefully updated to read from the last *completed* bar to prevent any change in trading behavior.
2026-01-07 10:37:51 +00:00
copilot-swe-agent[bot]
f3a56948cb Update WebRequestURL to soloist.ai and add ZOLO plugin integration
Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
2026-01-05 11:37:02 +00:00
google-labs-jules[bot]
ef9c877700 feat: Add web request functionality to Expert Advisor
This change adds the ability for the Expert Advisor to send a web request to a user-defined URL when a trading signal is generated. This allows for integration with external services and websites.

The following changes were made:

- Added `EnableWebRequest` and `WebRequestURL` input parameters to the "Notifications" section of the EA.
- Created a new `SendWebRequest` function that sends a POST request with a JSON payload to the specified URL.
- Modified the `Notify` function to call `SendWebRequest` when a notification is triggered.
- Added a comment to the code to remind the user to add the URL to the MetaTrader 5 terminal's list of allowed URLs.
2026-01-04 20:16:44 +00:00
google-labs-jules[bot]
fd9514b9bd Bolt: Optimize Donchian Channel price lookup
💡 What: Replaced `iHigh()` and `iLow()` function calls with direct array access within the `OnTick()` function for retrieving Donchian Channel price levels.

🎯 Why: The `OnTick()` function is a performance-critical hot path that executes on every price update. The original code made redundant function calls to `iHigh()` and `iLow()` to retrieve price data that was already loaded into the local `rates` array.

📊 Impact: This change reduces unnecessary function call overhead in a high-frequency loop. While a micro-optimization, it leads to a small but meaningful improvement in execution speed and reduces processing time for each tick.

🔬 Measurement: Performance can be verified by profiling the `OnTick()` function's execution time in the MetaTrader 5 Strategy Tester before and after the change. A decrease in the average execution time per tick would confirm the improvement.
2025-12-30 10:33:03 +00:00
google-labs-jules[bot]
31eaf10a0c feat(mql5): Bolt: Use global Ask/Bid in OnTick
Replaces `SymbolInfoDouble` calls with direct `Ask` and `Bid` global variables in the `OnTick` function to improve performance.

**💡 What:** The optimization replaces function calls (`SymbolInfoDouble`) with direct access to pre-defined global variables (`Ask` and `Bid`) for fetching the latest market prices inside the performance-critical `OnTick` function.

**🎯 Why:** The `OnTick` function is executed on every price tick, making it a "hot path." Calling `SymbolInfoDouble` involves function call overhead (stack management, etc.). Using the globally available `Ask` and `Bid` variables is a standard MQL5 optimization that provides a direct, faster way to access the same information.

**📊 Impact:** This change reduces the execution time of each `OnTick` cycle by a small but meaningful amount. In a high-frequency environment, this micro-optimization can lead to a noticeable reduction in CPU usage and faster response times.

**🔬 Measurement:** The performance improvement can be verified by using the MetaTrader 5 Strategy Tester's profiling tools. A backtest run with profiling enabled would show a reduced execution time for the `OnTick` function compared to the previous version.
2025-12-28 19:02:42 +00:00
Cursor Agent
7d3a565d6f Add cached point size for performance
Co-authored-by: genxdbxfx3 <genxdbxfx3@gmail.com>
2025-12-27 20:33:29 +00:00
google-labs-jules[bot]
0bbcba4c14 feat(ea): cache static symbol properties on init
What:
Caches the results of `SymbolInfo...` calls (e.g., tick size, volume step, point value) into global variables once during the Expert Advisor's `OnInit` function. Helper functions and `OnTick` logic are refactored to use these cached values instead of making repeated calls.

Why:
The `OnTick` function is executed frequently, and the `SymbolInfo...` functions involve lookups that are unnecessary to repeat for static data. This repeated lookup adds processing overhead to every tick, which can be significant in volatile markets. Caching these values reduces the per-tick workload, making the EA more efficient.

Impact:
This change is expected to reduce the execution time of the `OnTick` function, leading to faster response times and lower CPU usage. While the exact impact depends on market conditions and broker execution, this is a standard and effective optimization practice in MQL5.

Measurement:
The performance improvement can be verified by profiling the EA's `OnTick` execution time in the MetaTrader 5 Strategy Tester before and after the change. A noticeable reduction in the average execution time per tick is expected.
2025-12-27 19:05:05 +00:00