MQL4参考 标准常量,列举和架构 环境状态 符号属性

Symbol Properties

Market information identifiers, used with MarketInfo() function. It can be any of the following values:

ID

Value

Description

MODE_LOW

1

Low day price

MODE_HIGH

2

High day price

MODE_TIME

5

The last incoming tick time (last known server time)

MODE_BID

9

Last incoming bid price. For the current symbol, it is stored in the predefined variable Bid

MODE_ASK

10

Last incoming ask price. For the current symbol, it is stored in the predefined variable Ask

MODE_POINT

11

Point size in the quote currency. For the current symbol, it is stored in the predefined variable Point

MODE_DIGITS

12

Count of digits after decimal point in the symbol prices. For the current symbol, it is stored in the predefined variable Digits

MODE_SPREAD

13

Spread value in points

MODE_STOPLEVEL

14

Stop level in points

 

A zero value of MODE_STOPLEVEL means either absence of any restrictions on the minimal distance for Stop Loss/Take Profit or the fact that a trade server utilizes some external mechanisms for dynamic level control, which cannot be translated in the client terminal. In the second case, GetLastError() can return error 130, because MODE_STOPLEVEL is actually "floating" here.

MODE_LOTSIZE

15

Lot size in the base currency

MODE_TICKVALUE

16

Tick value in the deposit currency

MODE_TICKSIZE

17

Tick size in points

MODE_SWAPLONG

18

Swap of the buy order

MODE_SWAPSHORT

19

Swap of the sell order

MODE_STARTING

20

Market starting date (usually used for futures)

MODE_EXPIRATION

21

Market expiration date (usually used for futures)

MODE_TRADEALLOWED

22

Trade is allowed for the symbol

MODE_MINLOT

23

Minimum permitted amount of a lot

MODE_LOTSTEP

24

Step for changing lots

MODE_MAXLOT

25

Maximum permitted amount of a lot

MODE_SWAPTYPE

26

Swap calculation method. 0 - in points; 1 - in the symbol base currency; 2 - by interest; 3 - in the margin currency

MODE_PROFITCALCMODE

27

Profit calculation mode. 0 - Forex; 1 - CFD; 2 - Futures

MODE_MARGINCALCMODE

28

Margin calculation mode. 0 - Forex; 1 - CFD; 2 - Futures; 3 - CFD for indices

MODE_MARGININIT

29

Initial margin requirements for 1 lot

MODE_MARGINMAINTENANCE

30

Margin to maintain open orders calculated for 1 lot

MODE_MARGINHEDGED

31

Hedged margin calculated for 1 lot

MODE_MARGINREQUIRED

32

Free margin required to open 1 lot for buying

MODE_FREEZELEVEL

33

Order freeze level in points. If the execution price lies within the range defined by the freeze level, the order cannot be modified, cancelled or closed

MODE_CLOSEBY_ALLOWED

34

Allowed using OrderCloseBy() to close opposite orders on a specified symbol

Example:

//+------------------------------------------------------------------+
//| The script prints information on symbol                          |
//+------------------------------------------------------------------+
void OnStart()
  {
   Print("Symbol=",Symbol());
   Print("Low day price=",MarketInfo(Symbol(),MODE_LOW));
   Print("High day price=",MarketInfo(Symbol(),MODE_HIGH));
   Print("The last incoming tick time=",(MarketInfo(Symbol(),MODE_TIME)));
   Print("Last incoming bid price=",MarketInfo(Symbol(),MODE_BID));
   Print("Last incoming ask price=",MarketInfo(Symbol(),MODE_ASK));
   Print("Point size in the quote currency=",MarketInfo(Symbol(),MODE_POINT));
   Print("Digits after decimal point=",MarketInfo(Symbol(),MODE_DIGITS));
   Print("Spread value in points=",MarketInfo(Symbol(),MODE_SPREAD));
   Print("Stop level in points=",MarketInfo(Symbol(),MODE_STOPLEVEL));
   Print("Lot size in the base currency=",MarketInfo(Symbol(),MODE_LOTSIZE));
   Print("Tick value in the deposit currency=",MarketInfo(Symbol(),MODE_TICKVALUE));
   Print("Tick size in points=",MarketInfo(Symbol(),MODE_TICKSIZE)); 
   Print("Swap of the buy order=",MarketInfo(Symbol(),MODE_SWAPLONG));
   Print("Swap of the sell order=",MarketInfo(Symbol(),MODE_SWAPSHORT));
   Print("Market starting date (for futures)=",MarketInfo(Symbol(),MODE_STARTING));
   Print("Market expiration date (for futures)=",MarketInfo(Symbol(),MODE_EXPIRATION));
   Print("Trade is allowed for the symbol=",MarketInfo(Symbol(),MODE_TRADEALLOWED));
   Print("Minimum permitted amount of a lot=",MarketInfo(Symbol(),MODE_MINLOT));
   Print("Step for changing lots=",MarketInfo(Symbol(),MODE_LOTSTEP));
   Print("Maximum permitted amount of a lot=",MarketInfo(Symbol(),MODE_MAXLOT));
   Print("Swap calculation method=",MarketInfo(Symbol(),MODE_SWAPTYPE));
   Print("Profit calculation mode=",MarketInfo(Symbol(),MODE_PROFITCALCMODE));
   Print("Margin calculation mode=",MarketInfo(Symbol(),MODE_MARGINCALCMODE));
   Print("Initial margin requirements for 1 lot=",MarketInfo(Symbol(),MODE_MARGININIT));
   Print("Margin to maintain open orders calculated for 1 lot=",MarketInfo(Symbol(),MODE_MARGINMAINTENANCE));
   Print("Hedged margin calculated for 1 lot=",MarketInfo(Symbol(),MODE_MARGINHEDGED));
   Print("Free margin required to open 1 lot for buying=",MarketInfo(Symbol(),MODE_MARGINREQUIRED));
   Print("Order freeze level in points=",MarketInfo(Symbol(),MODE_FREEZELEVEL)); 
  }

To obtain the current market information there are several functions: SymbolInfoInteger(), SymbolInfoDouble() and SymbolInfoString(). The first parameter is the symbol name, the values of the second function parameter can be one of the identifiers of ENUM_SYMBOL_INFO_INTEGER, ENUM_SYMBOL_INFO_DOUBLE and ENUM_SYMBOL_INFO_STRING.

For function SymbolInfoInteger():

ENUM_SYMBOL_INFO_INTEGER

Identifier

Description

Type

SYMBOL_SELECT

Symbol is selected in Market Watch.

 

Some symbols can be hidden in Market Watch, but still they are considered as selected.

bool

SYMBOL_VISIBLE

Symbol is visible in Market Watch.

 

Some symbols (mostly, these are cross rates required for calculation of margin requirements or profits in deposit currency) are selected automatically, but generally are not visible in Market Watch. To be displayed such symbols have to be explicitly selected.

bool

SYMBOL_SESSION_DEALS

Not supported

long

SYMBOL_SESSION_BUY_ORDERS

Not supported

long

SYMBOL_SESSION_SELL_ORDERS

Not supported

long

SYMBOL_VOLUME

Not supported

long

SYMBOL_VOLUMEHIGH

Not supported

long

SYMBOL_VOLUMELOW

Not supported

long

SYMBOL_TIME

Time of the last quote

datetime

SYMBOL_DIGITS

Digits after a decimal point

int

SYMBOL_SPREAD_FLOAT

Indication of a floating spread

bool

SYMBOL_SPREAD

Spread value in points

int

SYMBOL_TRADE_CALC_MODE

Contract price calculation mode

int

SYMBOL_TRADE_MODE

Order execution type

ENUM_SYMBOL_TRADE_MODE

SYMBOL_START_TIME

Date of the symbol trade beginning (usually used for futures)

datetime

SYMBOL_EXPIRATION_TIME

Date of the symbol trade end (usually used for futures)

datetime

SYMBOL_TRADE_STOPS_LEVEL

Minimal indention in points from the current close price to place Stop orders

int

SYMBOL_TRADE_FREEZE_LEVEL

Distance to freeze trade operations in points

int

SYMBOL_TRADE_EXEMODE

Deal execution mode

ENUM_SYMBOL_TRADE_EXECUTION

SYMBOL_SWAP_MODE

Swap calculation model

int

SYMBOL_SWAP_ROLLOVER3DAYS

Day of week to charge 3 days swap rollover

ENUM_DAY_OF_WEEK

SYMBOL_EXPIRATION_MODE

Not supported

int

SYMBOL_FILLING_MODE

Not supported

int

SYMBOL_ORDER_MODE

Not supported

int

For function SymbolInfoDouble():

ENUM_SYMBOL_INFO_DOUBLE

Identifier

Description

Type

SYMBOL_BID

Bid - best sell offer

double

SYMBOL_BIDHIGH

Not supported

double

SYMBOL_BIDLOW

Not supported

double

SYMBOL_ASK

Ask - best buy offer

double

SYMBOL_ASKHIGH

Not supported

double

SYMBOL_ASKLOW

Not supported

double

SYMBOL_LAST

Not supported

double

SYMBOL_LASTHIGH

Not supported

double

SYMBOL_LASTLOW

Not supported

double

SYMBOL_POINT

Symbol point value

double

SYMBOL_TRADE_TICK_VALUE

Value of SYMBOL_TRADE_TICK_VALUE_PROFIT

double

SYMBOL_TRADE_TICK_VALUE_PROFIT

Not supported

double

SYMBOL_TRADE_TICK_VALUE_LOSS

Not supported

double

SYMBOL_TRADE_TICK_SIZE

Minimal price change

double

SYMBOL_TRADE_CONTRACT_SIZE

Trade contract size

double

SYMBOL_VOLUME_MIN

Minimal volume for a deal

double

SYMBOL_VOLUME_MAX

Maximal volume for a deal

double

SYMBOL_VOLUME_STEP

Minimal volume change step for deal execution

double

SYMBOL_VOLUME_LIMIT

Not supported

double

SYMBOL_SWAP_LONG

Buy order swap value

double

SYMBOL_SWAP_SHORT

Sell order swap value

double

SYMBOL_MARGIN_INITIAL

Initial margin means the amount in the margin currency required for opening an order with the volume of one lot. It is used for checking a client's assets when he or she enters the market.

double

SYMBOL_MARGIN_MAINTENANCE

The maintenance margin. If it is set, it sets the margin amount in the margin currency of the symbol, charged from one lot. It is used for checking a client's assets when his/her account state changes. If the maintenance margin is equal to 0, the initial margin is used.

double

SYMBOL_MARGIN_LONG

Not supported

double

SYMBOL_MARGIN_SHORT

Not supported

double

SYMBOL_MARGIN_LIMIT

Not supported

double

SYMBOL_MARGIN_STOP

Not supported

double

SYMBOL_MARGIN_STOPLIMIT

Not supported

double

SYMBOL_SESSION_VOLUME

Not supported

double

SYMBOL_SESSION_TURNOVER

Not supported

double

SYMBOL_SESSION_INTEREST

Not supported

double

SYMBOL_SESSION_BUY_ORDERS_VOLUME

Not supported

double

SYMBOL_SESSION_SELL_ORDERS_VOLUME

Not supported

double

SYMBOL_SESSION_OPEN

Not supported

double

SYMBOL_SESSION_CLOSE

Not supported

double

SYMBOL_SESSION_AW

Not supported

double

SYMBOL_SESSION_PRICE_SETTLEMENT

Not supported

double

SYMBOL_SESSION_PRICE_LIMIT_MIN

Not supported

double

SYMBOL_SESSION_PRICE_LIMIT_MAX

Not supported

double

For function SymbolInfoString():

ENUM_SYMBOL_INFO_STRING

Identifier

Description

Type

SYMBOL_CURRENCY_BASE

Basic currency of a symbol

string

SYMBOL_CURRENCY_PROFIT

Profit currency

string

SYMBOL_CURRENCY_MARGIN

Margin currency

string

SYMBOL_DESCRIPTION

Symbol description

string

SYMBOL_PATH

Path in the symbol tree

string

There are several symbol trading modes. Information about trading modes of a certain symbol is reflected in the values of enumeration ENUM_SYMBOL_TRADE_MODE.

ENUM_SYMBOL_TRADE_MODE

Identifier

Description

SYMBOL_TRADE_MODE_DISABLED

Trade is disabled for the symbol

SYMBOL_TRADE_MODE_LONGONLY*

Allowed only long positions

SYMBOL_TRADE_MODE_SHORTONLY*

Allowed only short positions

SYMBOL_TRADE_MODE_CLOSEONLY

Allowed only position close operations

SYMBOL_TRADE_MODE_FULL

No trade restrictions

Possible deal execution modes for a certain symbol are defined in enumeration ENUM_SYMBOL_TRADE_EXECUTION.

ENUM_SYMBOL_TRADE_EXECUTION

Identifier

Description

SYMBOL_TRADE_EXECUTION_REQUEST

Execution by request

SYMBOL_TRADE_EXECUTION_INSTANT

Instant execution

SYMBOL_TRADE_EXECUTION_MARKET

Market execution

SYMBOL_TRADE_EXECUTION_EXCHANGE*

Exchange execution

*These values are not used in MQL4 (added for compatibility with MQL5).

Values of the ENUM_DAY_OF_WEEK enumeration are used for specifying days of week.

ENUM_DAY_OF_WEEK

Identifier

Description

SUNDAY

Sunday

MONDAY

Monday

TUESDAY

Tuesday

WEDNESDAY

Wednesday

THURSDAY

Thursday

FRIDAY

Friday

SATURDAY

Saturday