Terminal
MQL5
Web Terminal
The update will be available through the Live Update system.
MetaTrader 5 Android
Update your mobile apps through Google Play, Huawei AppGallery or by downloading the APK file.
Terminal
MetaTester
Web Terminal
MetaEditor
Terminal
MQL5
MetaTrader 5 Web Terminal
vector<double/complex> operator[](const int i) const; vector<double/complex> operator[](const ulong i) const;They have been replaced by a single method with a constant return value:
const vector<double/complex> operator[](const ulong i) const;This modification will assist in capturing incorrect use of the result in place as in the new Alglib version, the code mat[row][col]=x operates differently from the old version. Previously, this indicated writing to a matrix. Now, the value is written to a temporary object vector<double/complex>, which is immediately destroyed after recording.
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);Since real number formats for 16 and 8 bits may differ, the "fmt" parameter in the conversion functions must indicate which number format needs to be processed. For 16-bit versions, the new enumeration NUM_FLOAT16_FORMAT is used, which currently has the following values:
Improved display of margin requirements in contract specifications. Now, in addition to ratios and initial parameters for calculations, specifications display the final margin values. If the margin amount depends on the position volume, the corresponding levels will be shown in the dialog.
Terminal
MQL5
MetaEditor
Tester
Web Terminal
Terminal
MQL5
MetaTrader 5 Web Terminal
Terminal
MetaTrader 5 Web Terminal
Terminal
MQL5
//+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ 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)]] */ }
from sys import argv data_path=argv[0] last_index=data_path.rfind("\\")+1 data_path=data_path[0:last_index] from sklearn.datasets import load_iris iris_dataset = load_iris() from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(iris_dataset['data'], iris_dataset['target'], random_state=0) from sklearn.neighbors import KNeighborsClassifier knn = KNeighborsClassifier(n_neighbors=1) knn.fit(X_train, y_train) # Convert into ONNX format from skl2onnx import convert_sklearn from skl2onnx.common.data_types import 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())Open the created onnx file in MetaEditor:
struct MyMap { long key[]; float value[]; };Here we used dynamic arrays with appropriate types. In this case, we can use fixed arrays because the Map for this model always contains 3 key+value pairs.
//--- declare an array to receive data from the output layer output_probability MyMap output_probability[]; ... //--- model running OnnxRun(model,ONNX_DEBUG_LOGS,float_input,output_label,output_probability);
MetaEditor
MetaTrader 5 Web Terminal build 3980
Terminal
The report is divided into four tabs, each containing aggregated information:
New reports allow you to visually evaluate trading results in a variety of aspects by simply clicking on the tabs. Histograms, graphs and diagrams are interactive and provide additional information when hovering the mouse cursor. Our designers have put much effort into making reports as simple and clear as possible. Just give them a try!
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 Hosting
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;
MetaEditor
Tester
Updated user interface translations.
Fixed errors reported in crash logs.
MetaTrader 5 Web Terminal build 3950
Terminal
MQL5
double vector::RegressionMetric( const vector& vector_true, // true values const ENUM_REGRESSION_METRIC metric // metric ); double matrix::RegressionMetric( const matrix& matrix_true, // true values const ENUM_REGRESSION_METRIC metric // metric ); vector matrix::RegressionMetric( const matrix& matrix_true, // true values const ENUM_REGRESSION_METRIC metric, // metric const int axis // axis );
vector vector::LinearRegression(); matrix matrix::LinearRegression( ENUM_MATRIX_AXIS axis=AXIS_NONE // axis along which regression is calculated );Example:
vector vector_a; //--- fill the vector with prices vector_a.CopyRates(_Symbol,_Period,COPY_RATES_CLOSE,1,100); //--- get a linear regression vector vector_r=vector_a.LinearRegression();The results are visualized in the graph:
ulong vector::HasNan(); ulong matrix::HasNan();When comparing the appropriate pair of elements having NaN values, the Compare and CompareByDigits methods consider these elements equal, while in case of a usual comparison of floating-point numbers NaN != NaN.
Modified the OnnxTypeInfo structure which is used for operations with ONNX (Open Neural Network Exchange) models:
struct OnnxTypeInfo { ENUM_ONNX_TYPE type; // parameter type OnnxTensorTypeInfo tensor; // tensor description OnnxMapTypeInfo map; // map description OnnxSequenceTypeInfo sequence; // sequence description };
The data type is specified in the structure using new substructures:
struct OnnxTensorTypeInfo { ENUM_ONNX_DATATYPE data_type; // data type in the tensor long dimensions[]; // number of elements }; struct OnnxMapTypeInfo { ENUM_ONNX_DATA_TYPE key_type; // key type OnnxTypeInfo type_info; // value type }; struct OnnxSequenceTypeInfo { OnnxTypeInfo type_info; // data type in the sequence };Depending on OnnxTypeInfo::type (ONNX_TYPE_TENSOR, ONNX_TYPE_MAP or ONNX_TYPE_SEQUENCE), the relevant substructure is filled.
bool vector<T>::CopyIndicatorBuffer(long indicator_handle,ulong buffer_index,ulong start_pos,ulong count); bool vector<T>::CopyIndicatorBuffer(long indicator_handle,ulong buffer_index,datetime start_time,ulong count); bool vector<T>::CopyIndicatorBuffer(long indicator_handle,ulong buffer_index,datetime start_time,datetime stop_time);
MetaEditor
Tester
Fixed errors reported in crash logs.
Web Terminal
MQL5.community
Terminal
MQL5
Web Terminal
Web Terminal
MQL5
MQL5: Added COPY_TICKS_VERTICAL and COPY_RATES_VERTICAL flags for the CopyTicks, CopyTicksRange and CopyRates methods respectively.
By default, ticks and series are copied to the matrix along the horizontal axis, which means the data is added to the right, at the line end. In trained ONNX model running tasks, such a matrix needs to be transposed in order to feed the input data:
const long ExtOutputShape[] = {1,1}; // model's output shape const long ExtInputShape [] = {1,10,4}; // model's input shape #resource "Python/model.onnx" as uchar ExtModel[]// model as a resource //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ int OnStart(void) { matrix rates; //--- get 10 bars if(!rates.CopyRates("EURUSD",PERIOD_H1,COPY_RATES_OHLC,2,10)) return(-1); //--- input a set of OHLC vectors matrix x_norm=rates.Transpose(); vector m=x_norm.Mean(0); vector s=x_norm.Std(0); matrix mm(10,4); matrix ms(10,4);
By specifying the additional flag COPY_RATES_VERTICAL (COPY_TICKS_VERTICAL for ticks) when calling the method, you can eliminate the extra data transposition operation:
//+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ int OnStart(void) { matrix rates; //--- get 10 bars if(!rates.CopyRates("EURUSD",PERIOD_H1,COPY_RATES_OHLC|COPY_RATES_VERTICAL,2,10)) return(-1); //--- input a set of OHLC vectors
MetaEditor
Terminal
Terminal
MQL5
Compile the project and run it on EURUSD H1 to see the result.
In
addition to the model and the MQL5 code which runs it, the project also
includes the PricePredictionTraining.py Python script. It shows how you
can create an ONNX model yourself. To run the script, install Python on
your computer and the required modules from the prompt line:
#import "mmlib.dll" bool sgemm(uint flags,matrix<float> &C,const matrix<float> &A,const matrix<float> &B,ulong M,ulong N,ulong K,float alpha,float beta); #importC++
extern "C" __declspec(dllexport) bool sgemm(UINT flags,float *C,const float *A,const float *B,UINT64 M,UINT64 N,UINT64 K,float alpha,float beta)In addition to buffers, you should pass matrix and vector sizes for correct processing.
Added new CopySeries function for copying synchronized timeseries from MqlRates into separate arrays.
The CopySeries function allows obtaining only the necessary timeseries into different specified arrays during one call, while all of timeseries data will be synchronized. This means that all values in the resulting arrays at a certain index N will belong to the same bar on the specified Symbol/Timeframe pair. Therefore, there is no need for the programmer to additionally synchronize the received timeseries by the bar opening time.
Unlike CopyRates, which returns the full set of timeseries as an MqlRates array, the CopySeries function allows obtaining specific required timeseries into separate arrays. This can be done by specifying a combination of flags to select the type of timeseries. The order of the arrays passed to the function must match the order of the fields in the MqlRates structure:
struct MqlRates { datetime time; // period beginning time double open; // open price double high; // high price for the period double low; // low price for the period double close; // close price long tick_volume; // tick volume int spread; // spread long real_volume; // exchange volume }
Thus, if you need to get the values of the 'time', 'close' and 'real_volume' timeseries for the last 100 bars of the current Symbol/Timeframe, you should use the following call:
datetime time[]; double close[]; long volume[]; CopySeries(NULL,0,0,100,COPY_RATES_TIME|COPY_RATES_CLOSE|COPY_RATES_VOLUME_REAL,time,close,volume);
The order of the arrays "time, close, volume" must match the order of the fields in the MqlRates structure. The order of values in the rates_mask is ignored. The mask could be as follows:
COPY_RATES_VOLUME_REAL|COPY_RATES_TIME|COPY_RATES_CLOSE
Example
//--- input parameters input datetime InpDateFrom=D'2022.01.01 00:00:00'; input datetime InpDateTo =D'2023.01.01 00:00:00'; input uint InpCount =20; //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart(void) { //--- arrays to get timeseries from the Rates structure double open[]; double close[]; float closef[]; datetime time1[], time2[]; //---request close prices to a double array ResetLastError(); int res1=CopySeries(NULL, PERIOD_CURRENT, 0, InpCount, COPY_RATES_TIME|COPY_RATES_CLOSE, time1, close); PrintFormat("1. CopySeries returns %d values. Error code=%d", res1, GetLastError()); ArrayPrint(close); //--- now also request open prices; use float array for close prices ResetLastError(); int res2=CopySeries(NULL, PERIOD_CURRENT, 0, InpCount, COPY_RATES_TIME|COPY_RATES_CLOSE|COPY_RATES_OPEN, time2, open, closef); PrintFormat("2. CopySeries returns %d values. Error code=%d", res2, GetLastError()); ArrayPrint(closef); //--- compare the received data if((res1==res2) && (time1[0]==time2[0])) { Print(" | Time | Open | Close double | Close float |"); for(int i=0; i<10; i++) { PrintFormat("%d | %s | %.5f | %.5f | %.5f |", i, TimeToString(time1[i]), open[i], close[i], closef[i]); } } /* Result 1. CopySeries returns 0 values. Error code=0 [ 0] 1.06722 1.06733 1.06653 1.06520 1.06573 1.06649 1.06694 1.06675 1.06684 1.06604 [10] 1.06514 1.06557 1.06456 1.06481 1.06414 1.06394 1.06364 1.06386 1.06239 1.06247 2. CopySeries returns 0 values. Error code=0 [ 0] 1.06722 1.06733 1.06653 1.06520 1.06573 1.06649 1.06694 1.06675 1.06684 1.06604 [10] 1.06514 1.06557 1.06456 1.06481 1.06414 1.06394 1.06364 1.06386 1.06239 1.06247 | Time | Open | Close double | Close float | 0 | 2023.03.01 17:00 | 1.06660 | 1.06722 | 1.06722 | 1 | 2023.03.01 18:00 | 1.06722 | 1.06733 | 1.06733 | 2 | 2023.03.01 19:00 | 1.06734 | 1.06653 | 1.06653 | 3 | 2023.03.01 20:00 | 1.06654 | 1.06520 | 1.06520 | 4 | 2023.03.01 21:00 | 1.06520 | 1.06573 | 1.06573 | 5 | 2023.03.01 22:00 | 1.06572 | 1.06649 | 1.06649 | 6 | 2023.03.01 23:00 | 1.06649 | 1.06694 | 1.06694 | 7 | 2023.03.02 00:00 | 1.06683 | 1.06675 | 1.06675 | 8 | 2023.03.02 01:00 | 1.06675 | 1.06684 | 1.06684 | 9 | 2023.03.02 02:00 | 1.06687 | 1.06604 | 1.06604 | */ }
MetaEditor
Tester
MetaTrader 5 Web Terminal build 3620
Terminal
Web Terminal
Web Terminal
Terminal
MQL5
long preferred_workgroup_size_multiple=OpenCL.GetDeviceInfo(0x1067);
void OnStart() { string cpu,os; //--- cpu=TerminalInfoString(TERMINAL_CPU_NAME); os=TerminalInfoString(TERMINAL_OS_VERSION); PrintFormat("CPU: %s, OS: %s",cpu,os); }Result:
MetaEditor
Terminal
MQL5
//--- the first handle parameter is ignored when obtaining the last error code int code = (int)CLGetInfoInteger(0,CL_LAST_ERROR);
//--- get the code of the last OpenCL error int code = (int)CLGetInfoInteger(0,CL_LAST_ERROR); string desc; // to get the text description of the error //--- use the error code to get the text description of the error if(!CLGetInfoString(code,CL_ERROR_DESCRIPTION,desc)) desc = "cannot get OpenCL error description, " + (string)GetLastError(); Print(desc); //--- to get the description of the last OpenCL error without receiving the code, pass CL_LAST_ERROR if(!CLGetInfoString(CL_LAST_ERROR,CL_ERROR_DESCRIPTION, desc)) desc = "cannot get OpenCL error description, " + (string)GetLastError(); Print(desc);The internal enumeration name is passed as the error description. Its explanation can be found at https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_API.html#CL_SUCCESS. For example, the CL_INVALID_KERNEL_ARGS value means "Returned when enqueuing a kernel when some kernel arguments have not been set or are invalid."