Discussion of article "Improve Your Trading Charts With Interactive GUI's in MQL5 (Part II): Movable GUI (II)"

 

New article Improve Your Trading Charts With Interactive GUI's in MQL5 (Part II): Movable GUI (II) has been published:

Unlock the potential of dynamic data representation in your trading strategies and utilities with our in-depth guide to creating movable GUIs in MQL5. Delve into the fundamental principles of object-oriented programming and discover how to design and implement single or multiple movable GUIs on the same chart with ease and efficiency.

Let's embark on a journey to create a similar dashboard from scratch, but this time using a .mqh file. We'll borrow pieces of our previous code where necessary. To organize our code files effectively, we'll create a new folder, aptly named "Movable Dashboard MQL5".

Next, we'll generate two new files: the "Movable_Dashboard_MQL5.mq5" file, which will serve as our primary .mq5 file, and the "GUI_Movable.mqh" file to hold the code for making the dashboard movable. Properly naming these files is crucial for managing multiple files with ease.

With these steps, we've replicated what we accomplished in Part 1 with more efficient code. Notice the significant difference in the amount of code used in the main .mq5 file between Part 1 and Part 2. And the best part is, it's only going to get better from here.


Result:

Figure 2. Simple Movable Dashboard


Author: Kailash Bai Mina

 

Hi,

Somehow I missed your second posting; I just saaw it yesterday.  Good Work.  I took your basis and extended it to make the dashBoard more functional.  I added my CreatePael function and copied the additional parameters into your Creat DashBoard to allow setting the background color and boder color and style.  Attached are the screen shot, the mq5 and mqh files.

May I suggest your nest step.  Create a Text class that contains label, button, text box, etc functions.  Users could use the Test class directly, but more importantly, your Moveable DashBoard class could inherit the text class and then each instance would have all the text functions available.  When a specific function is placed on the dashboard, it will be linked to the dashboards movement.  I'm including a GUI header file that I haven't used as an example.  You should probably try to find the latest version or perhaps one already exists in MQL5


Cheers, I'm looking forward to your next article.


Cape Coddah

 
Hi,

Thank you for the article! 

I would like to create multiple "dashboards" dynamically by left clicking on chart. With each click a new dashboard would be created. Could you give me a hint how your code should be modified to achieve this?

Thank you

 
komlos #:
Hi,

Thank you for the article! 

I would like to create multiple "dashboards" dynamically by left clicking on chart. With each click a new dashboard would be created. Could you give me a hint how your code should be modified to achieve this?

Thank you

Hi,

I feel great that you liked my article! Thank you for your feedback.

I don't think you need to modify my code to achieve what you're aiming for, as your goal seems distinct from what my code was initially designed for. However, you can certainly utilize my code to make your dynamically created dashboards movable.

To detect mouse clicks on the chart, you could use the ChartEvent, specifically CHARTEVENT_CLICK. This event will provide the coordinates of the mouse click, allowing you to create a new dashboard at that location. You could then apply my code to make this newly created dashboard movable.

If you want to learn more about ChartEvent, I would recommend referring to the first part of this series, specifically the section titled 'Decoding Chart Events: The Building Blocks of Movable GUI'.

Additionally, I strongly suggest using classes, as they will simplify your task if used correctly. If you're unfamiliar with the concept of classes, you might want to refer to my article 'Understanding the Concept of Classes' for the basics.

Hope this helps!

Improve Your Trading Charts With Interactive GUI's in MQL5 (Part I): Movable GUI (I)
Improve Your Trading Charts With Interactive GUI's in MQL5 (Part I): Movable GUI (I)
  • www.mql5.com
Unleash the power of dynamic data representation in your trading strategies or utilities with our comprehensive guide on creating movable GUI in MQL5. Dive into the core concept of chart events and learn how to design and implement simple and multiple movable GUI on the same chart. This article also explores the process of adding elements to your GUI, enhancing their functionality and aesthetic appeal.
 
komlos #:
Hi,

Thank you for the article! 

I would like to create multiple "dashboards" dynamically by left clicking on chart. With each click a new dashboard would be created. Could you give me a hint how your code should be modified to achieve this?

Thank you

Hi CapeCoddah,

Your feedback truly delights me. The exact purpose of my writings is to inspire readers like you to take the concepts and extend them in your own unique ways. The fact that you've done exactly that reaffirms the utility of my articles.

As for your suggestion regarding the creation of a Text class encompassing label, button, text box, etc., it's interesting to note that my upcoming article actually ventures in a similar direction. I am constructing functional trading dashboard that can execute buy and sell commands, request lot sizes, and yes, it will also be movable with all elements contained within exactly as you suggested.

However, I believe that creating a Text class may not be universally beneficial given the diverse needs of each user. Instead, I encourage readers to create classes tailored to their specific requirements.

Upon reviewing your files, I found it quite coincidental that your GUI closely matches what I have in store for part 3. I'm eager for its imminent publication.

Here's a sneak peek into what's coming up in the next article:


Yes, this is a movable dashboard, complete with all its elements!

Stay tuned for more and thank you again for your active involvement and feedback.

Happy Coding!

 
Kailash Bai Mina #:

Hi CapeCoddah,

Your feedback truly delights me. The exact purpose of my writings is to inspire readers like you to take the concepts and extend them in your own unique ways. The fact that you've done exactly that reaffirms the utility of my articles.

As for your suggestion regarding the creation of a Text class encompassing label, button, text box, etc., it's interesting to note that my upcoming article actually ventures in a similar direction. I am constructing functional trading dashboard that can execute buy and sell commands, request lot sizes, and yes, it will also be movable with all elements contained within exactly as you suggested.

However, I believe that creating a Text class may not be universally beneficial given the diverse needs of each user. Instead, I encourage readers to create classes tailored to their specific requirements.

Upon reviewing your files, I found it quite coincidental that your GUI closely matches what I have in store for part 3. I'm eager for its imminent publication.

Here's a sneak peek into what's coming up in the next article:


Yes, this is a movable dashboard, complete with all its elements!

Stay tuned for more and thank you again for your active involvement and feedback.

Happy Coding!

Kailash Bai Mina #:

Hi CapeCoddah,

Your feedback truly delights me. The exact purpose of my writings is to inspire readers like you to take the concepts and extend them in your own unique ways. The fact that you've done exactly that reaffirms the utility of my articles.

As for your suggestion regarding the creation of a Text class encompassing label, button, text box, etc., it's interesting to note that my upcoming article actually ventures in a similar direction. I am constructing functional trading dashboard that can execute buy and sell commands, request lot sizes, and yes, it will also be movable with all elements contained within exactly as you suggested.

However, I believe that creating a Text class may not be universally beneficial given the diverse needs of each user. Instead, I encourage readers to create classes tailored to their specific requirements.

Upon reviewing your files, I found it quite coincidental that your GUI closely matches what I have in store for part 3. I'm eager for its imminent publication.

Here's a sneak peek into what's coming up in the next article:


Yes, this is a movable dashboard, complete with all its elements!

Stay tuned for more and thank you again for your active involvement and feedback.

Happy Coding!

 

Hi Kailash,


Your preview intrigues me.  It is what my final objective is.  The concept of the Text class is a tool box of functions that are used to create the trading dashboard panels. Your preview illustrates several of the members of my text class: Label,Input Box, Buttons, Panel and perhaps a Text Panel, right now I use buttons. I want to encapsulate the details of producing a Label inside fo a callable Text Class Fuction, CreateLabel(....) so users can make multiple calls to the label function to place different text in different places on the Moveable panel.

I actually envisions multiple but independent sub panels that will together comprise my trading station, e.g. ATR indicators, Crossovers of indicators, trade openings, status of active trades, money management, Stop Loss and Take Profit management, etc, etc.  As I envision  it,the OnInit function will be used to call the development of each panel and the OnTick will provide updating fuctions to the various panels and probably there will be a functions panel which can open and close the on demand panels.

 
CapeCoddah #:

Hi Kailash,


Your preview intrigues me.  It is what my final objective is.  The concept of the Text class is a tool box of functions that are used to create the trading dashboard panels. Your preview illustrates several of the members of my text class: Label,Input Box, Buttons, Panel and perhaps a Text Panel, right now I use buttons. I want to encapsulate the details of producing a Label inside fo a callable Text Class Fuction, CreateLabel(....) so users can make multiple calls to the label function to place different text in different places on the Moveable panel.

I actually envisions multiple but independent sub panels that will together comprise my trading station, e.g. ATR indicators, Crossovers of indicators, trade openings, status of active trades, money management, Stop Loss and Take Profit management, etc, etc.  As I envision  it,the OnInit function will be used to call the development of each panel and the OnTick will provide updating fuctions to the various panels and probably there will be a functions panel which can open and close the on demand panels.

I'm considering creating such a Text Class, likely named 'GUI', to house all the objects, including Rectangle Label, Label, Edit, and Button.


Your idea of creating multiple yet independent subpanels for each task, like indicators and trade management, is precisely my intended outcome for future articles. Although achieving this is not without challenges - such as dealing with z-order, different screen sizes affecting panel sizes, and so on - I am confident we can overcome these hurdles together.


The concept of a panel manager sounds promising as well. We should be able to create that soon."

 
Kailash Bai Mina #:

Hi,

I feel great that you liked my article! Thank you for your feedback.

I don't think you need to modify my code to achieve what you're aiming for, as your goal seems distinct from what my code was initially designed for. However, you can certainly utilize my code to make your dynamically created dashboards movable.

To detect mouse clicks on the chart, you could use the ChartEvent, specifically CHARTEVENT_CLICK. This event will provide the coordinates of the mouse click, allowing you to create a new dashboard at that location. You could then apply my code to make this newly created dashboard movable.

If you want to learn more about ChartEvent, I would recommend referring to the first part of this series, specifically the section titled 'Decoding Chart Events: The Building Blocks of Movable GUI'.

Additionally, I strongly suggest using classes, as they will simplify your task if used correctly. If you're unfamiliar with the concept of classes, you might want to refer to my article 'Understanding the Concept of Classes' for the basics.

Hope this helps!

My problem is that I don't know how I can call the OnEvent function in OnChartEvent on every dynamically created dashboard instance (since every dashboard instance has to handle the event independently as you mention it in the article). The way your code currently works, OnEvent is called on every previously created instance by defining them separately in OnChartEvent in advance. But when creating dashboard instances dynamically you can't just define them in OnChartEvent in advance because they hasn't been created yet...
Thanks
 
komlos #:
My problem is that I don't know how I can call the OnEvent function in OnChartEvent on every dynamically created dashboard instance (since every dashboard instance has to handle the event independently as you mention it in the article). The way your code currently works, OnEvent is called on every previously created instance by defining them separately in OnChartEvent in advance. But when creating dashboard instances dynamically you can't just define them in OnChartEvent in advance because they hasn't been created yet...
Thanks

Oh, I see where you're having difficulty. Let me help you.

I've written an Expert Advisor (EA) named MultiDash exactly like you wanted by slightly modifying my code.

I've attached it below for your reference. Please check it out and don't hesitate to ask if there's anything in my code that you don't understand. I would be happy to help.


Files:
 
Kailash Bai Mina #:

Oh, I see where you're having difficulty. Let me help you.

I've written an Expert Advisor (EA) named MultiDash exactly like you wanted by slightly modifying my code.

I've attached it below for your reference. Please check it out and don't hesitate to ask if there's anything in my code that you don't understand. I would be happy to help.


Wow, thank you, it is very kind of you! I will definitely check it out!