forked from dennislwm/MT4-Telegram-Bot-Recon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TelegramRecon.mq4
155 lines (142 loc) · 6.6 KB
/
TelegramRecon.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//|-----------------------------------------------------------------------------------------|
//| TelegramRecon.mq4 |
//| Copyright 2019, Dennis Lee |
//| https://github.com/dennislwm/MT4-Telegram-Bot-Recon |
//| |
//| Background |
//| Telegram isn't just for sending and receiving chat messages. It's also for |
//| automating your dialog flow, including work flow. Using a Telegram Bot gives you the |
//| ability to check prices, query status, manage trades, and even have a fun |
//| conversation. And if you're a serious crypto or forex trader, you can create your own |
//| Telegram Bot to manage your order flow. |
//| |
//| URL: https://www.mql5.com/en/articles/2355 |
//| |
//| Strategy |
//| This EA can be used to manage your order flow. |
//| |
//| Example |
//| For example, in Telegram, send a message "/help" to your Bot. |
//| |
//| History |
//| 0.9.0 The TelegramRecon EA listens for messages from a Telegram Bot. You can use |
//| the bot to query your orders from a Metatrader 4 client. You can use this approach |
//| to manage your order flow and view account details. |
//|-----------------------------------------------------------------------------------------|
#property copyright "Copyright 2019, Dennis Lee"
#property link "https://github.com/dennislwm/MT4-Telegram-Bot-Recon"
#property version "000.900"
#property strict
//---- Assert Basic externs
#include <plusinit.mqh>
#include <plusbig.mqh>
#include <Telegram.mqh>
#include <CPlusBotRecon.mqh>
//|-----------------------------------------------------------------------------------------|
//| E X T E R N A L V A R I A B L E S |
//|-----------------------------------------------------------------------------------------|
extern string s1="-->TGR Settings<--";
extern string s1_1="Token - Telegram API Token";
input string TgrToken;
extern string IndD1="===Debug Properties===";
extern bool IndViewDebugNotify = false;
extern int IndViewDebug = 0;
extern int IndViewDebugNoStack = 100;
extern int IndViewDebugNoStackEnd = 10;
int IndDebugCrit=0;
int IndDebugCore=1;
int IndDebugFine=2;
//|-----------------------------------------------------------------------------------------|
//| I N T E R N A L V A R I A B L E S |
//|-----------------------------------------------------------------------------------------|
//---- Assert indicator name and version
string IndName="TelegramRecon";
string IndVer="0.9.0";
//---- Assert variables for TGR
CPlusBotRecon bot;
int intResult;
//|-----------------------------------------------------------------------------------------|
//| I N I T I A L I Z A T I O N |
//|-----------------------------------------------------------------------------------------|
int OnInit()
{
InitInit();
BigInit();
bot.Token(TgrToken);
intResult=bot.GetMe();
//--- create timer
EventSetTimer(3);
OnTimer();
//---
return(INIT_SUCCEEDED);
}
//|-----------------------------------------------------------------------------------------|
//| D E I N I T I A L I Z A T I O N |
//|-----------------------------------------------------------------------------------------|
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
BigDeInit();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
}
void OnTimer()
{
//--- Assert intResult=0 (success)
if( intResult!=0 ) {
BigComment( "Error: "+GetErrorDescription(intResult) );
return;
}
BigComment( "Bot name: "+bot.Name() );
bot.GetUpdates();
bot.ProcessMessages();
}
//|-----------------------------------------------------------------------------------------|
//| I N T E R N A L F U N C T I O N S |
//|-----------------------------------------------------------------------------------------|
void IndDebugPrint(int dbg, string fn, string msg)
{
static int noStackCount;
if(IndViewDebug>=dbg)
{
if(dbg>=IndDebugFine && IndViewDebugNoStack>0)
{
if( MathMod(noStackCount,IndViewDebugNoStack) <= IndViewDebugNoStackEnd )
Print(IndViewDebug,"-",noStackCount,":",fn,"(): ",msg);
noStackCount ++;
}
else
{
if(IndViewDebugNotify) SendNotification( IndViewDebug + ":" + fn + "(): " + msg );
Print(IndViewDebug,":",fn,"(): ",msg);
}
}
}
string IndDebugInt(string key, int val)
{
return( StringConcatenate(";",key,"=",val) );
}
string IndDebugDbl(string key, double val, int dgt=5)
{
return( StringConcatenate(";",key,"=",NormalizeDouble(val,dgt)) );
}
string IndDebugStr(string key, string val)
{
return( StringConcatenate(";",key,"=\"",val,"\"") );
}
string IndDebugBln(string key, bool val)
{
string valType;
if( val ) valType="true";
else valType="false";
return( StringConcatenate(";",key,"=",valType) );
}
//|-----------------------------------------------------------------------------------------|
//| E N D O F I N D I C A T O R |
//|-----------------------------------------------------------------------------------------|