Get ticks from an MqlTick structure into a matrix or a vector within the specified date range. Elements are counted from the past to the present, which means that the tick with index 0 is the oldest one. To analyze a tick, check the flags field which shows what exactly has changed in the tick.
[in] A combination of flags from the ENUM_COPY_TICKS enumeration indicating the contents of the requested data. When copying to a vector, you can specify only one value from the ENUM_COPY_TICKS enumeration, otherwise an error will occur.
[in] A flag defining the type of the requested ticks. COPY_TICKS_INFO means ticks cased by Bid and/or Ask changes, COPY_TICKS_TRADE — ticks with Last and Volume changes, COPY_TICKS_ALL — all ticks. For any type of request, the values of the previous tick are added to the remaining fields of the MqlTick structure.
[in] Time starting from which ticks are requested. Time is specified in milliseconds since 01/01/1970. If the 'from_msc' parameter is not specified, ticks from the beginning of the history are returned. Ticks with the time >= from_msc will be returned.
[in] Time up to which ticks are requested. Time is specified in milliseconds since 01/01/1970. Ticks with the time <= to_msc are returned. If the to_msc parameter is not specified, all ticks up to the history end are returned.
Returns true on success or false if error occurs. GetLastError() can return the following errors:
- ERR_HISTORY_TIMEOUT — timeout for tick synchronization has expired, the function has returned all it had.
- ERR_HISTORY_SMALL_BUFFER — static buffer is too small. Only the amount the array can store has been returned.
- ERR_NOT_ENOUGH_MEMORY — not enough memory to receive historical data from the specified range into a dynamic tick array. Failed to allocate enough memory for the tick array.
- TICK_FLAG_BID — the tick has changed the bid price
- TICK_FLAG_ASK — the tick has changed the ask price
- TICK_FLAG_LAST — the tick has changed the last deal price
- TICK_FLAG_VOLUME — the tick has changed the volume
- TICK_FLAG_BUY — the tick is a result of a buy deal
- TICK_FLAG_SELL — the tick is a result of a sell deal
The CopyTicksRange() method is used to request ticks from exactly the specified range. For example, ticks for a specific day in history. CopyTicks() allows specifying only the start date, for example, to receive all ticks from the beginning of the month up to now.