MT5 Python error -3: Out of memory (RES_E_NO_MEMORY)
The call couldn't get enough memory, usually because it asked for a huge amount of tick or bar data at once. Ask in smaller pieces.
What it means
You see this code in mt5.last_error() in Python, after a package call returns None or False.
The package or the terminal ran out of memory while handling the call. It shows up most when a single request asks for millions of ticks or bars.
The machine may have plenty of memory overall; the single request is the problem.
Common causes
copy_ticks_rangeover months or years of tick data in one call.- Many large requests held in memory at the same time.
- A machine or virtual machine that is short of memory.
How to fix it
- Split long ranges into days or weeks and process each piece before the next.
- Ask for bars instead of ticks when you don't need every tick.
- Free large arrays you no longer use.
Example in Python:
from datetime import datetime, timedelta
import MetaTrader5 as mt5
start, end = datetime(2026, 1, 1), datetime(2026, 3, 1)
day = start
while day < end:
ticks = mt5.copy_ticks_range("EURUSD", day, day + timedelta(days=1), mt5.COPY_TICKS_ALL)
if ticks is None:
print(day.date(), mt5.last_error())
else:
save(ticks) # your own storage, one day at a time
day += timedelta(days=1) Is it safe to retry?
Yes, with smaller requests.
Could the order have executed?
Not a trade. This normally comes from data calls, not trades.
Without the Python package
With Tickwire your code calls a REST API from any operating system, so this package error doesn't come up. See the MT5 Python API page.
Related codes
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.