//+------------------------------------------------------------------+
//|                                                SetTesterDate.mq4 |
//|                                       Copyright © 2011, sangmane |
//|                                        sangmane@forexfactory.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, sangmane"
#property link      "sangmane@forexfactory.com"
#property show_inputs

extern datetime StartDate = D'2008.07.13';
extern datetime StopDate = D'2011.01.29';

#define	ID_TERMINAL   		0xE81E
#define	ID_TESTER			0x53
#define	ID_FRAME			0x81BF
#define DTM_SETSYSTEMTIME   0x1002

#import "user32.dll"
	int GetAncestor(int hwnd, int gaFlags);
	int GetDlgItem(int hwnd, int id);
	int FindWindowExA(int hwndParent, int hwndChildAfter, string lpszClass, string lpszWindow);
	int SendMessageA(int hwnd, int msg, int wparam, int &lparam[]);

int start()
{
	int hwnd = WindowHandle(Symbol(),0);
	hwnd = GetAncestor(hwnd,2);
	hwnd = GetDlgItem(hwnd,ID_TERMINAL);
	hwnd = GetDlgItem(hwnd,ID_TESTER);
	hwnd = GetDlgItem(hwnd,ID_FRAME);
	int hStart = FindWindowExA(hwnd,0,"SysDateTimePick32","");
	int hEnd   = FindWindowExA(hwnd,hStart,"SysDateTimePick32","");
	
	int dt[4] = {0,0,0,0};
	dt[0] = (TimeMonth(StartDate) << 16) | TimeYear(StartDate);
	dt[1] = (TimeDay(StartDate) << 16) | TimeDayOfWeek(StartDate);
	SendMessageA(hStart,0x1002,0,dt);
	dt[0] = (TimeMonth(StopDate) << 16) | TimeYear(StopDate);
	dt[1] = (TimeDay(StopDate) << 16) | TimeDayOfWeek(StopDate);
	SendMessageA(hEnd,0x1002,0,dt);	
	return(0);
}
//+------------------------------------------------------------------+