In this article
After this article, you can
- Separate API function availability from the quality of a data archive.
- Select the version known at decision time and distinguish null from zero.
Terms at hand: Backtesting · Expert Advisor (EA) · Economic Calendar
An EA may download API data on demo yet receive no equivalent responses in the tester. That need not indicate a server outage. Check function availability in the testing environment before examining the archive. Downloading today's value and assigning it to earlier decisions creates a different test. The model below replays explicit versions, distinguishes revisions from unavailable data and makes no external API connection.
Why is a working WebRequest insufficient for backtesting?
MQL5 documentation states that WebRequest cannot execute in Strategy Tester. Adding an endpoint to the terminal's permitted URLs does not change this restriction. Distinguish an unavailable testing function from a network problem, failed authorisation or the response received during ordinary EA operation.
Suppose a rule needs an external economic observation. Do not replace a failed request with zero: zero may be a legitimate value, whereas failure means the input is unavailable. Replacing WebRequest with a file is also insufficient if that file contains revisions unknown at the time of the decision.
Define the required observation, version, value and availability time before connecting signal logic directly to HTTP. Our EA guide separates data, decisions and execution; this article develops the data layer. A different adapter should not silently change what the information means or how missing input affects the strategy.
How do you separate online and offline adapters?
The online adapter handles a provider response. The testing adapter selects a preserved record available at the decision time. Both deliver the same kind of result to the decision logic: a valid value, explicit unavailability or an error. This is our proposed code organisation, not a complete trading robot or a promise of compatibility with every API.
Preserve raw responses separately from test-ready records. Record the source, schema version, retrieval time and evidence for availability. The period an observation describes is not the time it became known. If you know only a vintage date, do not invent a precise release hour. A daily archive cannot by itself establish availability within that day.
FRED describes real-time periods distinguishing information known now from information known previously. This is an example of versioned data, not a universal FX API. A vintage date does not automatically supply an exact UTC publication timestamp. Establish the particular provider's chronology before preparing intraday test input from a date-only record.
In MQL5, FileOpen uses a defined file area, including during testing. A relative path need not point to the ordinary terminal folder. Check opening and reading success. Missing input should produce recognised unavailability, not an empty table treated as complete history.
Which version can an earlier decision use?
Own history of three responses
Assume the fictional observation GDP-model on 1 October 2026. These are not GDP releases or records from an actual endpoint. Every timestamp is UTC. availableAt defines when our model can access the record; it does not determine an order's execution time.
| availableAt | revision | value |
|---|---|---|
| 2026-10-01T12:00:00Z | initial | "1.0" |
| 2026-10-01T13:00:00Z | revised | "1.4" |
| 2026-10-01T14:00:00Z | unavailable | null |
At 12:30 the latest eligible value is 1.0. At 13:30 it is 1.4. At 14:30 the newest eligible record has null, so the result is unavailable. Our model neither falls back to the older 1.4 nor converts the absence into zero.
The version available then, not today
A fictional rule requiring a value above 1.2 would be false at 12:30. Substituting the later 1.4 would reverse that decision even if price data remained identical. This examines information availability, not strategy profitability. The tool selects a record; it does not calculate a trading signal or return.
If a strategy should retain the last known value when new information is unavailable, design that as a separate policy. State the permitted age and reason for using the older record before evaluating results. Our explicit-null variant deliberately does not implement that fallback. Do not add it after seeing a more attractive result and present the rerun as unchanged.
What can you inspect in the local replayer?
Paste a JSON object containing numeric version 1 and an events array. Every event has availableAt, observation, value and revision. availableAt requires YYYY-MM-DDTHH:mm:ssZ without fractional seconds or other offsets. observation and revision are strings. value is decimal-point numerical text or null, without conversion to Number. Limits: 1–200 events and 64 KiB JSON; observation and value up to 128 characters, revision up to 64.
Replay information available at decision time
Our teaching example runs locally in your browser: it does not connect to an account or API, send your entries or save them persistently. Do not enter passwords or personal details.
Enter decisionAt separately using the same UTC format. The model selects an observation's latest version whose availableAt does not exceed that time. Before its first record, no value is available. Two records for the same observation and availability time are ambiguous and rejected, rather than resolved by paste order. The revision label is not a numerical chronological counter.
This exercise works locally on pasted events without downloading releases or using API credentials. It does not verify provider timestamps. Valid JSON is not proof of a genuine archive. If you guess the dates or label all subsequent revisions with the initial release time, a correct selection algorithm reproduces incorrect assumptions. Preserve provenance documentation for any actual dataset used in research.
Tester documentation distinguishes agents' files and environments from the terminal. Use a fixed dataset copy for parallel runs rather than overwriting it with a live response during the study. Record the actual preserved dataset in your run manifest, not just the endpoint name.
Our Python backtesting guide develops time-based joins; the calendar guide addresses release revisions. Data replay does not automatically replay execution: Bid/Ask prices, charges, quantity and server responses remain separate components. Begin by comparing a few decisions without placing trades, before attributing a result difference to the strategy.
What should you do before judging this EA's results?
- State the data contract and separate online from offline adapters. Preserve raw responses, observation definitions and evidence for availability. Mark missing historical versions as a limitation instead of assigning today's endpoint value to an earlier date and treating it as archived knowledge.
- Trace one fictional observation before its initial version, between release and revision, and after explicit unavailability. Compare selected records with the table. Test the exact availability boundary and conflicting timestamps before using the algorithm for a larger study.
- In the tester, confirm the intended file is read and missing data is recognised. Store the dataset version with its report. After explaining discrepancies, check signals, execution and costs separately. Correct replay of inputs does not establish future strategy profitability.
Check your understanding
One short exercise
About 3 min · you can try again
GDP-model has 1.0 available at 12:00 UTC and a 1.4 revision at 13:00. Which value does our model select at 12:30?
- 1.4 because it is the revised value.
- 1.0, the latest available version.
- 0 because the tester cannot use WebRequest.
Check the answer and explanation
1.0, the latest available version.
Correct. The 12:00 record is eligible; a subsequent revision does not change the earlier evaluation's input.
Frequently asked
Will allowing a URL enable WebRequest in the tester?
No. It does not change the restriction documented by MetaQuotes: WebRequest cannot execute in Strategy Tester. Permitted-URL settings apply to appropriate use outside that test. Establish where the program runs and what error occurred. For historical evaluation, prepare a separate adapter replaying preserved data. The file needs supported versions and availability times rather than only the endpoint's current response. A working demo download does not establish a correct offline test or equivalent conditions in the two environments.
Is today's table of historical observations sufficient?
Not necessarily. An observation period and a version's availability time are different information. Today's table may contain revised values for earlier periods. Feeding those into earlier decisions can give the EA knowledge learned only later. Establish version provenance, archive methodology and time precision. If the source provides only a vintage date, do not invent a UTC release hour. Our replayer selects records from the supplied timestamps but cannot detect that a later revision was incorrectly assigned an earlier date.
Does null mean zero or reuse the previous value?
In our model, null means an explicitly unavailable value. After the 14:00 record, the result at 14:30 remains unavailable despite the previous value of 1.4. We neither substitute zero nor automatically fall back. Reusing a last-known value requires a separate policy, including age and the reason for absence, defined before evaluating results. The checker demonstrates one explicit replay convention; it does not choose the best missing-data behaviour for every API, instrument or strategy that might use such information.
Does correct replay validate the whole backtest?
It establishes only version selection under the supplied timestamps and records. Verify dataset provenance, parsing, signal logic and missing-data handling separately. Execution prices, costs, quantities and position state are other parts of the study. Correctly replaying one observation does not establish realistic execution of all trades. Preserve the data version and report together with a log of selected inputs. A sound check helps explain discrepancies but does not establish a strategy's advantage or future profitability in live conditions.
Sources & bibliography
-
MetaQuotes Ltd MQL5 Reference — WebRequest · WebRequest is unavailable in Strategy Tester; permitting a terminal URL does not remove that restriction. www.mql5.com ↗
-
MetaQuotes Ltd MQL5 Reference — FileOpen · File operations within the MQL5 area and relevant testing-agent folder; check opening success. www.mql5.com ↗
-
Federal Reserve Bank of St. Louis FRED API — Real-Time Periods · Distinguishes information known now and in the past; vintage periods are not universal exact release timestamps. fred.stlouisfed.org ↗
-
MetaQuotes Ltd MetaTrader 5 Help — Testing Features · Separate agent environments and file operations in their folders; shared-folder interaction requires an explicit design. www.metatrader5.com ↗
