mcpField
M
mql5-indicator-patterns

mql5-indicator-patterns

github.com/terrylicaDevelopment2505 installsUpdated today
Repository

About mql5-indicator-patterns

mql5-indicator-patterns is a skill for building and debugging custom indicators in MQL5 for MetaTrader 5. It focuses on display settings, buffer handling, recalculation, and avoiding common plotting errors.

Key features

  1. 01Set display scales for small values
  2. 02Configure visible and hidden buffers
  3. 03Detect new bars and track recalculation
  4. 04Calculate warmup and plot alignment
  5. 05Troubleshoot indicator display and updates

Use cases

  1. 01Build a custom MQL5 indicator
  2. 02Fix blank or misaligned indicator plots
  3. 03Prevent rolling-window drift during recalculation

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/terrylica/cc-skills --skill mql5-indicator-patterns

After installing, type/mql5-indicator-patternsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
buffer-patterns.md
complete-template.md
debugging.md
display-scale.md
evolution-log.md
recalculation.md

Details

From the project README

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):

IndicatorSetDouble(INDICATOR_MINIMUM, 0.0);
IndicatorSetDouble(INDICATOR_MAXIMUM, 0.1);

Buffer Setup (visible + hidden):

SetIndexBuffer(0, BufVisible, INDICATOR_DATA);        // Visible
SetIndexBuffer(1, BufHidden, INDICATOR_CALCULATIONS); // Hidden

New Bar Detection (prevents drift):

static int last_processed_bar = -1;
bool is_new_bar = (i > last_processed_bar);

Warmup Calculation:

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

IssueCauseSolution
Blank indicator windowScale not set for small valuesSet INDICATOR_MINIMUM/MAXIMUM explicitly
Values drifting over timeRolling window not resetUse new bar detection with hidden buffer
Misaligned plot startWrong PLOT_DRAW_BEGINCalculate: underlying_warmup + own_warmup
Reversed array indexingSeries mode enabledCall ArraySetAsSeries(buffer, false)
Buffer values incorrectWrong INDICATOR_DATA typeUse INDICATOR_CALCULATIONS for hidden buffers
Compile error on bufferBuffer count mismatchMatch #property indicator_buffers with SetIndexBuffer
Indicator not updatingOnCalculate return wrongReturn rates_total to signal successful calculation
Performance issuesRecalculating all barsOnly recalculate from prev_calculated onwards

Reference Documentation

For detailed information, see:

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.

Comments

Markdown supported