Machine learning in trading: theory, models, practice and algo-trading - page 3243

 
blef #:

and still unclear: how onnx-signal will get into this working template?

Through your variant of the body of this function.

Forum on trading, automated trading systems and testing trading strategies

Machine learning in trading: theory, models, practice and algo-trading

fxsaber, 2023.09.13 19:28

// Торговый сигнал.
double SignalONNX( const MqlTick &Tick ) { return(0); }

Each tick comes to the input - the output is ONNX-decision about the trading signal.

A variant of the body of such a function showed above. In the case of ONNX is connected its own model.onnx.


The EA template remains unchanged.

 
fxsaber #:

Through its body variant of this function.


Each tick comes to the input - the output is ONNX-decision about the trading signal.

The variant of the body of such a function is shown above. In the case of ONNX, its own model.onnx is connected.


The EA template remains unchanged.

i.e. the body of this function should implement the functions specified in the MQL5 Help on this page - https://www.mql5.com/ru/docs/onnx?

Документация по MQL5: ONNX модели
Документация по MQL5: ONNX модели
  • www.mql5.com
ONNX модели - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
blef #:

i.e. the body of this function should implement the functions specified in the MQL5 Help on this page - https://www.mql5.com/ru/docs/onnx?

Except for the first three, which are responsible for creating and deleting ONNX session.
 
I see, thanks for the clarification - I'll try to do something about the MoD.
 
blef #:

i.e. the body of this function should implement the functions specified in the MQL5 Help on this page - https://www.mql5.com/ru/docs/onnx?

It is like this.

// Торговый сигнал.
double SignalONNX( const MqlTick &Tick )
{
  struct ONNX
  {
  public:
    const long Handle;
    
    ONNX( const string FileName ) : Handle(::OnnxCreate(FileName, ONNX_DATA_TYPE_DOUBLE)) {}
    ~ONNX() { ::OnnxRelease(this.Handle); }
  } static const Model("model.onnx"); // Подключили модель с автоматическим отключением.
  
  OnnxRun(Model.Handle, ONNX_DATA_TYPE_DOUBLE, ...); // Прогоняем данные через модель, получаем результат.
  
  // .... Обрабатываем результат вычислений.
  
  return(0); // Возвращаем торговый сигнал.
}
 
fxsaber #:

That's about right.


All in all, it's fine.
But why is the value returned by the function double?
 

For some reason it keeps talking about neural networks.

But there is a converter listed here

Microsoft' s ONNXMLToolsallows you to convert models to the ONNX format.

which is able to convert the following models

Conversion to ONNX format (ONNXMLTools)

ONNXMLTools allows you to convert models from various machine learning toolkits to theONNX format.

Installation and usage instructions are available in the ONNXMLToolsrepository on GitHub.

Support

The following toolkits are currently supported:

  • Keras (keras2onnx con verter shell);
  • Tensorflow (tf2onnx transducer shell);
  • scikit-learn (skl2onnx converter shell);
  • Apple Core ML;
  • Spark ML (experimental mode);
  • LightGBM
  • libscm;
  • XGBoost;
  • H2O
  • CatBoost

There are many more NOT neural networks than neural networks in this list

Документация по MQL5: ONNX модели
Документация по MQL5: ONNX модели
  • www.mql5.com
ONNX модели - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Andrey Dik #:

All in all, it's fine.
but why is the value returned by the function double?

Because the final template itself may be more difficult to process the received trading signals than the original one.

It was supposed to discuss the template. Let's pass.

 

In ONNX, the input data are vectors and matrices.

For prediction from a ready-made model, it may be possible to make do with these features (a matrix has one data type, which limits the predictor options), but training an µl model is impossible: any even primitive model has a much larger number of diverse input parameters.

For example, it is impossible to drive RF into a matrix:

randomForest( x, y=NULL, xtest=NULL, ytest=NULL,

ntree=500,

mtry=if (! is.null( y) && ! is.factor(y)) max( floor( ncol( x)/3), 1) else floor( sqrt( ncol( x))),

weights=NULL,

replace=TRUE,

classwt=NULL,

cutoff,

strata,

sampsize = if ( replace) nrow( x) else ceiling(.632*nrow( x)),

nodesize = if (! is.null( y) && ! is.factor( y)) 5 else 1,

maxnodes = NULL,

importance=FALSE,

localImp=FALSE,

nPerm=1,

proximity,

oob.prox=proximity,

norm.votes=TRUE,

do.trace=FALSE,

keep.forest=! is.null( y) && is.null( xtest), c

orr.bias=FALSE, keep.inbag=FALSE, ...)

Therefore, training only in python, testing and other joys, and then conversion for loading into µl and checking in the EA by the tester. It is not clear how and where to prepare predictors for testing in µl, whether to write code in µl, or to turn to python and from it get predictors for prediction...., and even so that they were the same as those on which the model was trained.

 

Why are the strings not supported????

https://www.mql5.com/ru/docs/onnx/onnx_types_autoconversion

Неподдерживаемые типы:

ONNX_DATA_TYPE_BFLOAT16
ONNX_DATA_TYPE_STRING

Don't ask questions like "why do you need strings?

Документация по MQL5: ONNX модели / Автоконвертация данных
Документация по MQL5: ONNX модели / Автоконвертация данных
  • www.mql5.com
Автоконвертация данных - ONNX модели - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
Reason: