agentleFS
kecoma1kecoma1/MQL5-SKILLS/skills/candles-and-series/SKILL.md

candles-and-series

Skill17 starsChanged 7 months agoMITView on GitHub

Use when working with MqlRates arrays, candles, or time series in MQL5 in this workspace. Follow the local convention for treating index 0 as the most recent candle by explicitly enabling series mode.

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 8 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this skill when loading or processing candles in MQL5 with MqlRates[], CopyRates, CopyOpen, CopyHigh, CopyLow, CopyClose, or similar …

    line 8
  2. Very specific:

    When the logic depends on candle 0 being the most recent candle, always call:

    line 12
  3. Distinctive:

    Before trusting candle logic, verify these points:

    line 43
  4. Distinctive:

    when the pattern is recalculated

    line 60
  5. Distinctive:

    when entry conditions are evaluated

    line 61
  6. Distinctive:

    If the pattern depends on closed candles, it can be recalculated on a new bar.

    line 63
  7. Distinctive:

    If the entry depends on price crossing a level, that condition may need to be checked on every tick.

    line 64
  8. Very specific:

    When a pattern depends on candle numbering, the convention must be written explicitly.

    line 68
  9. Distinctive:

    When there is doubt about a candle-pattern calculation, create a separate EA test.

    line 79
  10. Distinctive:

    If a class or function is responsible for calculating a pattern, it should also load the candles inside that same function.

    line 85
  11. Distinctive:

    Do not split that responsibility between the EA and the class, because that can make each place use a different window, a different shift, …

    line 87

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Candles And Series

Use this skill when loading or processing candles in MQL5 with MqlRates[], CopyRates, CopyOpen, CopyHigh, CopyLow, CopyClose, or similar functions.

Rule

When the logic depends on candle 0 being the most recent candle, always call:

ArraySetAsSeries(array, true);

Apply this before reading the array contents.

In this workspace, the default expectation for candle-processing logic is:

  • index 0: most recent candle
  • index 1: previous candle
  • index 2: older candle

Example

MqlRates rates[];
ArraySetAsSeries(rates, true);

int copied = CopyRates(_Symbol, _Period, 0, 3, rates);
if(copied < 3)
   return false;

double current_open = rates[0].open;
double previous_high = rates[1].high;
double older_low = rates[2].low;

Validation

Before trusting candle logic, verify these points:

  1. ArraySetAsSeries(..., true) is applied when the code expects candle 0 to be the latest.
  2. CopyRates(...) loads only the number of candles actually needed for the pattern.
  3. The code does not mix series-style indexing with chronological indexing by mistake.
  4. Conditions that refer to candle 1, 2, or 3 are mapped explicitly to the intended indices.

Closed Candles

For patterns that must be built only from closed candles, do not use CopyRates(..., 0, ...) if the current forming candle must be excluded.

In those cases, start from 1, so rates[0] represents the last closed candle.

Recalculation Vs Entry

Separate these two responsibilities explicitly:

  • when the pattern is recalculated
  • when entry conditions are evaluated

If the pattern depends on closed candles, it can be recalculated on a new bar. If the entry depends on price crossing a level, that condition may need to be checked on every tick.

Candle Numbering

When a pattern depends on candle numbering, the convention must be written explicitly. It is not enough to say ArraySetAsSeries(..., true).

Also state what each index means in that context, for example:

  • rates[0] = last closed candle when using CopyRates(..., 1, ...)
  • rates[1] = previous closed candle
  • rates[2] = third closed candle back

Pattern Debugging

When there is doubt about a candle-pattern calculation, create a separate EA test.

That EA should print times, OHLC values, indices, and pattern results so the calculation can be validated without mixing it with trading logic.

Function Ownership

If a class or function is responsible for calculating a pattern, it should also load the candles inside that same function.

Do not split that responsibility between the EA and the class, because that can make each place use a different window, a different shift, or a different array orientation.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.