Discussing the article: "Building Your First Glass-box Model Using Python And MQL5"

 

Check out the new article: Building Your First Glass-box Model Using Python And MQL5.

Machine learning models are difficult to interpret and understanding why our models deviate from our expectations is critical if we want to gain any value from using such advanced techniques. Without comprehensive insight into the inner workings of our model, we might fail to spot bugs that are corrupting our model's performance, we may waste time over engineering features that aren't predictive and in the long run we risk underutilizing the power of these models. Fortunately, there is a sophisticated and well maintained all in one solution that allows us to see exactly what our model is doing underneath the hood.

Glass-box algorithms are machine learning algorithms that are fully transparent and inherently intelligible. They defy conventional wisdom that there is a tradeoff between prediction accuracy and interpretability in Machine Learning because they offer an unparalleled level of accuracy and transparency. This means they are exponentially easier to debug, maintain, and improve upon iteration when compared to their black-box alternatives that we are more familiar with. Black-box models are all machine learning models whose inner workings are complex and not easily interpretable. These models can represent high dimensional and non-linear relationships which aren't easily understood by us as humans.

As a rule of thumb, black-box models should only be used in scenarios where a glass-box model cannot deliver the same level of accuracy. In this article we will build a glass-box model and understand the potential benefits of employing them. We will explore 2 ways of controlling our MetaTrader 5 terminal with our glass-box model:

  1. Legacy Approach: This is the easiest approach possible. We simply connect our glass-box model to our MetaTrader 5 Terminal using the integrated Python library in MetaTrader 5. From there we will build an Expert Advisor in MetaQuotes Language 5 to assist our glass-box model and maximize our effectiveness.
  2. Contemporary Approach: This is the recommended way of integrating Machine Learning models into your expert advisor. We will export our glass-box model to Open Neural Network Exchange format and then load the model directly into our Expert Advisor as a resource allowing us to leverage all the useful features available in MetaTrader 5 and fuse it with the power of our glass-box model.


    Author: Gamuchirai Zororo Ndawana

     

    A great article with lots of novel ideas. I liked the way you are integrating python for MT5. This article is a fundemntal reference to demonstare data manipulation, charting and modelling in python.

     
    amrali #:

    A great article with lots of novel ideas. I liked the way you are integrating python for MT5. This article is a fundemntal reference to demonstare data manipulation, charting and modelling in python.

    Thank you so much for your kind words, I'm happy you enjoyed reading the article. And I look forward to sharing more novel insights with you in the future. 

     

    Awesome thank you , Well explained and clear instructions , Going to see if I can follow your comprehensive instruction, thanks for the ideas .

    Great stuff was able to connect to demo acct (only a subset of symbols there expect that is the demo account ) tried one that was there AUDHKD but stuck in disagreement problem line 204 , 

    at least one array or dtype is required

    ValueError: at least one array or dtype is required

    tried with NZDCNH it seems to work through some iterations but fails in the sklern\multiclass on line 167 with a datahandling 

    debug tells me valueerror in line 204 one array or dtype is required - in may be I need to check my demo environment as I only created it today :) 


    on the default Boom1000 Index the problem is line 100 with date and time.    raise KeyError(key)

    KeyError: 'time' . Possibly an issue as my timezone is New Zealand 

    Out of time today for testing , will try again tomorrow.
     
    linfo2 #:

    Awesome thank you , Well explained and clear instructions , Going to see if I can follow your comprehensive instruction, thanks for the ideas .

    Great stuff was able to connect to demo acct (only a subset of symbols there expect that is the demo account ) tried one that was there AUDHKD but stuck in disagreement problem line 204 , 

    at least one array or dtype is required

    ValueError: at least one array or dtype is required

    tried with NZDCNH it seems to work through some iterations but fails in the sklern\multiclass on line 167 with a datahandling 

    debug tells me valueerror in line 204 one array or dtype is required - in may be I need to check my demo environment as I only created it today :) 


    on the default Boom1000 Index the problem is line 100 with date and time.    raise KeyError(key)

    KeyError: 'time' . Possibly an issue as my timezone is New Zealand 

    Out of time today for testing , will try again tomorrow.

    Hi Linfo, I hope this helps:

    1) The 'time' column was the name my broker gave to a UNIX timestamp that marks each of the rows in the data I fetched. Maybe your broker uses a different name instead, like 'date' is common. Check the dataframe that you get after calling copy_rates_range. The fact that you're getting a "KeyError" thrown, might mean either the dataframe is totally empty or there's no column named 'time' it probably has a different name on your side.

    2) Validate the output from copy_rates_range,from what you've described I think that's where things may be falling apart. Check the column names of the data that's being returned to you after making the call. 

    If these steps don't work let me know. 

     

    Thank you for the prompt feedback and advice . 

    Updating here as it may be useful to others . My issues ;

    1) I set up a new demo account to test this and not all currencies where available to This is resolved by opening the acct and ensuring the currencies you want are active (gold colored)

    2)There was no Boom1000 Index (data) provided to me by the server , it was in the list but I not against my account (ensure you change the default to be something you have access to and that can give a result) . 

    3) For me the interpret results would not show in std python , I could only get working with anaconda installed (It would have been easier if I had installed that first).

     After this hiccup the documentation was clear and helpful,I am still digesting the results so far so have not yet moved on  to the mql5 side

    Thank you again for publishing and I look forward to actually understanding the process better . Regards Neil 

     
    linfo2 #:

    Thank you for the prompt feedback and advice . 

    Updating here as it may be useful to others . My issues ;

    1) I set up a new demo account to test this and not all currencies where available to This is resolved by opening the acct and ensuring the currencies you want are active (gold colored)

    2)There was no Boom1000 Index (data) provided to me by the server , it was in the list but I not against my account (ensure you change the default to be something you have access to and that can give a result) . 

    3) For me the interpret results would not show in std python , I could only get working with anaconda installed (It would have been easier if I had installed that first).

     After this hiccup the documentation was clear and helpful,I am still digesting the results so far so have not yet moved on  to the mql5 side

    Thank you again for publishing and I look forward to actually understanding the process better . Regards Neil 

    I'm glad to see that you're making material progress Neil. 

     

    Surprisingly: the most important phrase for understanding the material is at the very end of the article:

    текущие реализации моделей стеклянного ящика основаны на деревьях решений

     
    Stanislav Korotky # :

    Surprisingly: the most important phrase for understanding the material is at the very end of the article:

    Yes you're right, looking back that information should've been covered in the introduction or the synopsis, your feedback will be applied in future.