- Getting available symbols and Market Watch lists
- Editing the Market Watch list
- Checking if a symbol exists
- Checking the symbol data relevance
- Getting the last tick of a symbol
- Schedules of trading and quoting sessions
- Symbol margin rates
- Overview of functions for getting symbol properties
- Checking symbol status
- Price type for building symbol charts
- Base, quote, and margin currencies of the instrument
- Price representation accuracy and change steps
- Permitted volumes of trading operations
- Trading permission
- Symbol trading conditions and order execution modes
- Margin requirements
- Pending order expiration rules
- Spreads and order distance from the current price
- Getting swap sizes
- Current market information (tick)
- Descriptive symbol properties
- Depth of Market
- Custom symbol properties
- Specific properties (stock exchange, derivatives, bonds)
Pending order expiration rules
When working with pending orders (including Stop Loss and Take Profit levels), an MQL program should check a couple of properties that define the rules for their expiration. Both properties are available as members of the ENUM_SYMBOL_INFO_INTEGER enumeration for the call of the SymbolInfoInteger function.
Identifier |
Description |
---|---|
SYMBOL_EXPIRATION_MODE |
Flags of allowed order expiration modes (bit mask) |
SYMBOL_ORDER_GTC_MODE |
The validity period is defined by one of the elements of the ENUM_SYMBOL_ORDER_GTC_MODE enumeration |
The SYMBOL_ORDER_GTC_MODE property is taken into account only if SYMBOL_EXPIRATION_MODE contains SYMBOL_EXPIRATION_GTC (see further). GTC is an acronym for Good Till Canceled.
For each financial instrument, the SYMBOL_EXPIRATION_MODE property can specify several modes of validity (expiration) of pending orders. Each mode has a flag (bit) associated with it.
Identifier (Value) |
Description |
---|---|
SYMBOL_EXPIRATION_GTC (1) |
Order is valid according to the ENUM_SYMBOL_ORDER_GTC_MODE property |
SYMBOL_EXPIRATION_DAY (2) |
Order is valid until the end of the current day |
SYMBOL_EXPIRATION_SPECIFIED (4) |
The expiration date and time are specified in the order |
SYMBOL_EXPIRATION_SPECIFIED_DAY (8) |
The expiration date is specified in the order |
The flags can be combined with a logical OR ('|') operation, for example, SYMBOL_EXPIRATION_GTC | SYMBOL_EXPIRATION_SPECIFIED, equivalent to 1 | 4, which is the number 5. To check whether a particular mode is enabled for a tool, perform a logical AND ('&') operation on the function result and the desired mode bit: a non-zero value means the mode is available.
In the case of SYMBOL_EXPIRATION_SPECIFIED_DAY, the order is valid until 23:59:59 of the specified day. If this time does not fall on the trading session, the expiration will occur at the nearest next trading time.
The ENUM_SYMBOL_ORDER_GTC_MODE enumeration contains the following members.
Identifier |
Description |
---|---|
SYMBOL_ORDERS_GTC |
Pending orders and Stop Loss/Take Profit levels are valid indefinitely until explicitly canceled |
SYMBOL_ORDERS_DAILY |
Orders are valid only within one trading day: upon its completion, all pending orders are deleted, as well as Stop Loss and Take Profit levels |
SYMBOL_ORDERS_DAILY_EXCLUDING_STOPS |
When changing the trading day, only pending orders are deleted, but Stop Loss and Take Profit levels are saved |
Depending on the set bits in the SYMBOL_EXPIRATION_MODE property, when preparing an order for sending, an MQL program can select one of the modes corresponding to these bits. Technically, this is done by filling in the type_time field in a special structure MqlTradeRequest before calling the OrderSend function. The field value must be an element of the ENUM_ORDER_TYPE_TIME enumeration (see Pending order expiration dates): as we will see later, it has something in common with the above set of flags, that is, each flag sets the corresponding mode in the order: ORDER_TIME_GTC, ORDER_TIME_DAY, ORDER_TIME_SPECIFIED, ORDER_TIME_SPECIFIED_DAY. The expiration time or day itself must be specified in another field of the same structure.
The script SymbolFilterExpiration.mq5 allows you to find out the statistics of the use of each of the flags in the available symbols (in the market overview or in general, depending on the input parameter UseMarketWatch). The second parameter in ShowPerSymbolDetails, being set to true, will cause all flags for each character to be logged, so be careful: if at the same time, the mode UseMarketWatch equals false, a very large number of log entries will be generated.
#property script_show_inputs
|
In the OnStart function, in addition to the filter object and receiving arrays for symbol names and property values, we describe MapArray to calculate statistics separately for each of the SYMBOL_EXPIRATION_MODE and SYMBOL_ORDER_GTC_MODE properties.
void OnStart()
|
Next, apply the filter and calculate the statistics.
f.select(UseMarketWatch, ints, symbols, flags);
|
Finally, we output the received numbers to the log.
PrintFormat("===== Expiration modes for %s symbols =====",
|
Let's run the script two times. The first time, with the default settings, we can get something like the following picture.
===== Expiration modes for all available symbols =====
|
Here you can see that almost all flags are allowed for most symbols, and for the SYMBOL_EXPIRATION_GTC mode, the only variant SYMBOL_ORDERS_GTC is used.
Run the script a second time by setting UseMarketWatch and ShowPerSymbolDetails to true (it is assumed that a limited number of symbols is selected in Market Watch).
GBPUSD:
|
Of the 15 selected symbols, only 6 have the SYMBOL_EXPIRATION_SPECIFIED_DAY flag set. Details about the flags for each symbol can be found above.