How to Start with MT5, a summary ! - page 6

 

Something about drawdown -

--------------------

Drawdown in signal - Where can I find the open maximum drawdown of a signal? (good threadwith everything explained).

--------------------

Forum on trading, automated trading systems and testing trading strategies

Is Relative DrawDown terminology identical to Absolute Draw Down ?

Michele Lazzarini, 2014.08.09 02:16

Absolute: compared to initial balance

Maximal: largest drawdown (measured in currency)

Relative: largest relative drawdown (measured in %)
This because you can have an early drawdown big in % but not in currency.
The Maximal can hide a largest drawdown in % happened earlier.

Relative is an index of resistance to drawdowns and can be used to compare different results.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

To assess performances i find useful this expression:

Efficacy = Net Profit / Gross Profit

this can be used combined with Relative Drawdown, to assess the real reliability of a strategy:

Reliability = Efficacy / Relative Drawdown


Forum on trading, automated trading systems and testing trading strategies

Maximum Drawdown

Sergey Golubev, 2016.09.28 08:20

This is what I found:
...

There are many 'drawdowns' in the world:

  • Absolute
  • Maximal
  • Relative
  • Maximum drawdown on equity open trades
  • may be more.

I am not sure which kind of drawdown is used for the signals (I think, it may be 'Maximum drawdown on equity open trades' as maximum possibe drawdown) but you can read the following:

Article: What the Numbers in the Expert Testing Report Mean

Small thread: Is Relative DrawDown terminology identical to Absolute Draw Down ?

Forum on trading, automated trading systems and testing trading strategies

About Drawdown

Sergey Golubev, 2022.02.27 13:09

...
As I know - the traders are using some tools/indicators for MT4 and MT5 to show absolute drawdown on equity open trades,
for example: post

And you can read this article too - What the Numbers in the Expert Testing Report Mean

Forum on trading, automated trading systems and testing trading strategies

Ask about Drawdown

Sergey Golubev, 2016.11.09 08:34

What the Numbers in the Expert Testing Report Mean

  • Absolute drawdown is the difference between the initial deposit and the smalles value of balance within testing:

    AbsoluteDrawDown = InitialDeposit - MinimalBalance

  • Maximal drawdown is the highest difference between one of local upper extremums of the balance graph and the following lower extremums:

    MaximalDrawDown = Max of (Maximal Peak - next Minimal Peak)

    The maximal drawdown percentage shows the ratio between the maximal drawdown and the value of respective local upper extremum:

    MaxDrawDown % = MaxDrawDown / its MaxPeak * 100%
Any expert can be tested on history data. After the expert has been tested, the summarized expert testing results and some key characteristics are displayed in the "Report" tab. Reports allow comparing to each other both various experts and the working results of the same expert with different inputs working. This article explains how to read such reports and to interpret the obtained results properly.



About Drawdown
About Drawdown
  • 2022.02.27
  • www.mql5.com
Hello. I'm backtesting an EA on metatrader...
 

Something new in documentation:
ONNX models in machine learning 

Forum on trading, automated trading systems and testing trading strategies

Machine learning in trading: theory, models, practice and algorithmic trading

Renat Fatkhullin , 2023.02.26 12:55

Beta version 3584 is available with ONNX support.

Need Windows 10 build 1809 and newer, preferably Windows 11 with all updates.


Forum on trading, automated trading systems and testing trading strategies

Machine learning in trading: theory, models, practice and algorithmic trading

Renat Fatkhullin , 2023.02.26 13:06

For the regular ONNX Runtime from Microsoft, the minimum version of Windows 10 build 1809 is declared.

And in C:\Windows\System32\onnxruntime.dll there is a very old version 1.10. Currently desired version is 1.14

We will write step by step articles/instructions on how to use ONNX features.


Forum on trading, automated trading systems and testing trading strategies

Machine learning in trading: theory, models, practice and algorithmic trading

Renat Fatkhullin , 2023.02.26 18:04

They will be available in the market, in the tester too, including Cloud Network.

ONNX Runtume will be rewritten and redesigned to not depend on outdated system libraries.

ONNX files are easily included in projects, encrypted and compressed inside EX5 files. Pure robots are obtained from one file.



Scheme of work:

  1. Train the model on the side, for example in Python
  2. Convert it to onnx
  3. Include in the robot and use (training is not available, only inference)

-------------------------------

In MetaEditor -



public ONNX project

Forum on trading, automated trading systems and testing trading strategies

Machine learning in trading: theory, models, practice and algorithmic trading

Renat Fatkhullin , 2023.02.26 22:22

For an example, you can see the public project ONNX.Price.Prediction in the general projects section of MetaEditor.

Forum on trading, automated trading systems and testing trading strategies

Machine learning in trading: theory, models, practice and algorithmic trading

Renat Fatkhullin , 2023.02.27 12:00

Now available:



Inside, the simplest model training in Python with the generation of model.onnx, Python inversion and inference in MQL5.

...


Documentation on MQL5: ONNX models
Documentation on MQL5: ONNX models
  • www.mql5.com
ONNX models - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Some more about ONNX ( ONNX models in machine learning ) -
Part #1. How to test ONNX models:

Forum on trading, automated trading systems and testing trading strategies

Machine learning in trading: theory, models, practice and algorithmic trading

Renat Fatkhullin , 2023.02.28 21:32

Released beta 3589, on which you can test the ONNX models.

Step by step:

  1. Update to 3589 via Help -> Check Desktop Updates -> Latest Beta Version

  2. Activate MQL5 Storage by specifying the correct MQL5 login (not email) in case-sensitive form:






  3. Who has a corrupted config and MQL5 Storage does not work, open the explorer through File -> Open Data Folder, go to the MQL5 directory and delete the following files:


    Then go to step 2

  4. Join the ONNX.Price.Prediction project from the context menu with the Join command



  5. Open the Navigator, open the Shared Projects section and call Update from Storage on the ONNX.Price.Prediction project from the context menu:



    The project will be downloaded from MQL5 Storage (Subversion).

  6. Open the project and click on ONNX.Price.Prediction.mqproj - this is the project file



  7. Copy the project and run it on EURUSD, H1

  8. Get the result:
    2023.02 . 28 21 : 54 : 43.316 Scripts script ONNX.Price.Prediction (EURUSD,H1) loaded successfully
    2023.02 . 28 21 : 54 : 43.348 ONNX    initialized [API version 1.14 . 0 ]
    
    in the Experts log: the last two lines are important, and the rest are specially included debug logs by the ONNX_DEBUG_LOGS flag
    
    2023.02 . 28 22 : 11 : 53.441 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Creating and using per session threadpools since use_per_session_threads_ is true
    2023.02 . 28 22 : 11 : 53.441 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Dynamic block base set to 0
    2023.02 . 28 22 : 11 : 53.442 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Initializing session.
    2023.02 . 28 22 : 11 : 53.442 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Adding default CPU execution provider.
    2023.02 . 28 22 : 11 : 53.442 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Total shared scalar initializer count: 0
    2023.02 . 28 22 : 11 : 53.443 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Total fused reshape node count: 0
    2023.02 . 28 22 : 11 : 53.443 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Total shared scalar initializer count: 0
    2023.02 . 28 22 : 11 : 53.443 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Total fused reshape node count: 0
    2023.02 . 28 22 : 11 : 53.444 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Use DeviceBasedPartition as default
    2023.02 . 28 22 : 11 : 53.444 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Saving initialized tensors.
    2023.02 . 28 22 : 11 : 53.444 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Done saving initialized tensors
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Session successfully initialized.
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Number of streams: 1
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: Begin execution
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 0
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: ort value 1 released
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 1
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: ort value 2 released
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 3
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: ort value 6 released
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 4
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: ort value 8 released
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 5
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: ort value 9 released
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 6
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 7
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 2
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: ort value 3 released
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: ort value 11 released
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 8
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 9
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: ort value 16 released
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 10
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 11
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: ort value 22 released
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 12
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: ort value 25 released
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 13
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: ort value 27 released
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 27
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 17
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 18
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: ort value 28 released
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 28
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: ort value 30 released
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       ONNX: stream 0 launch kernel with idx 26
    
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       [- 1.5921557 ]
    2023.02 . 28 22 : 11 : 53.445 ONNX.Price.Prediction (EURUSD,H1)       predicted 1.0591759612759748
    
  9. If it does not work, then either the old version of ONNX Runtime or it is missing

    In this case, download the ONNX Runtime 1.14 archive signed by Microsoft, expand it to the root directory of the terminal next to terminal64.exe and restart the terminal:

The project immediately attached the simplest model.onnx trained for the sake of an example, so that you can see the demo.



To train the model yourself, you need to use the Python scripts included in the project:

  1. Install Python 3 (e.g. Python 3.10) and deliver/upgrade packages:
    python.exe -m pip install --upgrade pip
    pip install --upgrade tensorflow
    pip install --upgrade pandas
    pip install --upgrade scikit-learn
    pip install --upgrade matplotlib
    pip install --upgrade tqdm
    pip install --upgrade metatrader5
    pip install --upgrade onnx== 1.12
    pip install --upgrade tf2onnx
    The onnx package with version 1.12 specified so as not to conflict with the requirements of tensorflow.

  2. Start MetaEditor and make sure Python is recognized in Tools -> Options -> Compilers:



    If necessary, specify the path yourself if the editor cannot determine it yourself.

  3. The trading terminal must be connected to a server where there is EURUSD (for example, MetaQuotes-Demo)

    Make sure that Python integration is enabled in the terminal settings. If it was disabled, then enable and restart the terminal:




  4. Navigate to the ONNX.Price.Prediction project in the navigator and open the file PricePredictionTraning.py


  5. Run the script to compile, which for a Python script means run.

    The script using the MetaTrader5 package will contact the terminal (if it is turned off, it will start automatically) and start training on EURUSD, H1:


    Upon completion, the Journal Editor will:
     2023.02 . 28 22 : 24 : 16.876 Python   107 / 107 [==============================] - 0 s 1 ms/step - loss: 1.9167 - mae: 0.8553
    2023.02 . 28 22 : 24 : 16.876 Python  test_loss= 1.917
    2023.02 . 28 22 : 24 : 16.876 Python  test_mae= 0.855
    2023.02 . 28 22 : 24 : 17.179 Python  saved model to C:\Users\sys\AppData\Roaming\MetaQuotes\Terminal\ 8 D1E0A7047FFD62A8C00B09AEC1F3004\MQL5\Shared Projects\ONNX.Price.Prediction\Python\model.onnx
    2023.02 . 28 22 : 24 : 17.291 Storage modify MQL5\Shared Projects\ONNX.Price.Prediction\Python\model.onnx to base
    
    The new model.onnx will be saved/updated in the project. She can already use it.

  6. Run the PricePrediction.py script to make sure the model works:
     2023.02 . 28 22 : 27 : 46.078 Python  data path to load onnx model C:\Users\sys\AppData\Roaming\MetaQuotes\Terminal\ 8 D1E0A7047FFD62A8C00B09AEC1F3004\MQL5\Shared Projects\ONNX.Price.Prediction\Python\
    2023.02 . 28 22 : 27 : 46.078 Python  [[[ 1.061412 1.062328 1.060358 1.061169 ]]]
    2023.02 . 28 22 : 27 : 46.078 Python  [[[ 0.00105361 0.00119785 0.00074662 0.00125179 ]]]
    2023.02 . 28 22 : 27 : 46.078 Python  [[[ 0.18792516    0.17698306    0.01607251 - 0.45455042 ]
    2023.02 . 28 22 : 27 : 46.078 Python    [- 0.77068297 - 0.50757406    0.2839477    0.36827372 ]
    2023.02 . 28 22 : 27 : 46.078 Python    [ 0.21639867 - 0.3823502    0.48485409 - 0.19891574 ]
    2023.02 . 28 22 : 27 : 46.078 Python    [- 0.46696554 - 0.31556414    0.33752274    0.48011389 ]
    2023.02 . 28 22 : 27 : 46.078 Python    [ 0.3302927    0.7196198    1.36884221    1.56656129 ]
    2023.02 . 28 22 : 27 : 46.078 Python    [ 1.63058293    1.46261473    1.39562973    1.74231014 ]
    2023.02 . 28 22 : 27 : 46.078 Python    [ 1.82040632    1.84663458 - 0.26519644 - 0.52644768 ]
    2023.02 . 28 22 : 27 : 46.078 Python    [- 0.84661232 - 0.50757406 - 0.45270907 - 0.86995678 ]
    2023.02 . 28 22 : 27 : 46.078 Python    [- 1.27371495 - 1.11699687 - 1.10900328 - 0.48650476 ]
    2023.02 . 28 22 : 27 : 46.078 Python    [- 0.82762998 - 1.37579285 - 2.0599602   - 1.62088366 ]]]
    2023.02 . 28 22 : 27 : 46.094 Python  [[- 1.6349795 ]]
    2023.02 . 28 22 : 27 : 46.094 Python  predict:  [ 1.05912 ]
    
  7. The test case worked!


This is a specially crafted example to demonstrate both training and running models.

You can convert your own TensorFlow models to ONNX format using the onnx and tf2onnx python packages:

import tf2onnx
...
onnx_model = tf2onnx.convert.from_keras(model, output_path=output_path)

ps: use the latest version of the project, since the function prototypes have changed in the old version.

Documentation on MQL5: ONNX models
Documentation on MQL5: ONNX models
  • www.mql5.com
ONNX models - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

More to follow ( ONNX models in machine learning ) -
Part #2. More details on how to install and convert:

Forum on trading, automated trading systems and testing trading strategies

Machine learning in trading: theory, models, practice and algorithmic trading

Renat Fatkhullin , 2023.03.01 16:33

https://learn.microsoft.com/en-us/windows/ai/windows-ml/onnxmltools

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

Installation and usage instructions are available in the ONNXMLTools GitHub repository .

Support

The following toolkits are currently supported:

Pytorch also has a built-in ONNX exporter. See here for more information.


Documentation on MQL5: ONNX models
Documentation on MQL5: ONNX models
  • www.mql5.com
ONNX models - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Documentation on MQL5: ONNX models
Documentation on MQL5: ONNX models
  • www.mql5.com
ONNX models - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
More to follow ( ONNX models in machine learning ) -
Part #4. no longer requires third-party ONNX Runtime libraries :


Forum on trading, automated trading systems and testing trading strategies

Machine learning in trading: theory, models, practice and algorithmic trading

Renat Fatkhullin , 2023.03.03 13:54

The terminal no longer requires third-party ONNX Runtime libraries.

Now onnx models can be driven on any platform where the terminal and the tester are launched . Will be available in the next beta.


Documentation on MQL5: ONNX models
Documentation on MQL5: ONNX models
  • www.mql5.com
ONNX models - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Test version of MQL5 Copilot in beta 3647

Test version of MQL5 Copilot in beta 3647 -
https://www.mql5.com/ru/forum/444170
--------------
MetaEditor, Open AI and ChatGPT

MetaEditor, Open AI and ChatGPT
MetaEditor, Open AI and ChatGPT
  • 2023.03.24
  • www.mql5.com
Forum on trading, automated trading systems and testing trading strategies Test version of MQL5 Copilot in beta 3647 Renat Fatkhullin , 2023.03...
 
Information about the ONNX model's inputs and outputs
Information about the ONNX model's inputs and outputs
  • www.mql5.com
The script obtains information about the number, types and sizes of input and output tensors in an ONNX model
 

Learning ONNX for trading

Forum on trading, automated trading systems and testing trading strategies

Learning ONNX for trading

MetaQuotes , 2023.03.30 17:44

1. ONNX Runtime



This article talks about the Open Neural Network Exchange (ONNX) project , which is an open format for presenting traditional and deep learning models. It also describes ONNX Runtime, a high-performance engine for running these models.

ONNX Runtime is fully compliant with the operators defined in the ONNX specification and runs on both CPU and GPU on many platforms including Linux, Windows and Mac.

Provides a step-by-step guide to converting, loading, and running a model using ONNX Runtime in Azure ML and demonstrates its potential benefits, including improved performance and prediction performance for various models.

It is also encouraged to try ONNX and contribute to the growing ONNX community.


Learning ONNX for trading
Learning ONNX for trading
  • 2023.03.31
  • www.mql5.com
We have added support for ONNX models in MQL5 since we believe this is the future...
Reason: