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

 
I tried it this way:
if(id==CHARTEVENT_OBJECT_CLICK && sparam=="button1")
      ObjectSetInteger(0,"button1",OBJPROP_STATE,false);

But when you click, the button just visually doesn't seem to click, which makes sense.

 
Nerd Trader #:
I tried it this way:

But when you click, the button just visually doesn't seem to click, which makes sense.

if(sparam=="button1")
      Sleep(100);
      ObjectSetInteger(0,"button1",OBJPROP_STATE,false);
 
MakarFX #:
That'll do, thank you.
 
MakarFX #:

The entire programme is delayed. Not good... For a simple variant, of course, it's fine. But for normal - you need to poll the values of the pressed buttons in the millisecond timer and, if after pressing the button the required delay time has passed - set a flag.

 
Nerd Trader #:
That'll do, thank you.

In a closed market, be surprised how a button like this works

 
MakarFX #:

Try this.

Better yet, prescribe,

if there are no open sell orders, delete the sell line...

similar for the bai

Thanks for the tip but it did not help

 
Artyom Trishkin #:

The entire programme is delayed. Not good... For a simple variant, of course, it's fine. But for normal - you need to poll the values of the pressed buttons in the millisecond timer and if after pressing the button the required delay time has passed - set a flag.

Yes, it's not good. Is it ok?

     if(id==CHARTEVENT_OBJECT_CLICK && sparam=="button1"){
       ulong ms=GetMicrosecondCount();
       for(;;){
         if(GetMicrosecondCount()-ms>100000){
           ObjectSetInteger(0,"button1",OBJPROP_STATE,false);
           break;
         }
       }
     }
Isn't it equivalent to Sleep(100)? After all, the program will hang in a loop until break is executed.
 
Please suggest an indicator for crossing two slides with an alert?
 
Free ...
 
Nerd Trader #:

Yeah, that's not good. Is that OK?

Isn't it equivalent to Sleep(100)? After all, the program will hang in a loop until break is executed.
And if "ms" is made global
ulong ms=0;
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
      if(id==CHARTEVENT_OBJECT_CLICK && sparam=="button1")
         {ms=GetMicrosecondCount();}
  }
//+------------------------------------------------------------------+
void OnTimer()
  {
   if(GetMicrosecondCount()-ms>100000)
     {
      ObjectSetInteger(0,"button1",OBJPROP_STATE,false);
      ms=0;
     }
  }
//+------------------------------------------------------------------+
Reason: