Last active
September 21, 2022 14:37
-
-
Save ybagheri/518d6e6f1744fa19c38eabac40c08ed5 to your computer and use it in GitHub Desktop.
opens a template on all open charts Metatrader 4 MQ4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Resource Link : https://www.forexfactory.com/attachment/file/733647?d=1309582301 | |
// How to use: | |
//see this: https://www.forexfactory.com/attachment/image/4292179?d=1663770637 | |
//then run this script on that chart. | |
//+------------------------------------------------------------------+ | |
//| ChangeTemplate-All.mq4 | | |
//+------------------------------------------------------------------+ | |
#property copyright "Copyright © 2011, zznbrm" | |
#property show_inputs | |
#include <WinUser32.mqh> | |
#import "user32.dll" | |
int PostMessageA(int hWnd,int Msg,int wParam,int lParam); | |
int GetWindow(int hWnd,int uCmd); | |
int GetParent(int hWnd); | |
#import | |
extern int templateIndex = 0; | |
extern int NumbOfChart =3; // Nmber of chart to open | |
extern string symbol = "EURUSD"; | |
int start() | |
{ | |
//first open a chart and add your desire template manually | |
//then run this script | |
ENUM_TIMEFRAMES timeFrame = PERIOD_M1; | |
for(int i=0; i<NumbOfChart; i++) | |
{ | |
ChartOpen(symbol,timeFrame); | |
} | |
bool blnContinue = true; | |
int intParent = GetParent( WindowHandle( Symbol(), Period() ) ); | |
int intChild = GetWindow( intParent, GW_HWNDFIRST ); | |
if ( intChild > 0 ) | |
{ | |
if ( intChild != intParent ) PostMessageA( intChild, WM_COMMAND, 34800 + templateIndex, 0 ); | |
} | |
else blnContinue = false; | |
while( blnContinue ) | |
{ | |
intChild = GetWindow( intChild, GW_HWNDNEXT ); | |
if ( intChild > 0 ) | |
{ | |
if ( intChild != intParent ) PostMessageA( intChild, WM_COMMAND, 34800 + templateIndex, 0 ); | |
} | |
else blnContinue = false; | |
} | |
// Now do the current window | |
PostMessageA( intParent, WM_COMMAND, 34800 + templateIndex, 0 ); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment