Canvas is cool! - page 81

 
Dmitry Fedoseev work with objects in the counsellor's office.

The solution to the problem is in the EA:

Maybe ObjectFind() is not needed.

If you had attached the code with the problem, the problem would have been solved yesterday already

This is not the problem at all.
This problem ( OnChartEvent freezing ) exists only in MT4, and it is not obvious at all. I was tormented for a very long time myself. But it was already discussed in this thread about a year ago.

 
Nikolai Semko #:

that's not the problem at all.
This problem exists only in MT4, and it is not obvious at all. I was tormented myself for a very long time. But it was already discussed in this thread about a year ago.

I don't know what the problem is at all, I just wrote what causes it and how it is solved. But you can continue to suffer...

 
Dmitry Fedoseev #:

And I don't know what the problem is at all, I just wrote what causes it and how it is solved. But you can continue to suffer.

These words should be carved in stone! :))
 
Dmitry Fedoseev #:

And I don't know what the problem is at all, I just wrote what causes it and how it is solved. But you can continue to suffer.

The deunit problem has nothing to do with it. This problem occurs only in MT5. And here we are talking about MT4.

 
Nikolai Semko #:

You are a strange person.
You yourself want others to understand your code and hundreds of lines when asking a question, but you don't even try to penetrate into the answer and look into the code of one hundred lines.

Okay. I'll make life easier.
Translate all the code from OnChartEvent to OnTimer. Set the timer to 30 milliseconds. You will need to enter only global variables (not terminal), which should be updated in OnChartEvent, and reset (which are bool) in OnTimer.
Variables can be
as follows

It wasn't that obvious to me at all. I learnt from the link I gave earlier that the problem is old and its solution was sought even by authors with 10 000+ sales on the market more than once.

And this applies to all MT4 Expert Advisors with objects, which means that a huge number of users have faced this problem. They write to the authors on the market, and they do not know the solution. That is why it was so important to solve this problem.

Looking at the GIF (proof of workability) I am determined to implement this approach in my products. I'll probably sit and experiment and report back tomorrow.
 
Vitaliy Kuznetsov #:

For me it was not so obvious at all. From the link I gave earlier, I learnt that the problem is old and its solution was sought even by authors with 10 000+ sales on the market more than once.

And this applies to all MT4 Expert Advisors with objects, which means that a huge number of users have faced this problem. They write to the authors on the market, and they do not know the solution. That is why it was so important to solve this problem.

Looking at GIF I am determined to implement this approach in my products. I will probably sit, experiment and report back tomorrow.

Perhaps the same thing can be done in the Expert Advisor.
But it works without lags.

 
Nikolai Semko #:

Maybe the same thing can be done in the EA.
But it works without lags.

Firstly, Thank you!

Hmm, it seems to work within the given code. But still conflicts with EAs. For example with this one - https://www.mql5.com/ru/code/35440.

I checked with other EAs as well. I should try to improve the code of the EA. The problem is still relevant.
cm partial closing position
cm partial closing position
  • www.mql5.com
Советник закрывает позиции частями и переводит их в безубыток.
 
Vitaliy Kuznetsov #:

Firstly, Thank you!

Hmm, it seems to work within the given code. But still conflicts with EAs. For example with this one - https://www.mql5.com/ru/code/35440.

I checked with other EAs as well. I should try to improve the code of the EA. It's still a problem.

I don't see any lags.
Yes, you should also adjust the code in the EA so that there are no calculations in OnChartEvent.
The rule is simple:
- global variables (not terminal) of events and coordinates should be filled in OnChartEvent, but do not run functions with cumbersome calculations from it .
- All calling of such functions should be done from the timer according to the event variables,
- after the events are processed, you should remember to reset these events in the timer, so that on the next iteration of the timer you don't run the same thing again.

I repeat - this is a bug of OnChartEvent freezing only in MT4

The funny thing is that if MQ will fix this bug, which is apparently elementary ( OnChartEventfreezes if there are about 10 milliseconds of calculations inside of it) and is fixed so easily with the help of a timer, then many people will notice after recompiling their indicators or Expert Advisors, in which OnChartEvent is actively used, that everything is flying :)))
Or maybe it's an artificial bug to make people switch to MT5 ;))))

 
Nikolai Semko #:

I don't see any lags.
Yes, you should also adjust the code in the EA so that there are no calculations in OnChartEvent .
The rule is simple:
- global variables (not terminal) of events and coordinates should be filled in OnChartEvent, but do not run functions with cumbersome calculations from it .
- All calling of such functions should be done from the timer according to the event variables,
- after the events are processed, you should remember to reset these events in the timer, so that on the next iteration of the timer you don't run the same thing again.

I repeat - this is a bug of OnChartEvent freezing only in MT4

The funny thing is that if MQ will fix this bug, which is apparently elementary ( OnChartEventfreezes if there are about 10 milliseconds of calculations inside of it) and is fixed so easily with the help of a timer, then many people will notice after recompiling their indicators or Expert Advisors, in which OnChartEvent is actively used, that everything is flying :)))
Or maybe it's an artificial bug to make people switch to MT5 ;))))

It turns out that the method of ordinary indicator code improvement cannot solve the conflict with EAs in closed code that use objects.

I hope that improving the EA will globally solve the conflict with all dashboard indicators (which is my task).

I wrote in the MT4 build 1353 thread, maybe the terminal programmers will pay attention.

P.S. I made changes in the owls and something skis did not go ...

 
Vitaliy Kuznetsov #:


P.S. Edited the owls and something skis did not go....

Are you sure there is nothing left in OnChartEvent with loops and calls of other functions?
Measure
with GetMicrosecondCount() the calculation time of what happens in OnTimer (or OnChartEvent ) .

Reason: