- Types of matrices and vectors
- Creating and initializing matrices and vectors
- Copying matrices, vectors, and arrays
- Copying timeseries to matrices and vectors
- Copying tick history to matrices and vectors
- Evaluation of expressions with matrices and vectors
- Manipulating matrices and vectors
- Products of matrices and vectors
- Transformations (decomposition) of matrices
- Obtaining statistics
- Characteristics of matrices and vectors
- Solving equations
- Machine learning methods
Copying tick history to matrices or vectors
As in the case with bars, you can copy ticks to a vector or matrix. This is done by CopyTicks and CopyTicksRange method overloads. They work on a basis similar to the CopyTicks and CopyTicksRange functions, but they receive data into the caller. These functions will be described in detail in Part 5, in the section about arrays of real ticks in MqlTick structures. Here we will only show the prototypes and mention the main points.
bool matrix<T>::CopyTicks(const string symbol, uint flags, ulong from_msc, uint count)
bool vector<T>::CopyTicks(const string symbol, uint flags, ulong from_msc, uint count)
bool matrix<T>::CopyTicksRange(const string symbol, uint flags, ulong from_msc, ulong to_msc)
bool matrix<T>::CopyTicksRange(const string symbol, uint flags, ulong from_msc, ulong to_msc)
The symbol parameter sets the name of the financial instrument for which the ticks are requested. The tick range can be specified in different ways:
- In CopyTicks, it can be specified as a number of ticks (the count parameter), starting from some moment (from_msc), in milliseconds
- In CopyTicksRange, it can be a range of two points in time (from from_msc to to_msc).
The composition of the copied data about each tick is specified in the flags parameter as a bitmask of values from the ENUM_COPY_TICKS enumeration.
Identifier |
Value |
Description |
---|---|---|
COPY_TICKS_INFO |
1 |
Ticks generated by Bid and/or Ask changes |
COPY_TICKS_TRADE |
2 |
Ticks generated by Last and Volume changes |
COPY_TICKS_ALL |
3 |
All ticks |
COPY_TICKS_TIME_MS |
1 << 8 |
Time in milliseconds |
COPY_TICKS_BID |
1 << 9 |
Bid price |
COPY_TICKS_ASK |
1 << 10 |
Ask price |
COPY_TICKS_LAST |
1 << 11 |
Last price |
COPY_TICKS_VOLUME |
1 << 12 |
Volume |
COPY_TICKS_FLAGS |
1 << 13 |
The first three bits (low byte) determine the set of requested ticks, and the remaining bits (high byte) determine the properties of these ticks.
High-byte flags can only be combined for matrices since only one row with the values of a particular field from all ticks is placed in the vector. Thus, only one bit of the most significant byte should be selected to fill the vector.
When selecting several properties of ticks in the process of filling the matrix, the order of rows in it will correspond to the order of elements in the enumeration. For example, the Bid price will always appear in the row higher (with a lower index) than the row with Ask prices.
An example of working with both, ticks and vectors, will be presented in the section on machine learning.