Skip to main content
skill CX Codex

mql5-indicator-patterns — Claude Code skill: MQL5 indicator patterns

A skill for building MetaTrader 5 indicators: buffer setup, display scale and recalculation patterns that keep the chart from going blank.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add terrylica/cc-skills --skill mql5-indicator-patterns -a claude-code
Open on GitHub

What mql5-indicator-patterns does

The skill bundles battle-tested patterns for custom MQL5 indicators: explicit display scale for small values, visible and hidden buffers, new bar detection, warmup calculation. Inside you get a quick reference with code snippets, a troubleshooting table and links to deeper docs on each topic.

Reach for it when the indicator compiles but the window stays blank, values drift over time, or the plot starts in the wrong place. The troubleshooting table maps symptom to cause: blank window means INDICATOR_MINIMUM/INDICATOR_MAXIMUM were never set, drifting values mean the rolling window is not reset, a shifted plot start means a wrong PLOT_DRAW_BEGIN.

The skill calls itself self-evolving: if an instruction is wrong or parameters have drifted, the file gets fixed right away instead of deferred. Edits only happen for real, reproducible issues. Its tools are limited to Read, Grep, Edit and Write, so it will not build the project or drive the terminal.

What it helps with

  • set display scale for values below 1.0
  • split visible and hidden indicator buffers
  • detect a new bar without rolling window drift
  • compute warmup and align the plot start
  • debug a blank indicator window from the cause table

Example prompts for the agent

  • Help me write an MQL5 indicator with two buffers and a correct OnCalculate
  • My indicator window is blank for values under 1.0 — what should I check?
  • Indicator values drift over time, show me the new bar pattern

How to install mql5-indicator-patterns

1Skills CLI (Vercel)

npx skills add terrylica/cc-skills --skill mql5-indicator-patterns -a claude-code

2Manually: put the files in place

~/.claude/skills/mql5-indicator-patterns/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/mql5-indicator-patterns/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about mql5-indicator-patterns

How do I install mql5-indicator-patterns in Claude?

Run npx skills add terrylica/cc-skills --skill mql5-indicator-patterns -a claude-code. The skill then lives at ~/.claude/skills/mql5-indicator-patterns/SKILL.md.

What does mql5-indicator-patterns do?

It provides patterns for MetaTrader 5 indicator development: scale, buffers, new bar detection, warmup and recalculation. It also ships a table for diagnosing common display failures.

Which tools can the skill use?

Read, Grep, Edit and Write. It reads and edits code, but does not compile the project or run the terminal.

Source text

SKILL.md · MIT
---
name: mql5-indicator-patterns
description: MQL5 indicator development patterns. TRIGGERS - MQL5 indicator, OnCalculate, indicator buffers, MetaTrader 5.
allowed-tools: Read, Grep, Edit, Write
---

# MQL5 Visual Indicator Patterns

Battle-tested patterns for creating custom MQL5 indicators with proper display, buffer management, and real-time updates.

> **Self-Evolving Skill**: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.

## 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                                              |
| ------------------------- | ------------------------------ | ----------------------------------------------------- |
| Blank indicator window    | Scale not set for small values | Set INDICATOR_MINIMUM/MAXIMUM explicitly              |
| Values drifting over time | Rolling window not reset       | Use new bar detection with hidden buffer              |
| Misaligned plot start     | Wrong PLOT_DRAW_BEGIN          | Calculate: underlying_warmup + own_warmup             |
| Reversed array indexing   | Series mode enabled            | Call ArraySetAsSeries(buffer, false)                  |
| Buffer values incorrect   | Wrong INDICATOR_DATA type      | Use INDICATOR_CALCULATIONS for hidden buffers         |
| Compile error on buffer   | Buffer count mismatch          | Match #property indicator_buffers with SetIndexBuffer |
| Indicator not updating    | OnCalculate return wrong       | Return rates_total to signal successful calculation   |
| Performance issues        | Recalculating all bars         | Only recalculate from prev_calculated onwards         |

---

## Reference Documentation

For detailed information, see:

- [Display Scale](./references/display-scale.md) - Fix blank indicator windows for small values
- [Buffer Patterns](./references/buffer-patterns.md) - Visible and hidden buffer architecture
- [Recalculation](./references/recalculation.md) - Bar detection and rolling window state management
- [Complete Template](./references/complete-template.md) - Full working example with all patterns
- [Debugging](./references/debugging.md) - Checklist for troubleshooting display issues


## Post-Execution Reflection

After this skill completes, check before closing:

1. **Did the command succeed?** — If not, fix the instruction or error table that caused the failure.
2. **Did parameters or output change?** — If the underlying tool's interface drifted, update Usage examples and Parameters table to match.
3. **Was a workaround needed?** — If you had to improvise (different flags, extra steps), update this SKILL.md so the next invocation doesn't need the same workaround.

Only update if the issue is real and reproducible — not speculative.

© terrylica · MIT · terrylica/cc-skills

Similar skills

All skills for Programming languages →

From the same set2

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor