MQL5 indicator blocker

Fix CopyBuffer errors before trusting the EA signal logic.

Fix MQL5 CopyBuffer and indicator-handle errors by checking OnInit handles, copied counts, buffer indexes, ArraySetAsSeries, and runtime logs before manual retesting.

Common CopyBuffer evidence

CopyBuffer returned -1
CopyBuffer copied 0 values
array out of range
indicator handle is INVALID_HANDLE
signal value stays 0.0

These are data-read and lifecycle failures, not proof that a strategy works or fails. Treat them as software diagnostics before the next manual test.

Debug CopyBuffer runtime failures
Check indicator handles in OnInit and OnDeinit
Guard copied counts before reading buffer indexes
Route opt-in source as CopyBuffer fixer interest
Fix CopyBuffer in MQL5

Audience

For MQL5 builders whose EA compiles but indicator values are empty, stale, inverted, or fail with array out of range around CopyBuffer.

Problem

CopyBuffer issues usually come from treating MQL5 indicators like MQL4 direct calls, recreating handles on every tick, reading indexes that were never copied, or skipping copied-count checks.

Outcome

Workfusionapp keeps the repair path narrow: create handles once, validate copied data, guard every buffer read, then route the code into the free desk with the smallest useful log bundle.

Support path

One problem, one fix path.

Start with the concrete blocker, keep the full EA context attached, then move to a reviewable output.

1. Create handles once

Indicator handles belong in OnInit, checked against INVALID_HANDLE, reused during OnTick, and released in OnDeinit when the EA shuts down.

2. Check copied counts before reading

If the EA reads buffer[2], CopyBuffer must return at least three values. Guard the count before every indexed read instead of assuming data exists.

3. Log signal evidence separately

Print handle status, copied count, buffer values, spread/session gates, and final signal state so signal bugs do not get confused with execution failures.

Workflow

From empty indicator values to one safe buffer read.

The fix is not to guess a different indicator period. The fix is to prove that the handle is valid, CopyBuffer copied enough values, and the EA reads only indexes that exist.

Step 1

Paste the indicator block

Step 2

Check handle creation and release

Step 3

Guard CopyBuffer return counts

Step 4

Retest manually with signal logs

CopyBuffer handoff

Route the indicator failure into the right buffer check.

Open the guide that matches the failed data-read pattern, then run the free desk with handle setup, CopyBuffer call, copied count, buffer indexes, and signal log.

Indicator handle guide

Use this when the issue is handle creation, INVALID_HANDLE, MQL4-to-MQL5 indicator migration, or missing release logic.

Array out of range guide

Use this when CopyBuffer returns fewer values than the EA reads, or when current/previous-bar indexing is unsafe.

Send me the CopyBuffer repair workflow

Opt in only if your MQL5 EA has CopyBuffer, indicator-handle, array-index, or signal-value problems. This captures the CopyBuffer source for conversion measurement.

Intent locked: Paste compiler errors

Choose the workflow you want, then opt in only if you want Workfusionapp updates.

Should I recreate indicator handles on every tick?

No. Create handles once in OnInit, reuse them, check CopyBuffer results, and release handles in OnDeinit.

Does a valid indicator value prove the EA should trade?

No. It only proves the data-read layer works. Signal, risk, and execution checks still need separate review.

Does this require broker credentials?

No. Use code, Strategy Tester or demo logs, handle status, copied counts, and buffer values. Workfusionapp does not need broker login.