Source code
CopyRates returns less data than requested: what to check
A request for historical bars can return fewer elements than expected while data is being prepared or downloaded. The returned count is part of the function’s result and should guide subsequent processing.
Define the minimum data
List the actual lookback needed by the signal. If the strategy needs a completed sequence of bars, stop that calculation until the sequence is available. A missing bar is not a neutral indicator value.
Inspect symbol and timeframe
Confirm that the requested instrument exists and the timeframe matches the intended logic. Log the requested range and returned count once per meaningful state change, not on every tick indefinitely.
Check ordering explicitly
Know whether your array is indexed as a time series and which element represents the current unfinished bar. Avoid assuming that physical memory order and logical series indexing are the same thing.
Recover rather than busy-wait
Let a later event try again when history becomes available. A tight waiting loop can make the terminal unresponsive. This is a useful first source-code improvement because the change can be tested with a deliberately short history range.
Start with a free editable EA project · Explore MQLume source code
Back to top