# MT5 Python copy_ticks_range()

Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Educational only: nothing here is advice, and nothing here recommends a broker or a trade.

This is the markdown version of https://openbrokerapi.com/platforms/metatrader-5/functions/python-copy-ticks-range, written from the same records as that page.

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

Returns the ticks for one instrument between two dates.

- Function: `copy_ticks_range()`
- Interface: MetaTrader5 Python package
- Group: Bars and ticks
- Status: verified. Source: [mql5.com](https://www.mql5.com/en/docs/python_metatrader5/mt5copyticksrange_py), checked 2026-10-12.

This is a Python function, not an HTTP endpoint. It has no method, no path and no address to send a request to: the package talks to a MetaTrader 5 terminal running on the same computer. It is in no OpenAPI file on this site and the request builder does not list it.

Note: The page warns that Python builds a datetime in local time while the terminal stores times in UTC, so dates passed to the package should be created in UTC. It adds that the times that come back are in UTC too, and that Python applies the local offset again when it prints them.

## Signature

The form of the call on the vendor's page, with the vendor's comments taken out.

```python
copy_ticks_range(
  symbol,
  date_from,
  date_to,
  flags
)
```

## Arguments

- `symbol` (type not stated, required): The instrument's name. The page's example value is "EURUSD".
- `date_from` (type datetime or int, required): The start of the range. The page says it is given as a datetime object or as a number of seconds since 1 January 1970.
- `date_to` (type datetime or int, required): The end of the range, given the same way.
- `flags` (type not stated, required): Which ticks to return, as a value of the COPY_TICKS enumeration: COPY_TICKS_INFO for ticks that change the bid or ask, COPY_TICKS_TRADE for ticks that change the last price or volume, COPY_TICKS_ALL for both.

## Return value

- Type: `numpy array or None`
- What comes back: One row per tick with the named columns time, bid, ask, last and flags. The flags column combines values of the TICK_FLAG enumeration. On failure the page says it returns None, and that last_error() gives the reason.

## Sample

Written by this site from the signature and arguments recorded on this page. It has not been run against a terminal, a server or an account, and the values in it are placeholders. No credential is typed into it: where one is needed it is read from an environment variable on your own machine. Nothing is entered on this site.

```python
from datetime import datetime, timezone
import MetaTrader5 as mt5

if not mt5.initialize():
    raise SystemExit(f"initialize() failed: {mt5.last_error()}")

start = datetime(2026, 1, 8, 12, tzinfo=timezone.utc)
end = datetime(2026, 1, 8, 13, tzinfo=timezone.utc)
ticks = mt5.copy_ticks_range("EURUSD", start, end, mt5.COPY_TICKS_INFO)
print(0 if ticks is None else len(ticks))

mt5.shutdown()
```

## Related MT5 Python functions: Bars and ticks

- [copy_rates_from()](https://openbrokerapi.com/platforms/metatrader-5/functions/python-copy-rates-from): Returns a number of bars for one instrument and timeframe, counting back from a date.
- [copy_rates_from_pos()](https://openbrokerapi.com/platforms/metatrader-5/functions/python-copy-rates-from-pos): Returns a number of bars for one instrument and timeframe, starting from a bar index where 0 is the bar now forming.
- [copy_rates_range()](https://openbrokerapi.com/platforms/metatrader-5/functions/python-copy-rates-range): Returns the bars for one instrument and timeframe that open between two dates.
- [copy_ticks_from()](https://openbrokerapi.com/platforms/metatrader-5/functions/python-copy-ticks-from): Returns a number of ticks for one instrument, starting from a date.

## More on MetaTrader 5

- [All MetaTrader 5 functions](https://openbrokerapi.com/platforms/metatrader-5/functions): 78 documented here, grouped by what they do.
- [MetaTrader 5 API quickstart](https://openbrokerapi.com/platforms/metatrader-5/quickstart)
- [All MetaTrader 5 error codes](https://openbrokerapi.com/errors/mt5)
- [MetaTrader 5 API page](https://openbrokerapi.com/platforms/metatrader-5): The full record: access, authentication, limits and the source for each.

## Licence and how to cite

The records behind this page are all rights reserved. This file is the page itself, at its own address, in another format. It is not part of the CC BY 4.0 downloads listed at https://openbrokerapi.com/data. Quote from it with a link to the page.

Cite as: MT5 Python copy_ticks_range(). Broker API Hub, https://openbrokerapi.com/platforms/metatrader-5/functions/python-copy-ticks-range, newest check 2026-10-12.

Where you rely on a single figure, cite the source and the checked date printed beside it as well. Where this page and a broker's own documentation differ, the documentation wins.
