matrix A(2, 3); matrix B(3, 2); matrix C = A @ B; // Result: Matrix C of size [2,2]矩阵乘法(矩阵 × 向量)
matrix M(2, 3); vector V(3); vector R = M @ V; // Result: Vector R of 2 elements矩阵乘法(向量 x 矩阵)
matrix M(2, 3); vector V(1, 2); vector R = V @ M; // Result: Vector R of 3 elements标量乘法(向量 × 向量)
vector V1(1, 3), V2(1, 3); double r = V1 @ V2; // Result: Scalar
static vector vector::Random( const ulong size, // vector length const double min=0.0, // min value const double max=1.0 // max value ); static matrix matrix::Random( const ulong rows, // number of rows const ulong cols // number of columns const float min=0.0, // min value const float max=1.0 // max value );
MetaTrader 5 iOS 移动应用程序的最新版本引入了一系列便捷的图表功能,并进行了重要的稳定性改进,以获得更流畅的用户体验。
下载最新版本的应用程序,增强您的交易体验:
![]()
| ![]()
|
matrix<complex<T>> matrix<complex<T>>::TransposeConjugate(void) const;该方法返回一个新的共轭变换矩阵,其中原始矩阵的元素被转置并转换为它们的复共轭。
int matrix<T>::CompareEqual(const matrix<T>& mat) const返回值为:
pip install --upgrade MetaTrader5
函数 |
操作 |
---|---|
奇异值分解(SVD),分而治之算法;被认为是其他 SVD 算法中最快的算法(lapack 函数为 GESDD)。 |
|
奇异值分解,QR 算法;被认为是经典的 SVD 算法(lapack 函数为 GESVD)。 |
|
奇异值分解、带枢轴算法的 QR(lapack 函数为 GESVDQ)。 |
|
奇异值分解,分段算法(lapack 函数为 GESVDX)。 |
|
奇异值分解,Jacobi 高级算法(lapack 函数为 GEJSV)。 |
|
奇异值分解,Jacobi 低级算法(lapack 函数为 GESVJ)。在某些情况下,该方法计算小奇异值及其奇异向量的精确度远远高于其他 SVD 程序。 |
|
奇异值分解,双对角矩阵的分而治之算法(lapack 函数为 BDSVDX)。 |
|
奇异值分解,双对角矩阵的分段算法(lapack 函数为 BDSVDX)。 |
|
使用经典算法计算正方形矩阵的特征值和特征向量(lapack 函数为 GEEV)。 |
|
使用分而治之算法计算对称或 Hermitian(复共轭)矩阵的特征值和特征向量(lapack 函数为 SYEVD、HEEVD)。 |
|
基于特征值计算光谱成分相对贡献的方法函数 |
|
利用输入时间序列的频谱成分计算重建和预测数据的方法函数。 |
|
用于计算输入时间序列的重构成分及其贡献的方法函数。 |
|
利用第一个 component_count 组件计算重建时间序列的方法函数。 |
客户端
MQL5
网页端
更新将通过实时更新系统提供。
MetaTrader 5 Android
通过Google Play、华为 AppGallery或下载APK文件更新手机应用程序。
MetaEditor
程序端
MQL5
MetaTrader 5网页端
vector<double/complex> operator[](const int i) const; vector<double/complex> operator[](const ulong i) const;取而代之的是一个具有恒定返回值的方法:
const vector<double/complex> operator[](const ulong i) const;在新版Alglib中,mat[row][col]=x的代码运行方式与旧版不同,因此此次修改将有助于在适当的位置捕捉结果的错误使用。以前,这表示写入一个矩阵。现在,该值被写入一个临时对象向量<double/complex>,记录后会立即销毁。
bool ArrayToFP16(ushort &dst_array[],const float &src_array[],ENUM_FLOAT16_FORMAT fmt); bool ArrayToFP16(ushort &dst_array[],const double &src_array[],ENUM_FLOAT16_FORMAT fmt); bool ArrayToFP8(uchar &dst_array[],const float &src_array[],ENUM_FLOAT8_FORMAT fmt); bool ArrayToFP8(uchar &dst_array[],const double &src_array[],ENUM_FLOAT8_FORMAT fmt); bool ArrayFromFP16(float &dst_array[],const ushort &src_array[],ENUM_FLOAT16_FORMAT fmt); bool ArrayFromFP16(double &dst_array[],const ushort &src_array[],ENUM_FLOAT16_FORMAT fmt); bool ArrayFromFP8(float &dst_array[],const uchar &src_array[],ENUM_FLOAT8_FORMAT fmt); bool ArrayFromFP8(double &dst_array[],const uchar &src_array[],ENUM_FLOAT8_FORMAT fmt);由于16位和8位的实数格式可能不同,因此转换函数中的“fmt”参数必须指示需要处理哪种数字格式。对于16位版本,使用新的枚举NUM_FLOAT16_FORMAT,当前具有以下值:
程序端
MQL5
MetaEditor
Tester
网页端
程序端
MQL5
MetaTrader 5网页端
程序端
MetaTrader 5网页端
程序端
MQL5
//+------------------------------------------------------------------+ //| 脚本程序起始函数 | //+------------------------------------------------------------------+ void OnStart() { complex a=1+1i; complex b=a.Conjugate(); Print(a, " ", b); /* (1,1) (1,-1) */ vectorc va= {0.1+0.1i, 0.2+0.2i, 0.3+0.3i}; vectorc vb=va.Conjugate(); Print(va, " ", vb); /* [(0.1,0.1),(0.2,0.2),(0.3,0.3)] [(0.1,-0.1),(0.2,-0.2),(0.3,-0.3)] */ matrixc ma(2, 3); ma.Row(va, 0); ma.Row(vb, 1); matrixc mb=ma.Conjugate(); Print(ma); Print(mb); /* [[(0.1,0.1),(0.2,0.2),(0.3,0.3)] [(0.1,-0.1),(0.2,-0.2),(0.3,-0.3)]] [[(0.1,-0.1),(0.2,-0.2),(0.3,-0.3)] [(0.1,0.1),(0.2,0.2),(0.3,0.3)]] */ ma=mb.Transpose().Conjugate(); Print(ma); /* [[(0.1,0.1),(0.1,-0.1)] [(0.2,0.2),(0.2,-0.2)] [(0.3,0.3),(0.3,-0.3)]] */ }
从 sys 导入 argv data_path=argv[0] last_index=data_path.rfind("\\")+1 data_path=data_path[0:last_index] 从 sklearn.datasets 导入 load_iris iris_dataset = load_iris() 从 sklearn.model_selection 导入 train_test_split X_train, X_test, y_train, y_test = train_test_split(iris_dataset['data'], iris_dataset['target'], random_state=0) 从 sklearn.neighbors 导入 KNeighborsClassifier knn = KNeighborsClassifier(n_neighbors=1) knn.fit(X_train, y_train) # 转换 为 ONNX格式 从 skl2onnx 导入 convert_sklearn 从 skl2onnx.common.data_types 导入 FloatTensorType initial_type = [('float_input', FloatTensorType([None, 4]))] onx = convert_sklearn(knn, initial_types=initial_type) path = data_path+"iris.onnx" with open(path, "wb") as f: f.write(onx.SerializeToString())在MetaEditor中打开创建的onnx文件:
struct MyMap { long key[]; float value[]; };这里我们使用具有适当类型的动态数组。在这种情况下,我们可以使用固定数组,因为这个模型的Map始终包含3个键+值对。
//--- 声明一个数组来接收来自输出层output_probability的数据 MyMap output_probability[]; ... //--- 模型运行 OnnxRun(model,ONNX_DEBUG_LOGS,float_input,output_label,output_probability);
MetaEditor
程序端
报告分为四个选项卡,每个选项卡都包含汇总信息:
Terminal MetaTrader 5 x64 build 3914 started for MetaQuotes Software Corp.
Terminal Windows 10 build 19045, 20 x Intel Xeon E5-2630 v4 @ 2.20GHz, AVX, 41 / 63 Gb memory, 58 / 280 Gb disk, UAC, GMT+2
VPS主机
MQL5
#define MACRO1 /* #define MACRO2 */ void OnStart() { #ifdef MACRO2 Print( 2 ); #else Print( 1 ); #endif }
void OnStart() { Print("CPU name: ",TerminalInfoString(TERMINAL_CPU_NAME)); Print("CPU cores: ",TerminalInfoInteger(TERMINAL_CPU_CORES)); Print("CPU architecture: ",TerminalInfoString(TERMINAL_CPU_ARCHITECTURE)); Print(""); Print("EX5 architecture: ",__CPU_ARCHITECTURE__); } CPU name: 12th Gen Intel Core i9-12900K CPU cores: 24 CPU architecture: AVX2 + FMA3 EX5 architecture: AVX
extern int X=0; void OnStart() { }
extern int X; void OnStart() { }
extern int X; int Y=X; void OnStart(void) { Print("Y=",Y," X=",X); } int X=_Digits;
将ALGLIB库更新至版本3.19。ALGLIB是一个高性能的数值分析库,专用于数值方法和数据分析算法。
我们修正了现有的库类来使用矩阵和向量,还添加了ALGLIB
3.19的新功能。所有的源代码都经过修改,并采用了单一的设计风格。ALGLIB库的源代码位于<程序端数据目录>\MQL5\Include\Math\Alglib。测试脚本位于MQL5\Scripts\UnitTests\Alglib。
除了库本身之外,测试脚本也进行了更新 - 类的测试数量从62个增加到91个,接口的测试数量从143个增加到152个。因此,MetaTrader 5平台开发人员为交易者提供了更有效的解决方案:
MetaEditor
Tester
MetaTrader 5网页端build 3950
程序端
MQL5
double vector::RegressionMetric( const vector& vector_true, // 真值 const ENUM_REGRESSION_METRIC metric // 指标 ); double matrix::RegressionMetric( const matrix& matrix_true, // 真值 const ENUM_REGRESSION_METRIC metric // 指标 ); vector matrix::RegressionMetric( const matrix& matrix_true, // 真值 const ENUM_REGRESSION_METRIC metric, // 指标 const int axis // 坐标轴 );
vector vector::LinearRegression(); matrix matrix::LinearRegression( ENUM_MATRIX_AXIS axis=AXIS_NONE // 沿其计算回归的轴线 );示例:
vector vector_a; //--- 用价格填写向量 vector_a.CopyRates(_Symbol,_Period,COPY_RATES_CLOSE,1,100); //--- 获得线性回归 vector vector_r=vector_a.LinearRegression();该结果在图形中可视化:
ulong vector::HasNan(); ulong matrix::HasNan();当比较具有NaN值的相应元素对时,Compare和CompareByDigits方法认为这些元素相等,而在通常的浮点数比较中,NaN != NaN。
修改用于操作ONNX(开放神经网络交换)模型的OnnxTypeInfo结构:
struct OnnxTypeInfo { ENUM_ONNX_TYPE type; // 参数类型 OnnxTensorTypeInfo tensor; // 张量描述 OnnxMapTypeInfo map; // 地图描述 OnnxSequenceTypeInfo sequence; // 序列描述 };
使用新子结构在结构中指定数据类型:
struct OnnxTensorTypeInfo { ENUM_ONNX_DATATYPE data_type; // data type in the tensor long dimensions[]; // 元素数量 }; struct OnnxMapTypeInfo { ENUM_ONNX_DATA_TYPE key_type; // key type OnnxTypeInfo type_info; // 值类型 }; struct OnnxSequenceTypeInfo { OnnxTypeInfo type_info; // 序列中的数据类型 };根据OnnxTypeInfo::type(ONNX_TYPE_TENSOR、ONNX_TYPE_MAP或ONNX_TYPE_SEQUENCE),填写相关子结构。
bool vector::CopyIndicatorBuffer(long indicator_handle,ulong buffer_index,ulong start_pos,ulong count); bool vector::CopyIndicatorBuffer(long indicator_handle,ulong buffer_index,datetime start_time,ulong count); bool vector::CopyIndicatorBuffer(long indicator_handle,ulong buffer_index,datetime start_time,datetime stop_time);
MetaEditor
Tester
网页端
MQL5.community
客户端
MQL5
网页端