17 March 2023
17 March 2023
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