Symbol Properties
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
|
|
|
|
SYMBOL_SELECT
|
Symbol is selected in Market Watch
|
bool
|
SYMBOL_SESSION_DEALS
|
Number of deals in the current session
|
long
|
SYMBOL_SESSION_BUY_ORDERS
|
Number of Buy orders at the moment
|
long
|
SYMBOL_SESSION_SELL_ORDERS
|
Number of Sell orders at the moment
|
long
|
SYMBOL_VOLUME
|
Volume of the last deal
|
long
|
SYMBOL_VOLUMEHIGH
|
Maximal day volume
|
long
|
SYMBOL_VOLUMELOW
|
Minimal day volume
|
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_TICKS_BOOKDEPTH
|
Maximal number of requests shown in Depth of Market. For symbols that have no queue of requests, the value is equal to zero.
|
int
|
SYMBOL_TRADE_CALC_MODE
|
Contract price calculation mode
|
ENUM_SYMBOL_CALC_MODE
|
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
|
ENUM_SYMBOL_SWAP_MODE
|
SYMBOL_SWAP_ROLLOVER3DAYS
|
Weekday to charge 3 days swap rollover
|
ENUM_DAY_OF_WEEK
|
SYMBOL_EXPIRATION_MODE
|
Flags of allowed order expiration modes
|
int
|
SYMBOL_FILLING_MODE
|
Flags of allowed order filling modes
|
int
|
For function SymbolInfoDouble()
ENUM_SYMBOL_INFO_DOUBLE
|
|
|
|
SYMBOL_BID
|
Bid - best sell offer
|
double
|
SYMBOL_BIDHIGH
|
Maximal Bid of the day
|
double
|
SYMBOL_BIDLOW
|
Minimal Bid of the day
|
double
|
SYMBOL_ASK
|
Ask - best buy offer
|
double
|
SYMBOL_ASKHIGH
|
Maximal Ask of the day
|
double
|
SYMBOL_ASKLOW
|
Minimal Ask of the day
|
double
|
SYMBOL_LAST
|
Price of the last deal
|
double
|
SYMBOL_LASTHIGH
|
Maximal Last of the day
|
double
|
SYMBOL_LASTLOW
|
Minimal Last of the day
|
double
|
SYMBOL_POINT
|
Symbol point value
|
double
|
SYMBOL_TRADE_TICK_VALUE
|
Value of SYMBOL_TRADE_TICK_VALUE_PROFIT
|
double
|
SYMBOL_TRADE_TICK_VALUE_PROFIT
|
Calculated tick price for a profitable position
|
double
|
SYMBOL_TRADE_TICK_VALUE_LOSS
|
Calculated tick price for a losing position
|
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
|
Maximum allowed aggregate volume of an open position and pending orders in one direction (buy or sell) for the symbol. For example, with the limitation of 5 lots, you can have an open buy position with the volume of 5 lots and place a pending order Sell Limit with the volume of 5 lots. But in this case you cannot place a Buy Limit pending order (since the total volume in one direction will exceed the limitation) or place Sell Limit with the volume more than 5 lots.
|
double
|
SYMBOL_SWAP_LONG
|
Long swap value
|
double
|
SYMBOL_SWAP_SHORT
|
Short swap value
|
double
|
SYMBOL_MARGIN_INITIAL
|
Initial margin means the amount in the margin currency required for opening a position 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
|
Rate of margin charging on long positions
|
double
|
SYMBOL_MARGIN_SHORT
|
Rate of margin charging on short positions
|
double
|
SYMBOL_MARGIN_LIMIT
|
Rate of margin charging on Limit orders
|
double
|
SYMBOL_MARGIN_STOP
|
Rate of margin charging on Stop orders
|
double
|
SYMBOL_MARGIN_STOPLIMIT
|
Rate of margin charging on Stop Limit orders
|
double
|
SYMBOL_SESSION_VOLUME
|
Summary volume of current session deals
|
double
|
SYMBOL_SESSION_TURNOVER
|
Summary turnover of the current session
|
double
|
SYMBOL_SESSION_INTEREST
|
Summary open interest
|
double
|
SYMBOL_SESSION_BUY_ORDERS_VOLUME
|
Current volume of Buy orders
|
double
|
SYMBOL_SESSION_SELL_ORDERS_VOLUME
|
Current volume of Sell orders
|
double
|
SYMBOL_SESSION_OPEN
|
Open price of the current session
|
double
|
SYMBOL_SESSION_CLOSE
|
Close price of the current session
|
double
|
SYMBOL_SESSION_AW
|
Average weighted price of the current session
|
double
|
SYMBOL_SESSION_PRICE_SETTLEMENT
|
Settlement price of the current session
|
double
|
SYMBOL_SESSION_PRICE_LIMIT_MIN
|
Minimal price of the current session
|
double
|
SYMBOL_SESSION_PRICE_LIMIT_MAX
|
Maximal price of the current session
|
double
|
For function SymbolInfoString()
ENUM_SYMBOL_INFO_STRING
|
|
|
|
SYMBOL_CURRENCY_BASE
|
Basic currency of a symbol
|
string
|
SYMBOL_CURRENCY_PROFIT
|
Profit currency
|
string
|
SYMBOL_CURRENCY_MARGIN
|
Margin currency
|
string
|
SYMBOL_BANK
|
Feeder of the current quote
|
string
|
SYMBOL_DESCRIPTION
|
Symbol description
|
string
|
SYMBOL_PATH
|
Path in the symbol tree
|
string
|
For each symbol several expiration modes of pending orders can be specified. A flag is matched to each mode. Flags can be combined using the operation of logical OR (|), for example, SYMBOL_EXPIRATION_GTC|SYMBOL_EXPIRATION_SPECIFIED. In order to check whether a certain mode is allowed for the symbol, the result of the logical AND (&) should be compared to the mode flag.
If flag SYMBOL_EXPIRATION_SPECIFIED is specified for a symbol, then while sending a pending order, you may specify the moment this pending order is valid till.
|
|
|
|
SYMBOL_EXPIRATION_GTC
|
1
|
The order is valid during the unlimited time period, until it is explicitly canceled
|
SYMBOL_EXPIRATION_DAY
|
2
|
The order is valid till the end of the day
|
SYMBOL_EXPIRATION_SPECIFIED
|
4
|
The expiration time is specified in the order
|
SYMBOL_EXPIRATION_SPECIFIED_DAY
|
8
|
The expiration date is specified in the order
|
Example:
//+------------------------------------------------------------------+
//| Checks if the specified expiration mode is allowed |
//+------------------------------------------------------------------+
bool IsExpirationTypeAllowed(string symbol,int exp_type)
{
//--- Obtain the value of the property that describes allowed expiration modes
int expiration=(int)SymbolInfoInteger(symbol,SYMBOL_EXPIRATION_MODE);
//--- Return true, if mode exp_type is allowed
return((expiration&exp_type)==exp_type);
} |
When sending an order, you can specify the filling policy for the volume set in the order. Allowed order filling modes for each symbol are specified in the table. You can set several modes for one symbol by combining flags. The flags can be combined by the operation of the logical OR (|), for example, SYMBOL_FILLING_ALL_OR_NONE|SYMBOL_CANCEL_REMAIND. In order to check whether a certain mode is allowed for the symbol, the result of the logical AND (&) should be compared to the mode flag.
|
|
|
|
SYMBOL_FILLING_ALL_OR_NONE
|
1
|
"All or none". If the volume specified in the order with the specified price cannot be fully filled, the order is canceled and the deal is not conducted
|
SYMBOL_CANCEL_REMAIND
|
2
|
If only part of the specified volume can be filled, the deal for the available volume will be executed. The order remainder is canceled, and the new order is not placed
|
SYMBOL_RETURN_REMAIND
|
4
|
A deal is executed for the available volume. A new order at the same price is set for the remainder
|
Example:
//+------------------------------------------------------------------+
//| Checks if the specified filling mode is allowed |
//+------------------------------------------------------------------+
bool IsFillingTypeAllowed(string symbol,int fill_type)
{
//--- Obtain the value of the property that describes allowed expiration modes
int filling=(int)SymbolInfoInteger(symbol,SYMBOL_FILLING_MODE);
//--- Return true, if mode fill_type is allowed
return((filling & fill_type)==fill_type);
} |
The ENUM_SYMBOL_CALC_MODE enumeration is used for obtaining information about how the margin requirements for a symbol are calculated.
ENUM_SYMBOL_CALC_MODE
|
|
|
|
SYMBOL_CALC_MODE_FOREX
|
Forex mode - calculation of profit and margin for Forex
|
Margin: Lots*Contract_Size/Leverage
Profit: (close_price-open_price)*Contract_Size*Lots
|
SYMBOL_CALC_MODE_FUTURES
|
Futures mode - calculation of margin and profit for futures
|
Margin: Lots *InitialMargin*Percentage/100
Profit: (close_price-open_price)*TickPrice/TickSize*Lots
|
SYMBOL_CALC_MODE_CFD
|
CFD mode - calculation of margin and profit for CFD
|
Margin: Lots *ContractSize*MarketPrice*Percentage/100
Profit: (close_price-open_price)*Contract_Size*Lots
|
SYMBOL_CALC_MODE_CFDINDEX
|
CFD index mode - calculation of margin and profit for CFD by indexes
|
Margin: (Lots*ContractSize*MarketPrice)*TickPrice/TickSize
Profit: (close_price-open_price)*Contract_Size*Lots
|
SYMBOL_CALC_MODE_CFDLEVERAGE
|
CFD Leverage mode - calculation of margin and profit for CFD at leverage trading
|
Margin: (Lots*ContractSize*MarketPrice*Percentage)/Leverage
Profit: (close_price-open_price)*Contract_Size*Lots
|
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
|
|
|
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
|
|
|
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
|
Methods of swap calculation at position transfer are specified in enumeration ENUM_SYMBOL_SWAP_MODE.
ENUM_SYMBOL_SWAP_MODE
|
|
|
SYMBOL_SWAP_MODE_DISABLED
|
Swap mode disabled (no swaps)
|
SYMBOL_SWAP_MODE_BY_POINTS
|
Swaps in points
|
SYMBOL_SWAP_MODE_BY_MONEY
|
Swaps in money, its value is specified in the symbol properties in the deposit currency
|
SYMBOL_SWAP_MODE_BY_INTEREST
|
Swaps in yearly percents (bank mode - 360 days in a year)
|
SYMBOL_SWAP_MODE_BY_MARGIN_CURRENCY
|
Swaps in money, its value is specified in the symbol properties in the margin currency
|
Values of the ENUM_DAY_OF_WEEK enumeration are used for specifying weekdays.
ENUM_DAY_OF_WEEK
|
|
|
SUNDAY
|
Sunday
|
MONDAY
|
Monday
|
TUESDAY
|
Tuesday
|
WEDNESDAY
|
Wednesday
|
THURSDAY
|
Thursday
|
FRIDAY
|
Friday
|
SATURDAY
|
Saturday
|
|