💡 What: Added a guard at the beginning of the `OnTick()` function to ensure the main logic only runs once per new bar.
🎯 Why: The `OnTick()` function was executing expensive operations like `CopyRates()` on every single price tick. For a bar-based strategy, these calculations only need to happen when a new bar is formed.
📊 Impact: This change dramatically reduces the EA's CPU usage. Instead of running heavy calculations multiple times per second, it now only runs them once per bar, leading to significantly more efficient operation and preventing potential freezes or slowdowns in the trading terminal.
🔬 Measurement: The improvement can be verified by observing the EA's processing time in the MetaTrader 5 Strategy Tester. A before-and-after comparison will show a drastic reduction in the total time taken to process the same historical data period. The number of calls to `OnTick` that perform work will be reduced from thousands or millions to just the number of bars in the test period.
💡 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.
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.
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.
This commit adds documentation for the installation and setup of the following CLI tools:
- Jules CLI
- Cursor CLI
- Firebase CLI
- Docker CLI
- GitHub CLI
The documentation is located in the `docs` directory.
Replaced the manual `HighestHighMql` and `LowestLowMql` loops with the built-in, native MQL5 functions `iHighest` and `iLowest`.
This change improves performance within the `OnTick` handler by leveraging optimized, pre-compiled platform functions instead of slower, scripted iterations. This leads to a more efficient and responsive Expert Advisor.