SYMBOL_TRADE_CALC_MODE returned values

 

I can't find a clear documentation about the values returned by the SYMBOL_TRADE_CALC_MODE.

Print(SymbolInfoInteger(_Symbol, SYMBOL_TRADE_CALC_MODE));

would result in 0 for forex (I guess), 2 for CFDs.. do you guys have faced a similar situation?

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Leandro Norcini: I can't find a clear documentation about the values returned by the SYMBOL_TRADE_CALC_MODE. would result in 0 for forex (I guess), 2 for CFDs.. do you guys have faced a similar situation?

What do you mean? It is right there in the documentation and it is very clear ... Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties

And please don't use "0" or "2". Use the enumerations (see below) ...

SYMBOL_TRADE_CALC_MODE

Contract price calculation mode

ENUM_SYMBOL_CALC_MODE

ENUM_SYMBOL_CALC_MODE

Identifier

Description

Formula

SYMBOL_CALC_MODE_FOREX

Forex mode - calculation of profit and margin for Forex

Margin:  Lots * Contract_Size / Leverage * Margin_Rate

 

Profit:   (close_price - open_price) * Contract_Size*Lots

SYMBOL_CALC_MODE_FOREX_NO_LEVERAGE

Forex No Leverage mode – calculation of profit and margin for Forex symbols without taking into account the leverage

Margin:  Lots * Contract_Size * Margin_Rate

 

Profit:   (close_price - open_price) * Contract_Size * Lots

SYMBOL_CALC_MODE_FUTURES

Futures mode - calculation of margin and profit for futures

Margin: Lots * InitialMargin * Margin_Rate

 

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 * Margin_Rate

 

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 * Margin_Rate

 

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) / Leverage * Margin_Rate

 

Profit:  (close_price-open_price) * Contract_Size * Lots

SYMBOL_CALC_MODE_EXCH_STOCKS

Exchange mode – calculation of margin and profit for trading securities on a stock exchange

Margin: Lots * ContractSize * LastPrice * Margin_Rate

 

Profit:  (close_price - open_price) * Contract_Size * Lots

SYMBOL_CALC_MODE_EXCH_FUTURES

Futures mode –  calculation of margin and profit for trading futures contracts on a stock exchange

Margin: Lots * InitialMargin * Margin_Rate or Lots * MaintenanceMargin * Margin_Rate

 

Profit:  (close_price - open_price) * Lots * TickPrice / TickSize

SYMBOL_CALC_MODE_EXCH_FUTURES_FORTS

FORTS Futures mode –  calculation of margin and profit for trading futures contracts on FORTS. The margin may be reduced by the amount of MarginDiscount deviation according to the following rules:

1. If the price of a long position (buy order) is less than the estimated price, MarginDiscount = Lots*((PriceSettle-PriceOrder)*TickPrice/TickSize)

2. If the price of a short position (sell order) exceeds the estimated price, MarginDiscount = Lots*((PriceOrder-PriceSettle)*TickPrice/TickSize)

where:

    • PriceSettle – estimated (clearing) price of the previous session;
    • PriceOrder – average weighted position price or open price set in the order (request);
    • TickPrice – tick price (cost of the price change by one point)
    • TickSize – tick size (minimum price change step)

Margin: Lots * InitialMargin * Margin_Rate or Lots * MaintenanceMargin * Margin_Rate * Margin_Rate

 

Profit:  (close_price - open_price) * Lots * TickPrice / TickSize

SYMBOL_CALC_MODE_EXCH_BONDS

Exchange Bonds mode – calculation of margin and profit for trading bonds on a stock exchange

Margin: Lots * ContractSize * FaceValue * open_price * /100

 

Profit:  Lots * close_price * FaceValue * Contract_Size  + AccruedInterest * Lots * ContractSize

SYMBOL_CALC_MODE_EXCH_STOCKS_MOEX

Exchange MOEX Stocks mode – calculation of margin and profit for trading securities on MOEX

Margin: Lots * ContractSize * LastPrice * Margin_Rate

 

Profit:  (close_price - open_price) * Contract_Size * Lots

SYMBOL_CALC_MODE_EXCH_BONDS_MOEX

Exchange MOEX Bonds mode – calculation of margin and profit for trading bonds on MOEX

Margin: Lots * ContractSize * FaceValue * open_price * /100

 

Profit:  Lots * close_price * FaceValue * Contract_Size  + AccruedInterest * Lots * ContractSize

SYMBOL_CALC_MODE_SERV_COLLATERAL

Collateral mode - a symbol is used as a non-tradable asset on a trading account. The market value of an open position is calculated based on the volume, current market price, contract size and liquidity ratio. The value is included into Assets, which are added to Equity. Open positions of such symbols increase the Free Margin amount and are used as additional margin (collateral) for open positions of tradable instruments.

Margin: no

Profit:  no

 

Market Value: Lots*ContractSize*MarketPrice*LiqudityRate

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Fernando Carreiro #:

What do you mean? It is right there in the documentation and it is very clear ... Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties

And please don't use "0" or "2". Use the enumerations (see below) ...

SYMBOL_TRADE_CALC_MODE

Contract price calculation mode

ENUM_SYMBOL_CALC_MODE

ENUM_SYMBOL_CALC_MODE

Identifier

Description

Formula

SYMBOL_CALC_MODE_FOREX

Forex mode - calculation of profit and margin for Forex

Margin:  Lots * Contract_Size / Leverage * Margin_Rate

 

Profit:   (close_price - open_price) * Contract_Size*Lots

SYMBOL_CALC_MODE_FOREX_NO_LEVERAGE

Forex No Leverage mode – calculation of profit and margin for Forex symbols without taking into account the leverage

Margin:  Lots * Contract_Size * Margin_Rate

 

Profit:   (close_price - open_price) * Contract_Size * Lots

SYMBOL_CALC_MODE_FUTURES

Futures mode - calculation of margin and profit for futures

Margin: Lots * InitialMargin * Margin_Rate

 

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 * Margin_Rate

 

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 * Margin_Rate

 

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) / Leverage * Margin_Rate

 

Profit:  (close_price-open_price) * Contract_Size * Lots

SYMBOL_CALC_MODE_EXCH_STOCKS

Exchange mode – calculation of margin and profit for trading securities on a stock exchange

Margin: Lots * ContractSize * LastPrice * Margin_Rate

 

Profit:  (close_price - open_price) * Contract_Size * Lots

SYMBOL_CALC_MODE_EXCH_FUTURES

Futures mode –  calculation of margin and profit for trading futures contracts on a stock exchange

Margin: Lots * InitialMargin * Margin_Rate or Lots * MaintenanceMargin * Margin_Rate

 

Profit:  (close_price - open_price) * Lots * TickPrice / TickSize

SYMBOL_CALC_MODE_EXCH_FUTURES_FORTS

FORTS Futures mode –  calculation of margin and profit for trading futures contracts on FORTS. The margin may be reduced by the amount of MarginDiscount deviation according to the following rules:

1. If the price of a long position (buy order) is less than the estimated price, MarginDiscount = Lots*((PriceSettle-PriceOrder)*TickPrice/TickSize)

2. If the price of a short position (sell order) exceeds the estimated price, MarginDiscount = Lots*((PriceOrder-PriceSettle)*TickPrice/TickSize)

where:

    • PriceSettle – estimated (clearing) price of the previous session;
    • PriceOrder – average weighted position price or open price set in the order (request);
    • TickPrice – tick price (cost of the price change by one point)
    • TickSize – tick size (minimum price change step)

Margin: Lots * InitialMargin * Margin_Rate or Lots * MaintenanceMargin * Margin_Rate * Margin_Rate

 

Profit:  (close_price - open_price) * Lots * TickPrice / TickSize

SYMBOL_CALC_MODE_EXCH_BONDS

Exchange Bonds mode – calculation of margin and profit for trading bonds on a stock exchange

Margin: Lots * ContractSize * FaceValue * open_price * /100

 

Profit:  Lots * close_price * FaceValue * Contract_Size  + AccruedInterest * Lots * ContractSize

SYMBOL_CALC_MODE_EXCH_STOCKS_MOEX

Exchange MOEX Stocks mode – calculation of margin and profit for trading securities on MOEX

Margin: Lots * ContractSize * LastPrice * Margin_Rate

 

Profit:  (close_price - open_price) * Contract_Size * Lots

SYMBOL_CALC_MODE_EXCH_BONDS_MOEX

Exchange MOEX Bonds mode – calculation of margin and profit for trading bonds on MOEX

Margin: Lots * ContractSize * FaceValue * open_price * /100

 

Profit:  Lots * close_price * FaceValue * Contract_Size  + AccruedInterest * Lots * ContractSize

SYMBOL_CALC_MODE_SERV_COLLATERAL

Collateral mode - a symbol is used as a non-tradable asset on a trading account. The market value of an open position is calculated based on the volume, current market price, contract size and liquidity ratio. The value is included into Assets, which are added to Equity. Open positions of such symbols increase the Free Margin amount and are used as additional margin (collateral) for open positions of tradable instruments.

Margin: no

Profit:  no

 

Market Value: Lots*ContractSize*MarketPrice*LiqudityRate

Ahhh thank you Fernando now I got it. The function returns a number that I wasn't able to associate to the Identifier and not the identifier itself, that's why I said that the documentation isn't clear.
 
Leandro Norcini #: Ahhh thank you Fernando now I got it. The function returns a number that I wasn't able to associate to the Identifier and not the identifier itself, that's why I said that the documentation isn't clear.

The documentation is quite clear and it states that it returns an enumeration. So you have to typecast it ...

ENUM_SYMBOL_CALC_MODE eCalcMode = (ENUM_SYMBOL_CALC_MODE) SymbolInfoInteger( _Symbol, SYMBOL_TRADE_CALC_MODE );
Print( EnumToString( eCalcMode ) );
 
Fernando Carreiro #: The documentation is quite clear and it states that it returns an enumeration. So you have to typecast it ...

Ooops so dumb 😫
Now I see it clearly, Thank You much!!