How to move objects in screen in real time?

 

Hi,


I started to create an EA to visually draw orders in Metatrader 4 like Tradingview does, but when it comes to dragging objects across the chart I am having difficulties.


I would like to move the items freely as in the EA below (Link), does anyone know the library that was used or has any code example with a similar movement for me to use as a base?


Thanks!

<Link removed>

 
Welinton Dos Reis Goncalves: I started to create an EA to visually draw orders in Metatrader 4 like Tradingview does, but when it comes to dragging objects across the chart I am having difficulties.

I would like to move the items freely as in the EA below (Link), does anyone know the library that was used or has any code example with a similar movement for me to use as a base?

In order to track mouse movement and adjust a graphic object accordingly, you will need to process chart events via the OnChartEvent() event handler. Events of interest for this case will probably be the following:

  • CHARTEVENT_MOUSE_MOVE
  • CHARTEVENT_CLICK
  • CHARTEVENT_OBJECT_CLICK
  • CHARTEVENT_OBJECT_DRAG
Event Handling Functions - Functions - Language Basics - MQL4 Reference
Event Handling Functions - Functions - Language Basics - MQL4 Reference
  • docs.mql4.com
Event Handling Functions - Functions - Language Basics - MQL4 Reference
 

For example code, I found the following CodeBase example which demonstrate using various chart events including mouse movement: https://www.mql5.com/en/code/17875

However, there should probably be other example code in the CodeBase and/or in Articles about this subject. Do a thorough search of you own and research your findings.

ChartEvent Test Example
ChartEvent Test Example
  • www.mql5.com
Test ChartEvent is an example demonstrating the various types of ChartEvent: keyboard keys events, mouse click & move events, custom events. The source code works both in MetaTrader 4 and MetaTrader 5.
 
Welinton Dos Reis Goncalves: Thanks in advance for the help, I tried to put the example of movement I need but the link was deleted. I am sending a video so that I can better visualize my need. Today I can make some objects move together across the chart, but they have a delay in monitoring. In the video we can see a more fluid movement and with real-time response, I don't know if there is another graphic library available, but this is the ultimate goal, to move items together freely across the screen. I'll do some more tests with OnChartEvent, if you know anything else please share!

Please don't answer or post in Portuguese. This is the English forum and you must follow the rules.

Your link in the first post was removed by the moderator because it is against the rules to mention or discuss Market products on the forum.

Irrespective of the video, I had already already clearly understood your requirement in your first post, and so my recommendations remain the same.

Without your coding attempt, we am unable to offer more detailed advice. So if you need further advice, post your code, by using the "</>" icon on the posting toolbar or [Alt-S]. If it is a long file, then attach it with the "+ Attach file" link at the bottom of the posting section.