-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathBreakermindMT4EquityTestSaveToFileHttpsWebRequest.mq4
64 lines (58 loc) · 2.2 KB
/
BreakermindMT4EquityTestSaveToFileHttpsWebRequest.mq4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//+------------------------------------------------------------------+
//| P&L.mq4 |
//| http://breakermind.com |
//+------------------------------------------------------------------+
#property copyright "2014 Breakermind.com"
#property link "https://breakermind.com"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
input bool Start = true;
input string Trader = "WooW";
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnInit()
{
EventSetMillisecondTimer(5000);
}
void OnTimer(void)
{
if(Start)
{
string cookie=NULL;
string headers;
char post[],result[];
int res;
string url = "http://localhost/api-balance.php";
string signal = "account="+AccountNumber()+"&balance="+AccountBalance()+"&equity="+AccountEquity()+"&user="+Trader+"&end=0";
Print("REST client's POST: ",signal);
StringToCharArray(signal,post);
ResetLastError();
int timeout=5000;
res=WebRequest("POST",url,cookie,NULL,timeout,post,0,result,headers);
//MessageBox("Send positions ...");
if(res==-1)
{
Print("Error code =",GetLastError());
MessageBox("Add address '"+url+"' in Expert Advisors tab of the Options window","Error",MB_ICONINFORMATION);
}
else
{
//--- successful
PrintFormat("Download successful, size =%d bytes.",ArraySize(result));
//Print("Server response:",CharArrayToString(result,0));
//--- save data to file
int filehandle=FileOpen("Balance"+Trader+".htm",FILE_WRITE|FILE_BIN);
//--- check
if(filehandle!=INVALID_HANDLE)
{
//--- write result[] array to file
FileWriteArray(filehandle,result,0,ArraySize(result));
//--- close file
FileClose(filehandle);
}
else Print("Error in FileOpen. Error code=",GetLastError());
}
}
}