Automation with button and mouse click interception. - page 12

 
Ilnur Iksanov:
#include <WinUser32.mqh>

#import "user32.dll"
   int GetAncestor(int hWnd, int gaFlags);
   int GetDlgItem(int hDlg, int nIDDlgItem);
#import

void start()
{
   int hMetaTrader, hTerminal, hTester, hButtonStart;
      
   hMetaTrader = GetAncestor(WindowHandle(Symbol(),Period()),2); //дескриптор основного окна терминала
        
   hTerminal = GetDlgItem(hMetaTrader,0xE81E);
   hTester = GetDlgItem(hTerminal,0x53); // Return zero here
   hButtonStart = GetDlgItem(GetDlgItem(hTester,0x81BF),0x40A);  //дескриптор кнопки "Старт"
        
   PostMessageA(GetDlgItem(hTester,0x81BF),WM_COMMAND,0x40A,hButtonStart); //нажимаем кнопку старт
   
   Print("Запуск тестера стратегий");
   string sButtonStartName = "";
   while(!IsStopped()) 
   {
      Sleep(3000);
      GetWindowTextA(hButtonStart,sButtonStartName,6); //считываем текст кнопки запуска тестера
      if(sButtonStartName=="Старт")                    
      {
         Print("Работа тестера завершена");
         break;
      }
   }
}



That's great stuff. Thank you for sharing it.

But that's not working for me. Metatrader and Terminal Id are ok, but it can't find the tester window. I'm guessing your soluction is for MT4 while I'm using MT5. Or maybe it's a language issue (my MT5 is in portuguese). Any other way to discover the proper ID for the tester window? Thank you so much. And I'm really sorry for answering in (poor) english.

 

Good afternoon.

Guys, please help with the buy and sell script when 1click trading is on. Simple, without the hassle of changing lot size... etc...

Already broke my head - do not get anything.

I am very grateful to you in advance. Re-read the thread, found nothing like this.

 
axis:

Good afternoon.

Guys, please help with the buy and sell script when 1click trading is on. Simple, without the hassle of changing lot size... etc...

Already broke my head - do not get anything.

I am very grateful to you in advance. Vetku re-read, found nothing like this.


Spread what you can not get here (code), or in a new post, you will be advised what is wrong. Does one click trading prevent script from trading? Maybe just auto trade button is not activated? Or your brokerage company does not allow automatic trading.

You should at least try to publish the error codes from the journal, or better yet, the source code.

 

But still, is there a reasonable way to programmatically set dates for testing EAs? I think the method described earlier byYuriy Zaytsev works, but there are functions that address elements like DateTimePicker, like this:

DateTime_SetSystemtime(GetDlgItem(hwndDlg, IDD_Date1), GDT_VALID, &SysTime);

Just can't implement it yet. Any thoughts on this?

Reason: