Audience
For MQL5 builders whose EA compiles but fails during Strategy Tester, demo, or live observation with array out of range around CopyBuffer, indicator buffers, or bar indexing.
MQL5 runtime blocker
Fix MQL5 array out of range runtime errors by checking CopyBuffer return counts, ArraySize, buffer indexes, bar shifts, and indicator readiness before retesting.
Common array-range evidence
array out of range in Expert.mq5 CopyBuffer copied 1 values, EA reads buffer[2] ArraySize(buffer)=0 bar shift 1 not ready _LastError=4806
These are data-read and indexing failures. They do not prove anything about strategy quality; they prove the EA needs safer buffer guards before the next manual test.
Audience
For MQL5 builders whose EA compiles but fails during Strategy Tester, demo, or live observation with array out of range around CopyBuffer, indicator buffers, or bar indexing.
Problem
Array out of range usually means the EA read an index that was never copied, assumed a current/previous bar existed, or mixed ArraySetAsSeries direction with unsafe buffer access.
Outcome
Workfusionapp keeps the fix narrow: prove the copied count, guard every indexed read, log missing data, and route the code into the free desk with the exact buffer evidence.
Support path
Start with the concrete blocker, keep the full EA context attached, then move to a reviewable output.
If the EA reads buffer[2], CopyBuffer must return at least three values. Checking only for -1 still allows runtime crashes when fewer values were copied.
Use ArraySize and the copied count as gates before reading current, previous, or older bars. Return early with a clear log when the data is not ready.
ArraySetAsSeries changes index meaning. Decide whether [0] is the current bar and make current/previous-bar reads consistent across every buffer.
Workflow
The fix is not to hide the error or remove indicator logic. The fix is to prove that each buffer index exists before the EA reads it, then keep signal and execution evidence separate.
Step 1
Paste the failing buffer block
Step 2
Check CopyBuffer return count
Step 3
Guard the first unsafe index
Step 4
Retest manually with concise logs
Array-index handoff
Open the guide that matches the failed read, then run the free desk with the CopyBuffer call, requested count, copied count, ArraySize, index read, and signal log.
Use this when CopyBuffer returns fewer values than the EA reads, or when current/previous-bar indexing is unsafe.
Use this when the deeper issue is an invalid handle, missing OnInit setup, or MQL4-style indicator migration.
Use this when the EA needs clear copied-count, ArraySize, _LastError, spread, session, and signal-state logs before changing strategy logic.
Send me the array-index repair workflow
Opt in only if your MQL5 EA is blocked by array out of range, unsafe CopyBuffer indexing, ArraySize problems, or missing indicator data. This captures the array-index source for conversion measurement.
Choose the workflow you want, then opt in only if you want Workfusionapp updates.
No. Treat it as a runtime correctness bug. The EA is reading data it has not proven exists.
Not by itself. Request enough values, but also check the copied count and ArraySize before every indexed read.
No. It only fixes one data-read layer. Compile, signal, risk, Strategy Tester, and demo review remain separate checks.