InitAllIndicators

Author: (C)opyright � 2008, Ilnur
InitAllIndicators

This script is designed to automate the repetitive task of updating or refreshing all indicators currently attached to a specific trading chart within the MetaTrader platform. Instead of requiring a user to manually click through every single indicator one by one to refresh its settings or data, this tool handles the process automatically.

How it works:

The script functions by simulating human interactions with the software's interface. It essentially "mimics" a user performing the following sequence of actions at high speed:

  1. Identification: The script first identifies the active trading window you are currently viewing to ensure it only affects the intended chart.
  2. Navigation: It automatically opens the internal "Indicators List" window, which is where all your loaded tools and overlays are managed.
  3. Iterative Processing: Once the list is open, the script looks at every indicator listed in that menu. It systematically moves through them one by one:
    • It highlights each indicator in the list.
    • It "clicks" to open the specific properties and settings for that individual indicator.
    • It then "clicks" the confirmation button (OK) to apply those settings or refresh the data.
  4. Completion: After it has cycled through every single item in your list, it automatically closes the management window.

Key Takeaways:

  • Automation of Repetition: It transforms a long manual process into a nearly instantaneous automated task.
  • UI Interaction: Rather than modifying the underlying data directly, the script works by interacting with the visual buttons and menus you see on your screen.
  • Requirement: Because it interacts with the software's window system, the user must enable "Allow DLL imports" in the platform settings for the script to have permission to communicate with the computer's operating system.
8 Views
0 Downloads
0 Favorites
InitAllIndicators
//+------------------------------------------------------------------+
//|                                            InitAllIndicators.mq4 |
//|                                 		 (C)opyright © 2008, Ilnur |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+

// Ñêðèïò äëÿ ïåðåèíèöèàëèçàöèè âñåõ èíäèêàòîðîâ, ïðèêðåïëåííûõ òåêóùåìó îêíó.
// Äëÿ ðàáîòû ñêðèïòà íåîáõîäèìî ðàçðåøèòü âûçîâ ôóíêöèé èç ñèñòåìíûõ DLL:
// Ñåðâèñ -> Íàñòðîéêè  -> Ñîâåòíèêè -> Ðàçðåøèòü èìïîðò DLL.

#property copyright "(C)opyright © 2008, Ilnur"
#property link      "http://www.metaquotes.net"

#include <WinUser32.mqh>

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

#define PAUSE 100

#define VK_HOME 0x24
#define VK_DOWN 0x28

#define GA_ROOT 2

#define TVM_GETCOUNT 0x1105

//+------------------------------------------------------------------+
//| Âûçûâàåò îêíî "Ñïèñîê èíäèêàòîðîâ" è âîçâðàùàåò åãî äåñêðèïòîð   |
//+------------------------------------------------------------------+
int GetListDialog(int hOwnedWnd)
{
	int hDlgWnd;
//---- âûçûâàåì îêíî "Ñïèñîê èíäèêàòîðîâ"
	PostMessageA(hOwnedWnd,WM_COMMAND,35419,0);
	Sleep(PAUSE);
//---- îïðåäåëÿåì äåñêðèïòîð îêíà
	hDlgWnd = GetLastActivePopup(hOwnedWnd);
//----
	return(hDlgWnd);
}

//+------------------------------------------------------------------+
//| Âûçûâàåò îêíî ñâîéñòâ èíäèêàòîðà è âîçâðàùàåò åãî äåñêðèïòîð     |
//+------------------------------------------------------------------+
int GetPropertyDialog(int hOwnedWnd, int hListDlg)
{
	int hDlgWnd;
//---- âûçûâàåì îêíî ñâîéñòâ âûáðàííîãî èíäèêàòîðà
	PostMessageA(hListDlg,WM_COMMAND,0x48B,GetDlgItem(hListDlg,0x48B));
	Sleep(PAUSE);
//---- îïðåäåëÿåì äåñêðèïòîð îêíà
	hDlgWnd = GetLastActivePopup(hOwnedWnd);
//----
	return(hDlgWnd);
}

//+------------------------------------------------------------------+
//| Îñíîâíàÿ ôóíêöèÿ ñêðèïòà	                                     	|
//+------------------------------------------------------------------+
void start()
{
	int hParentWnd, hListDlg, hTreeView, hPropDlg;
	int nTreeCount;
//---- ïîëó÷àåì äåñêðèïòîð îñíîâíîãî îêíà òåðìèíàëà
	hParentWnd = GetAncestor(WindowHandle(Symbol(),Period()),GA_ROOT);

	if(hParentWnd!=0)
	{
	//---- âûçûâàåì îêíî "Ñïèñîê èíäèêàòîðîâ"
		hListDlg = GetListDialog(hParentWnd);
	//---- íàõîäèì ñïèñîê èíäèêàòîðîâ
		hTreeView = GetDlgItem(hListDlg,0x48C); //
	//---- îïðåäåëÿåì îáùóþ äëèíó ñïèñêà
		nTreeCount = SendMessageA(hTreeView,TVM_GETCOUNT,0,0);
	//---- óñòàíàâëèâàåì êóðñîð íà âåðõíåé ñòðî÷êå ñïèñêà
		PostMessageA(hTreeView,WM_KEYDOWN,VK_HOME,0);
	//---- â öèêëå ïåðåáèðàåì âåñü ñïèñîê
		for(int i=1; i<nTreeCount; i++)
		{
		//---- ñìåùàåì êóðñîð íà ñëåäóþùóþ ïîçèöèþ ñïèñêà
			PostMessageA(hTreeView,WM_KEYDOWN,VK_DOWN,0);
		//---- ïðîâåðÿåì àêòèâíîñòü êíîïêè "Ñâîéñòâà"
			if(IsWindowEnabled(GetDlgItem(hListDlg,0x48B))==0) continue;
		//---- âûçûâàåì îêíî ñâîéñòâ âûäåëåííîãî èíäèêàòîðà
			hPropDlg = GetPropertyDialog(hParentWnd,hListDlg);
		//---- íàæèìàåì êíîïêó "ÎÊ"
			PostMessageA(hPropDlg,WM_COMMAND,0x001,GetDlgItem(hPropDlg,0x001));
		}
	//---- çàêðûâàåì îêíî "Ñïèñîê èíäèêàòîðîâ"
		PostMessageA(hListDlg,WM_COMMAND,0x001,GetDlgItem(hListDlg,0x001));
	}
}

Comments