Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1784

 
Mihail Matkovskij #:

And seriously, ChartRedraw is called more than 24 times per second...

And ObjectCreate! The horror... (added)

ChartRedraw is fine. But the OBjestCreator may be loading if the line is created while the button is not pressed.

UPD
Yes it does...

UPD
Although no, it doesn't:

Print(ObjectCreate(0,"H Line",OBJ_HLINE,window,dt,price));
...
2021.12.03 23:15:50.987    USDCHF,M1: false
2021.12.03 23:15:50.977    USDCHF,M1: false
2021.12.03 23:15:50.977    USDCHF,M1: false
2021.12.03 23:15:50.967    USDCHF,M1: false
2021.12.03 23:15:50.957    USDCHF,M1: false
2021.12.03 23:15:50.957    USDCHF,M1: false
2021.12.03 23:15:50.927    USDCHF,M1: false
2021.12.03 23:15:50.907    USDCHF,M1: false
2021.12.03 23:15:50.887    USDCHF,M1: false
2021.12.03 23:15:50.887    USDCHF,M1: false
2021.12.03 23:15:50.467    USDCHF,M1: false
2021.12.03 23:15:50.417    USDCHF,M1: false
2021.12.03 23:15:50.417    USDCHF,M1: false
2021.12.03 23:15:50.417    USDCHF,M1: true
 
Nerd Trader #:
ChartRedraw is not a problem. But ObjestCreate might be loading, if the line is created until the button is released.

Yes, create it at startup and delete it at application shutdown. And useObjectSetInteger andObjectSetDouble functions to move it. How hard to understand...

 
Mihail Matkovskij #:

Yes, create it at startup and delete it at application shutdown. And useObjectSetInteger andObjectSetDouble functions to move it. How hard to understand...

How hard to understand that I need to create only after pressing the button and delete after releasing it.
 
Nerd Trader #:

UPD
Yes it does...

UPD
Although no, it doesn't:

One way or another, your CPU will blow up at such a programmer... :)

 
Nerd Trader #:
How hard is it to understand that I only need to create when the button is pressed and delete when the button is released.

You can hide from the chart and then show. How to properly hide an object and show it, it's been written about in the forum. Or track CHARTEVENT_OBJECT_CLICK - perfect solution!

 
Mihail Matkovskij #:

One way or another, your CPU will blow up at such a programmer... :)

I'm keeping an eye on the thermometer.

Mihail Matkovskij #:

You can hide from the chart and then show. How to properly hide an object and show, it was written about it on the forum.

Nah... I'll figure it out the right way.

 
Nerd Trader #:

I keep an eye on the thermometer.

Nah... I'm going to make this one up right now.

I've added to the previous message.

 
if(id==CHARTEVENT_OBJECT_CLICK){
    if(sparam=="button_bs")
      (ObjectCreate(0,"H Line",OBJ_HLINE,0,0,0));
  }

  if(ObjectGetInteger(0,"button_bs",OBJPROP_STATE)){
    int      x     =(int)lparam;
    int      y     =(int)dparam;
    datetime dt    =0;
    double   price =0;
    int      window=0;

    if(ChartXYToTimePrice(0,x,y,window,dt,price)){
      if(id == CHARTEVENT_MOUSE_MOVE){
        if(ObjectMove(0,"H Line",window,dt,price))
          ChartRedraw(0);
      }
    }
  }else ObjectDelete(0,"H Line");

Everything is brilliantly simple.

 
Nerd Trader #:

Everything brilliant is simple.

Well, somewhere along the line... :)

 
Mihail Matkovskij #:

Completed the previous post.

can't see
Reason: