14
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill terrylica/cc-skills --skill mql5-indicator-patterns- SKILL.md3.7 KB
Overview
This skill provides battle-tested MQL5 indicator development patterns to build reliable, well-behaved MetaTrader 5 indicators. It focuses on buffer management, display scaling, warmup alignment, and robust OnCalculate behavior so indicators render correctly and avoid common runtime drift. The patterns are practical and targeted at production-ready indicators.
How this skill works
The skill documents concrete code patterns and configuration steps that inspect and control indicator state: explicit display scale settings, visible and hidden buffer architecture, forward-indexed arrays, and new-bar detection using static state. It explains how to compute PLOT_DRAW_BEGIN from underlying and own warmup and how OnCalculate should return rates_total to indicate successful updates. The guidance prevents blank displays, rolling-window drift, misaligned plots, and indexing errors.
When to use it
- Creating a custom MQL5 indicator for MetaTrader 5 from scratch
- Fixing a blank or mis-scaled indicator window for small-value plots
- Stopping value drift caused by rolling-window recalculation
- Aligning plot start using correct warmup calculation
- Converting array indexing from series mode to forward-indexed logic
Best practices
- Set INDICATOR_MINIMUM and INDICATOR_MAXIMUM explicitly for small-value ranges
- Use separate visible and hidden buffers: INDICATOR_DATA for plots, INDICATOR_CALCULATIONS for internal state
- Detect new bars with a static last_processed_bar and only reset rolling state on bar change
- Call ArraySetAsSeries(buffer, false) to use forward indexing consistently
- Compute StartCalcPosition = underlying_warmup + own_warmup and set PLOT_DRAW_BEGIN accordingly
- Return rates_total from OnCalculate and only recalc bars from prev_calculated onwards
Example use cases
- A volatility indicator whose values are <1.0 and currently displays a blank chart
- An oscillator that slowly drifts because it recalculates all bars on each tick
- A multi-buffer indicator that needs hidden buffers to track recalculation state
- Porting an indicator that used series arrays to forward-indexed logic for clarity
- Creating a template indicator with correct PLOT_DRAW_BEGIN so plots align with price bars
FAQ
Often the scale is wrong for small-value plots; explicitly set INDICATOR_MINIMUM and INDICATOR_MAXIMUM to a suitable range.
How do I prevent values from drifting over time?
Use a hidden buffer to track recalculation state and detect new bars with a static last_processed_bar so you only reset rolling-window state on bar changes.
What indexing mode should I use for clarity?
Use forward indexing (ArraySetAsSeries(buffer, false)) to avoid reversed indexing bugs and make loops more intuitive.