Your setup, automated · Demo firstcontact@stratcorealpha.com · DE
All trading software errors

MT5 · code and request checks

MQL5 error 4806: keep missing indicator data out of your signal

My guarded indicator reader compiled with 0 errors, but that proves no working signal on your account.

Rendered native compiler log showing zero errors and zero warnings for the defensive indicator reader.

Arnold Holm · 2026-10-22

What the error means

A trader reported repeated 4806 failures while reading indicator values across multiple currency pairs. The official runtime table names 4806 as requested indicator data not found. That describes missing data at the call. It does not identify one universal repair for every program. I keep missing data out of the trading decision. For this small original example, the intended sample is one completed-bar value from buffer zero of an existing moving-average handle. The code first rejects an invalid handle or fewer than two calculated values. It then requests exactly one value starting at shift one. Only a complete copy with a finite, non-empty sample can update the caller's output. The readiness check is useful but does not guarantee that the next call succeeds. The copy result is checked again. A failed read leaves the caller's output untouched. The caller still has to respect the false result and skip its decision. Treating that untouched old output as a new signal would defeat the whole guard. These choices are specific to this example. A different indicator may expose a different buffer number, require a longer warm-up period or use different empty-value semantics. A multi-symbol program also needs to identify which handle and symbol failed. Keep a bounded retry on a later event rather than adding an endless loop that blocks the program. The compiled helper alone does not implement handle creation, retries or signal generation.

Three code paths to check

  1. 1. A handle exists before the requested values are ready.

    Record the handle, calculated count, requested shift and count at the failure. A handle number alone is not evidence that a sample exists.

  2. 2. The requested buffer does not match the indicator.

    Check the actual indicator interface. This example uses moving-average buffer zero. Do not apply that number blindly to a custom indicator.

  3. 3. A failed copy was turned into an ordinary number.

    Check the returned copy count before reading the array. Keep a missing sample separate from a legitimate zero or a previous value.

A one-value reader that refuses an incomplete copy

I compiled BufferReader.mq5 with native MetaEditor on 22 October 2026. It produced zero errors and zero warnings. Its OnStart only prints a label and never calls TryClosedMA. I did not run the script. The image below renders the actual compiler result. This is a source-level example, not an observed cure for error 4806. There is no reproduced error-to-recovery sequence, indicator output, strategy run or broker request in this proof. Before using it, test the caller's false-result path and the chosen indicator's actual data behaviour on demo.

bool TryClosedMA(const int handle,double &value)
{
 if(handle==INVALID_HANDLE || BarsCalculated(handle)<2) return false;
 double sample[1];
 ResetLastError();
 if(CopyBuffer(handle,0,1,1,sample)!=1) return false;
 if(!MathIsValidNumber(sample[0]) || sample[0]==EMPTY_VALUE) return false;
 value=sample[0];
 return true;
}

Compile-only proof. No reproduced runtime 4806, indicator readiness check, retry sequence, strategy validation or order submission.

How you know it is fixed

Preserve the failing request

Record symbol, timeframe, indicator parameters, handle, buffer number, shift, count and the copy result. Reset the error before the call and capture it immediately after a failure.

Test the no-data branch

On demo, a missing sample must skip the trading decision. The previous output must not become a new signal merely because the read failed.

Your five-minute source check

Find the CopyBuffer call that failed. Compare its requested buffer, shift and count with the indicator interface, then find the branch that prevents use of an incomplete copy.

Your own source

Find the next line to check

Start with the free EA-Check. Your code stays in your browser. It highlights patterns with line numbers; it does not prove the broker accepts an order.

Check my EA locally

Want one small change shown on your own case?

DEMO0: send the problem and try a free compiled demo first. R49: one authorised, reproducible MT4/MT5 defect in readable source up to 500 lines, with three agreed cases. 49 USD fixed. Delivery within 48 hours after source review and funding. The exact case is agreed before funded work.

Send the expected and actual behaviour

Common questions

Does BarsCalculated alone remove error 4806?

No. The subsequent copy can still fail or return an incomplete sample. Check its result as well.

Did this proof reproduce and repair a runtime error?

No. It proves only that this original defensive reader compiles. A real indicator and caller still require runtime tests.

Sources and limits

These public questions explain the error; use your own EA log to check whether the same cause applies.

Trading risk disclosure

Futures and forex trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one's financial security or lifestyle. Only risk capital should be used for trading, and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results.

Hypothetical performance disclosure

Hypothetical performance results have many inherent limitations. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown. There are frequently sharp differences between hypothetical performance results and the actual results subsequently achieved by any particular trading program. Hypothetical results are generally prepared with the benefit of hindsight, do not involve financial risk, and cannot completely account for the impact of financial risk in actual trading. Market conditions, the ability to withstand losses, and adherence to a trading program can all materially affect actual results.

NinjaTrader trademark disclosure

NinjaTrader® is a registered trademark of NinjaTrader Group, LLC. No NinjaTrader company has any affiliation with the owner, developer, or provider of the products or services described herein, or any interest, ownership or otherwise, in any such product or service, or endorses, recommends or approves any such product or service.

Testimonials, when shown, may not represent the experience of other clients and are not a guarantee of future performance or success. Virtual-currency trading carries additional risks. See the CFTC customer advisories. Read the full financial risk disclaimer.

MQL5 error 4806: keep missing indicator data out of your signal