-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForexRatesViewerClient.mq5
More file actions
69 lines (66 loc) · 2.42 KB
/
ForexRatesViewerClient.mq5
File metadata and controls
69 lines (66 loc) · 2.42 KB
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
65
66
67
68
69
//+------------------------------------------------------------------+
//| ForexRatesViewerClient.mq5 |
//| Copyright 2018, InvestDataSystems |
//| https://tradingbot.wixsite.com/robots-de-trading |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, InvestDataSystems"
#property link "https://tradingbot.wixsite.com/robots-de-trading"
#property version "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
return(INIT_SUCCEEDED);
}
char post[];
char result[];
string cookie=NULL,headers;
string url="http://127.0.0.1:9090/send_data/";
void SendData(string strpost);
int i=0;
int res;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void SendData(string strpost)
{
//---
ResetLastError();
ArrayResize(post,StringLen(strpost));
for(i=0; i<StringLen(strpost); i++)
{
post[i]=strpost[i];
}
res=WebRequest("POST",url,cookie,NULL,500,post,0,result,headers);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
MqlTick last_tick;
int stotal;
int sindex;
string sname;
void OnTick()
{
int stotal=SymbolsTotal(false); // seulement les symboles dans le marketwatch (false)
for(sindex=0; sindex<stotal; sindex++)
{
sname=SymbolName(sindex, false);
if(SymbolInfoTick(sname,last_tick))
{
// Time, Symbol, Bid, Ask, Vol
SendData(last_tick.time+";"+sname+";"+last_tick.bid+";"+last_tick.ask+";"+last_tick.volume);
}
else Print("SymbolInfoTick() failed, error = ",GetLastError());
}
}
//+------------------------------------------------------------------+