Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1508

 

Hello!

Try to create a separate object for each button and add it to the dialogue after creation. Otherwise the dialogue understands that it has only one button inside.

for(int i=0; i<SymbolsTotal(true);i++){ 
   btns[i].Create(0,"btn"+(string) i,0,0,0+BTN_HEIGHT+btn_left,0,0+BTN_WIDTH*btn_line);
   ExtDialog.Add(btns[i]);
}
 
Yuriy Bykov #:

Hello!

Try to create a separate object for each button and add it to the dialogue after creation. Otherwise the dialogue understands that it has only one button inside.

I tried it, it throws a critical error "Array out of range"

 
We should first make this array of objects, and then use its elements in a loop, calling the Create method for them. I can't write an example right now
 
Yuriy Bykov #:
We should first make this array of objects, and then use its elements in a loop, calling the Create method for them. I can't write an example right now

Got it, thanks!

 

Somehow, I guess:

// Глобальный массив
CButton btns[];

...

int total = SymbolsTotal(true);

ArrayResize(btns, total);

for(int i=0; i<total;i++){ 
   btns[i].Create(0,"btn"+(string) i,0,0,0+BTN_HEIGHT+btn_left,0,0+BTN_WIDTH*btn_line);
   ExtDialog.Add(btns[i]);
}

Usually create your own dialogue class by inheriting from CAppDialog. Then btns can be a field of this class. Otherwise you should make it a global variable.

Check also that you have correctly calculated the coordinates of the next button placement - the i index should somehow participate in their calculation.

 
This is probably a stupid question, but I am a newbie and I haven't figured it all out yet. can you please tell me how to limit the time an EA can work? I want to give the EA for 1-2 weeks for a test. How to write it in the code of the Expert Advisor? It is necessary that after X time it should give a message EA working time has expired contact the author or something like that.
 
Yuriy Bykov global variable.

Check also that you have correctly calculated the coordinates of the next button placement - the i index should somehow participate in their calculation.

Everything works! Thank you very much!

 
Lucum #:
This is probably a stupid question, but I am a newbie and I haven't figured it all out yet. can you please tell me how to limit the time an EA can work? I want to give the EA for 1-2 weeks for a test. How to write it in the code of the Expert Advisor? It is necessary that after X amount of time it should give a message EA working time has expired contact the author or something like that.

That's funny, but okay.

The easiest option is to add this code to OnTick().

   if(TimeLocal() >= D'2024.03.15 00:00:00')
     {
      MessageBox("Без денег, торговать не буду.\nДай денег.\nПобольше.");
      ExpertRemove();
     }
 
Is there any possibility to forbid to move the panel created with the help of <Controls\Dialog.mqh> library?
 
Hello Friends. I wonder if you have used real time real account expert bitlite. It is very good in testing. And if you know a similar expert at a lower price, thank you