# MQL5 CopyTicksRange()

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/mql5-copyticksrange, 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.

Copies the ticks of a symbol between two times into an array of MqlTick structures. The oldest tick copied is at index 0.

- Function: `CopyTicksRange()`
- Interface: MQL5
- Group: Bars and ticks
- Status: verified. Source: [mql5.com](https://www.mql5.com/en/docs/series/copyticksrange), checked 2026-10-12.

This is an MQL5 function, not an HTTP endpoint. It has no method, no path and no address to send a request to: it runs inside the MetaTrader 5 terminal, in a program written in MQL5. It is in no OpenAPI file on this site and the request builder does not list it.

## Signature

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

```mql5
int CopyTicksRange(
  const string symbol_name,
  MqlTick& ticks_array[],
  uint flags=COPY_TICKS_ALL,
  ulong from_msc=0,
  ulong to_msc=0
)
```

## Arguments

- `symbol_name` (type const string, required): The symbol.
- `ticks_array` (type MqlTick&[], required): The array of MqlTick that receives the ticks, static or dynamic. The page says a static array that is too small is filled as far as it goes and the error ERR_HISTORY_SMALL_BUFFER, 4407, is raised.
- `flags` (type uint, optional): Which ticks to copy: 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 all of them. Default: COPY_TICKS_ALL.
- `from_msc` (type ulong, optional): The start of the range, in milliseconds since 1 January 1970. Ticks at or after this time are copied. Left out, copying starts from the beginning of the history. Default: 0.
- `to_msc` (type ulong, optional): The end of the range, in milliseconds since 1 January 1970. Ticks at or before this time are copied. Left out, copying runs to the end of the history. Default: 0.

## Return value

- Type: `int`
- What comes back: The number of ticks copied, or -1 on an error. On failure the page points to GetLastError() for 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. It holds no credential and needs none: the program runs inside a terminal that is already logged in to an account. Nothing is entered on this site.

```mql5
void OnStart()
  {
   MqlTick ticks[];
   ulong from=(ulong)D'2026.01.08 12:00'*1000;
   ulong to  =(ulong)D'2026.01.08 13:00'*1000;
   int copied=CopyTicksRange(_Symbol,ticks,COPY_TICKS_ALL,from,to);
   PrintFormat("%d ticks, error %d",copied,GetLastError());
  }
```

## Related MQL5 functions: Bars and ticks

- [CopyRates()](https://openbrokerapi.com/platforms/metatrader-5/functions/mql5-copyrates): Copies historical bars of a symbol and timeframe into an array of MqlRates structures, by start position and count, by start time and count, or between two times.
- [CopyTicks()](https://openbrokerapi.com/platforms/metatrader-5/functions/mql5-copyticks): Copies ticks of a symbol into an array of MqlTick structures, from a time onwards or the most recent ones. The oldest tick copied is at index 0.

## 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: MQL5 CopyTicksRange(). Broker API Hub, https://openbrokerapi.com/platforms/metatrader-5/functions/mql5-copyticksrange, 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.
