-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccountPermissions.mq5
47 lines (40 loc) · 1.82 KB
/
AccountPermissions.mq5
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
//+------------------------------------------------------------------+
//| AccountPermissions.mq5 |
//| Copyright 2022, MetaQuotes Ltd. |
//| https://www.mql5.com |
//| Check complete set of trading permissions, |
//| including account settings, such as investor login. |
//+------------------------------------------------------------------+
#include <MQL5Book/Permissions.mqh>
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
PrintFormat("Run on %s", _Symbol);
if(!Permissions::isTradeEnabled()) // check default (current) symbol
{
Print("Trade is disabled for following reasons:");
Print(Permissions::explainLastRestrictionBitMask());
}
else
{
Print("Trade is enabled");
}
}
//+------------------------------------------------------------------+
/*
example output (algotrading is disabled in the terminal, Russian market is closed):
Run on USDRUB
Trade is disabled for following reasons:
TERMINAL_RESTRICTION PROGRAM_RESTRICTION SESSION_RESTRICTION
example output (algotrading is disabled in the terminal, symbol is not traded):
Run on SP500m
Trade is disabled for following reasons:
TERMINAL_RESTRICTION PROGRAM_RESTRICTION SYMBOL_RESTRICTION
example output (algotrading is enabled, but inverstor login is used):
Run on XAUUSD
Trade is disabled for following reasons:
ACCOUNT_RESTRICTION
*/
//+------------------------------------------------------------------+