forked from sholafalana/MT5-MT4-Telegram-API-Bot
-
Notifications
You must be signed in to change notification settings - Fork 55
/
CPlusBotRecon.mqh
91 lines (81 loc) · 4.98 KB
/
CPlusBotRecon.mqh
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
//|-----------------------------------------------------------------------------------------|
//| CPlusBotRecon.mq4 |
//| Copyright 2019, Dennis Lee |
//| https://github.com/dennislwm/MT5-MT4-Telegram-API-Bot |
//| |
//| History |
//| 0.9.0 The CPlusBotRecon class inherits from CCustomBot. We added general, order |
//| status, history status, and account status bot commands: |
//| (1) /help - Display a list of bot commands |
//| (2) /ordertotal - Return count of orders |
//| (3) /ordertrade - Return ALL orders, where EACH order includes ticket, symbol, |
//| type, lots, openprice, stoploss, takeprofit, opentime and prevticket. |
//| Note: curprice, swap, profit, expiration, closetime, magicno, accountno, |
//| and expertname are NOT returned. |
//| (4) /orderticket <ticket> - Return an order by ticket number. If <ticket> is a |
//| partial trade, return a chain of orders and history, otherwise return a |
//| single trade. |
//| (5) /historytotal - Return count of history |
//| (6) /historyticket <ticket> - Return a history or a chain of history, where EACH |
//| history includes ticket, symbol, type, lots, openprice, closeprice, stoploss,|
//| takeprofit, opentime, closetime, and prevticket. |
//| Note: opentime, swap, profit, expiration, magicno, accountno, and |
//| expertname are NOT returned. |
//| (7) /account - Return account number, currency, balance, equity, margin, |
//| freemargin and profit. |
//|-----------------------------------------------------------------------------------------|
#property copyright "Copyright 2019, Dennis Lee"
#property link "https://github.com/dennislwm/MT5-MT4-Telegram-API-Bot"
#property strict
//---- Assert Basic externs
#include <PlusBotRecon.mqh>
#include <Telegram.mqh>
//|-----------------------------------------------------------------------------------------|
//| M A I N P R O C E D U R E |
//|-----------------------------------------------------------------------------------------|
class CPlusBotRecon: public CCustomBot
{
public:
void ProcessMessages(void)
{
string msg=NL;
const string strOrderTrade="/ordertrade";
const string strHistoryTicket="/historyticket";
int pos=0, ticket=0;
for( int i=0; i<m_chats.Total(); i++ ) {
CCustomChat *chat=m_chats.GetNodeAtIndex(i);
if( !chat.m_new_one.done ) {
chat.m_new_one.done=true;
string text=chat.m_new_one.message_text;
if( text=="/ordertotal" ) {
SendMessage( chat.m_id, BotOrdersTotal() );
}
if( StringFind( text, strOrderTrade )>=0 ) {
pos = StringToInteger( StringSubstr( text, StringLen(strOrderTrade)+1 ) );
SendMessage( chat.m_id, BotOrdersTrade(pos) );
}
if( text=="/historytotal" ) {
SendMessage( chat.m_id, BotOrdersHistoryTotal() );
}
if( StringFind( text, strHistoryTicket )>=0 ) {
ticket = StringToInteger( StringSubstr( text, StringLen(strHistoryTicket)+1 ) );
SendMessage( chat.m_id, BotHistoryTicket(ticket) );
}
if( text=="/account" ) {
SendMessage( chat.m_id, BotAccount() );
}
msg = StringConcatenate(msg,"My commands list:",NL);
msg = StringConcatenate(msg,"/ordertotal-return count of orders",NL);
msg = StringConcatenate(msg,"/ordertrade-return ALL opened orders",NL);
msg = StringConcatenate(msg,"/orderticket <ticket>-return an order or a chain of history by ticket",NL);
msg = StringConcatenate(msg,"/historytotal-return count of history",NL);
msg = StringConcatenate(msg,"/historyticket <ticket>-return a history or chain of history by ticket",NL);
msg = StringConcatenate(msg,"/account-return account info",NL);
msg = StringConcatenate(msg,"/help-get help");
if( text=="/help" ) {
SendMessage( chat.m_id, msg );
}
}
}
}
};