Discussion of article "MQL5 Cookbook: Indicator Subwindow Controls - Buttons" - page 5

 
tol64:

Do you agree now? )

To be honest, I don't understand why the indicator should stop tracking mouse movement after disabling the Expert Advisor? Where is the connection between the indicator and the Expert Advisor?
 
C-4:
To be honest, I don't understand why the indicator should stop tracking mouse movement after disabling the Expert Advisor? Where is the connection between the indicator and the Expert Advisor?

That's the point, there may be no connection between them, so each program when unloading must disable what other programs may not need. In this case, if the indicator does not need tracking of mouse movement event, why clog the flow of the event queue?

You may not do it of course, it is not necessary. But if we talk about optimisation, I think it is necessary.

 
tol64:

The point is that there may be no connection between them, so each program must disable what other programs do not need. In this case, if the indicator does not need to track the mouse movement event, why clog the flow of the event queue?

You may not do it of course, it is not necessary. But if we talk about optimisation, I think it is necessary.

Vasiliy is talking, the programme should not mindlessly enable/disable tracking, but:

  • Switch it on only if it is disabled (this is not critical)
  • After completion of work return to the state in which it (tracking) was.

I.e. disabling should only happen if tracking was disabled when the programme was started.

Then any combination of starting/stopping programmes with/without mouse event tracking will work correctly.

 
tol64:

The point is that there may be no connection between them, so each program must disable what other programs do not need. In this case, if the indicator does not need to track the mouse movement event, why clog the flow of the event queue?

You may not do it of course, it is not necessary. But if we talk about optimisation, I think it is necessary.

Aha, i.e. in your example, the Expert Advisor decided that the indicator no longer needs to receive the EVENT_MOVE_MOUSE event and disabled it before its exit. So, on what basis does the Expert Advisor decide what other indicators need and what they don't? Doesn't he take too much on himself?
 
komposter:

Vasily is making a good point, the programme should not mindlessly enable/disable tracking, but:

  • Enable it only if it is disabled (this is not critical)
  • After completion of work, return to the state in which it (tracking) was.
I.e. disabling should be done only if tracking was disabled when the programme was started

So I have it done this way.

The programme, in which tracking is enabled at startup, disables it at unloading. And the programme that remains on the chart and needs tracking checks if it is enabled, and if it is disabled, it enables it.

It is desirable to give your variant on the examples of Expert Advisor and indicator code from my post on the previous page to exclude ambiguity of statements.

 
C-4:
Aha, i.e. in your example the Expert Advisor decided that the indicator no longer needs to receive EVENT_MOVE_MOUSE event and disabled it before its exit. On what basis does the Expert Advisor decide what other indicators need and what they don't? Doesn't he take too much on himself?

The expert decides for himself. But I actually like your variant better. That is, it is more correct. I wrote not about how to do it better, but about the necessity of it. You don't have to flip it. Full stop.

 
tol64:
The expert decides for himself. But I actually like your option better. I wasn't talking about the best way to do it, I was talking about the necessity of it. You don't need to flip it. Full stop.
So, if no one will switch off this event, there is no need to check whether it is switched on every second. In one Expert Advisor you specifically disable the event, and in another you monitor its property every second, while it is easier and safer not to write anything at all.
 
C-4:
Aha, i.e. in your example the Expert Advisor decided that the indicator no longer needs to receive EVENT_MOVE_MOUSE event and disabled it before its exit. On what basis does the Expert Advisor decide what other indicators need and what they don't? Doesn't it take too much on itself?

It is probably assumed that all other programs are arranged on the same principle, and they will switch it on themselves if necessary.

But is it that important to switch off? This on/off switch only applies to one chart. I think it won't be a big deal if you only switch it on and don't switch it off.

Few people would bother with that. So, to avoid problems, only switch it on, but not off. Then again, someone will switch it off. So you can monitor it with a timer and switch it on if necessary, but do not switch it off.

 
C-4:
So if no one is going to switch off this event...
There's no way of knowing.
 
C-4:
So if no one will disable this event, there is no need to check every second whether it is enabled. In one Expert Advisor you specifically disable the event, and in another you monitor its property every second, whereas it is easier and safer not to write anything at all.

Not necessarily every second, there is an alternative on another event (already discussed). Give a better example, please, of how I did it here. ) From the condition that the Expert Advisor needs this event, but the indicator does not. It will be clearer that way.

P.S. Correction. I made a mistake. )) Your variant is not more correct. It doesn't fit at all. So better give an example based on the condition above.