Canvas is cool! - page 82

 
Vitaliy Kuznetsov #:

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

I hope that improving the Expert Advisor 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 ...

Look through the whole code (indicator and Expert Advisor) to find out where and why ObjectGetXXX, ObjectFind, ObjectsTotal, ObjectName, etc. are called - they are synchronous and can seriously slow everything down. Try to get rid of them if possible.

Don't forget to call ChartRedraw()!!!! above...

 

Gentlemen moderators, I'm being attributed all sorts of nonsense and I'm not allowed to respond? Amazing!

 
Maxim Kuznetsov #:

Look through the whole code (indicator and EA) to find out where and why ObjectGetXXX, ObjectFind, ObjectsTotal, ObjectName, etc. are called - they are synchronous and can seriously slow down everything. Try to get rid of them if possible.

Don't forget to call ChartRedraw()!!!! above...

You just need to make OnChartEvent() wisely and not react to all events in a row. Or I don't know what is there... And why sit here and think for the guy who won't even condescend to show the code with the problem?

Now I have inserted a loop of 1000000 repetitions of ObjectFind() and ObjectGet() - everything is normal.

 
Dmitry Fedoseev #:

Gentlemen moderators, I'm being attributed all sorts of nonsense and I'm not allowed to respond? Amazing!

You're not the only one who's been subjected to such selectivity.

 
Dmitry Fedoseev #:

You just have to do OnChartEvent() wisely, and not react to all events in a row. Or I don't know what it is.... And why sit here and think for the guy who won't even bother to show the code with the problem?

Now I have inserted a loop of 1000000 repetitions of ObjectFind() and ObjectGet() - everything is normal.

Well, I'll write it for the fourth time, it's not hard for me.

https://www.mql5.com/ru/forum/379526/page9#comment_25865481


If you open the link, you will find an attachment with the code at the bottom of the post. Then you can read the posts, by whom and how the discussion was developed there.

The issue is not specifically in the proposed code (you can write any Expert Advisor with an object yourself), but in a global error that affects all Expert Advisors with objects (with a single exception) when working with the function of chart switching via an indicator.

Nikolay offered his solution, but I have errors with the work of such code, I'm dealing with the problem further.

Новая версия платформы MetaTrader 4 build 1350 - Если у вас проблемы с дешбордами, то придется удалять объекты чарта.
Новая версия платформы MetaTrader 4 build 1350 - Если у вас проблемы с дешбордами, то придется удалять объекты чарта.
  • 2021.11.10
  • www.mql5.com
точнее в очередностях OnInit удалении своих объектов чарта. Тут ремонт терминала не имеет смысла не создавайте объектов по крайней мере до первого OnChartEvent. И удалять объекты пачкой лучше по ChartObjectsDelete
 
Dmitry Fedoseev #:

You just have to do OnChartEvent() wisely, and not react to all events in a row. Or I don't know what it is.... And why sit here and think for the guy who won't even bother to show the code with the problem?

Now I have inserted a loop of 1000000 repetitions of ObjectFind() and ObjectGet() - everything is normal.

I have a vague doubt: have you ever written anything more complicated than a loop?

 
Vitaliy Kuznetsov #:

Well, I'll write for the fourth time, it's no problem for me.

https://www.mql5.com/ru/forum/379526/page9#comment_25865481


If you open the link, you will find an attachment with the code at the bottom of the post. Then you can read the posts, by whom and how the discussion was developed there.

The issue is not specifically in the proposed code (you can write any Expert Advisor with an object yourself), but in a global error that affects all Expert Advisors with objects (with a single exception) when working with the function of chart switching via an indicator.

Nikolay offered his solution, but I have errors with the work of such code, I'm dealing with the problem further.

Here are the changes:

   if(sparam=="Win_Ea_"){ // вот тут надо поцивильней сделать, из класса брать имя... но уж сами как-нибудь 
      if(id == CHARTEVENT_OBJECT_CLICK){
         if(win.BtnClickUP()){
         
            win.Process();
            
            ChartPeriodSet(true);
            
         }
         if(win.BtnClickDN()){
         
            win.Process();
            
            ChartPeriodSet(false);
            
         }
      }
   }
   if(id == CHARTEVENT_MOUSE_MOVE){
      MouseX=(int)lparam;
      MouseY=(int)dparam;
      
   }

I managed to get rid of terrible hangs. And if you press the buttons at a measured pace, everything is fine.

But if you start pounding like a woodpecker, you get hangs again, only they are different and shorter. I don't think

you can't get rid of them. Perhaps it is related to the timeframe construction.

I need to work on the buttons so that there are pressed/unpressed positions and introduce inertia so that the button is not pressed immediately.

A delay of 0.1 second would fix the situation and the user would not notice it.

--

Actually, without an expert you can hammer the buttons at a furious pace....

 

And here we are, I've completely got rid of the hangs.

It may be crooked, but the point is the main thing:

void windows_class::~windows_class(){
   //Canvas.Destroy();
}
int OnDeinit(const int r){
   if(r==REASON_REMOVE){
      Canvas.Destroy();
   }
}

The point is to not delete an object when switching the chart.

We should see what happens there when Destroy()... if it is possible to leave it like that...

 

Hi all !)

I apologise, but if we are talking about mq4, then maybe it can be solved like this :?)

void OnChartEvent(const int     id,
                  const long   &lparam,
                  const double &dparam,
                  const string &sparam)
{
   if(id == CHARTEVENT_CLICK
   || id == CHARTEVENT_CHART_CHANGE)
   {ChartSetSymbolPeriod(0,NULL,0);}
}
 

That's what else can create brakes:

void OnTick(void){
  win.Process();
}

Why?

Reason: