MQL5 indicator development patterns. TRIGGERS - MQL5 indicator, OnCalculate, indicator buffers, MetaTrader 5.
View on GitHubFebruary 5, 2026
Select agents to install to:
npx add-skill https://github.com/terrylica/cc-skills/blob/main/plugins/mql5/skills/mql5-indicator-patterns/SKILL.md -a claude-code --skill mql5-indicator-patternsInstallation paths:
.claude/skills/mql5-indicator-patterns/# MQL5 Visual Indicator Patterns Battle-tested patterns for creating custom MQL5 indicators with proper display, buffer management, and real-time updates. ## When to Use This Skill Use this skill when: - Creating custom MQL5 indicators for MetaTrader 5 - Debugging indicator display or buffer issues - Setting up OnCalculate with proper warmup handling - Implementing new bar detection patterns ## Quick Reference ### Essential Patterns **Display Scale** (for small values < 1.0): ```mql5 IndicatorSetDouble(INDICATOR_MINIMUM, 0.0); IndicatorSetDouble(INDICATOR_MAXIMUM, 0.1); ``` **Buffer Setup** (visible + hidden): ```mql5 SetIndexBuffer(0, BufVisible, INDICATOR_DATA); // Visible SetIndexBuffer(1, BufHidden, INDICATOR_CALCULATIONS); // Hidden ``` **New Bar Detection** (prevents drift): ```mql5 static int last_processed_bar = -1; bool is_new_bar = (i > last_processed_bar); ``` **Warmup Calculation**: ```mql5 int StartCalcPosition = underlying_warmup + own_warmup; PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, StartCalcPosition); ``` --- ## Common Pitfalls **Blank Display**: Set explicit scale (see Display Scale reference) **Rolling Window Drift**: Use new bar detection with hidden buffer (see Recalculation reference) **Misaligned Plots**: Calculate correct PLOT_DRAW_BEGIN (see Complete Template reference) **Forward-Indexed Arrays**: Always set `ArraySetAsSeries(buffer, false)` --- ## Key Patterns **For production MQL5 indicators**: 1. Explicit scale for small values (< 1.0 range) 2. Hidden buffers for recalculation tracking 3. New bar detection prevents rolling window drift 4. Static variables maintain state efficiently 5. Proper warmup calculation prevents misalignment 6. Forward indexing for code clarity These patterns solve the most common indicator development issues encountered in real-world MT5 development. --- ## Troubleshooting | Issue | Cause | Solution