Usage difference between MarketInfo() & SymbolInfoDouble()

 

Hi,

I wonder if this has been discussed before but I didn't find anything in google. From my research, the following 2 declarations seem to be doing the same thing.

double Ticksize1 = MarketInfo(Symbol(), MODE_TICKSIZE);
double Ticksize2 = SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_SIZE);

So is there any obvious reason / advantage to use one over the other?

Much thanks.

 
For me, no. But usually it is more to coding preference. Though, symbolinfodouble might gain in usage popularity soon enough.
 
I just feel that as MarketInfo is the Older form in Mql4, it may be the first to be phased out, so best use the newer version, just in case.
 
BigFisherman:

Hi,

I wonder if this has been discussed before but I didn't find anything in google. From my research, the following 2 declarations seem to be doing the same thing.

So is there any obvious reason / advantage to use one over the other?

Much thanks.

If you want to code something who works on MT4 and MT5, better to use SymbolInfoDouble(), otherwise no difference.
 
MarketInfo returns everything as doubles. SymbolInfoX returns an X. Accuracy, type checking, no int to double to int, etc.
 
WHRoeder:
MarketInfo returns everything as doubles. SymbolInfoX returns an X. Accuracy, type checking, no int to double to int, etc.

SymbolInfoInteger returns a long
 

Good to know, thanks for the info guys.

And this goes to another question, I'm currently using the following code snippets to get my "price step" of any instrument (for OrderSend() & OrderModify() in Forex, metals, CFDs, etc).

//... (EntryPrice calculation..)

double PriceStep = SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_SIZE);
EntryPrice = NormalizeDouble( EntryPrice / PriceStep, 0) * PriceStep;

//...

However as we know Ticksize taken from MarketInfo() or SymbolInfoDouble() tends to jump more than a tick once in awhile. So am I right to presume that there's also a chance the above code may result in having very slight inaccurate "Price step" as well? I was wondering if there's a better way of coding to get the "price step" / a single ticksize?

 
BigFisherman:

Good to know, thanks for the info guys.

And this goes to another question, I'm currently using the following code snippets to get my "price step" of any instrument (for OrderSend() & OrderModify() in Forex, metals, CFDs, etc).

However as we know Ticksize taken from MarketInfo() or SymbolInfoDouble() tends to jump more than a tick once in awhile. So am I right to presume that there's also a chance the above code may result in having very slight inaccurate "Price step" as well? I was wondering if there's a better way of coding to get the "price step" / a single ticksize?

What do you mean ?
EntryPrice = MathFloor( EntryPrice / PriceStep) * PriceStep;
 
  1. The market can jump more than a tick, but ticksize is a constant.
  2. You only have to normalize price for pending orders. See https://www.mql5.com/en/forum/146370
 
angevoyageur:
If you want to code something who works on MT4 and MT5, better to use SymbolInfoDouble(), otherwise no difference.


For me, it appears that SymbolInfoDouble() isn't a complete replacement to MarketInfo(). In particular, I have a b509 function that determines whether I have enough free margin to open and maintain a trade, given all other open trades. That function uses MarketInfo(Symbol(), MODE_MARGINREQUIRED) to determine how much free margin I need per 1 standard lot to open the trade. As I am upgrading some of my functions to b625+, I have found that SymbolInfoDouble() doesn't seem to provide that same piece of information. For example:

Print ("Using SymbolInfoDouble() -");
Print ("Initial Margin: ", DoubleToStr(SymbolInfoDouble(_Symbol, SYMBOL_MARGIN_INITIAL), 2));
Print ("Maintenance Margin: ", DoubleToStr(SymbolInfoDouble(_Symbol, SYMBOL_MARGIN_MAINTENANCE), 2));
Print ("Long Order Margin: ", DoubleToStr(SymbolInfoDouble(_Symbol, SYMBOL_MARGIN_LONG), 2));
Print ("Short Order Margin: ", DoubleToStr(SymbolInfoDouble(_Symbol, SYMBOL_MARGIN_SHORT), 2));
Print ("Limit Order Margin: ", DoubleToStr(SymbolInfoDouble(_Symbol, SYMBOL_MARGIN_LIMIT), 2));
Print ("Stop Order Margin: ", DoubleToStr(SymbolInfoDouble(_Symbol, SYMBOL_MARGIN_STOP), 2));
Print ("Stop/Limit Order Margin: ", DoubleToStr(SymbolInfoDouble(_Symbol, SYMBOL_MARGIN_STOPLIMIT), 2));
Print ("Using MarketInfo() -");
Print ("Initial Margin: ", DoubleToStr(MarketInfo(_Symbol, MODE_MARGININIT), 2));
Print ("Maintenance Margin: ", DoubleToStr(MarketInfo(_Symbol, MODE_MARGINMAINTENANCE), 2));
Print ("Required Margin: ", DoubleToStr(MarketInfo(_Symbol, MODE_MARGINREQUIRED), 2));

15:56:59 TestEA-1 EURUSD,H1: Using SymbolInfoDouble() -

15:56:59 TestEA-1 EURUSD,H1: Initial Margin: 100000.00

15:56:59 TestEA-1 EURUSD,H1: Maintenance Margin: 100000.00

15:56:59 TestEA-1 EURUSD,H1: Long Order Margin: 0.00

15:56:59 TestEA-1 EURUSD,H1: Short Order Margin: 0.00

15:56:59 TestEA-1 EURUSD,H1: Limit Order Margin: 0.00

15:56:59 TestEA-1 EURUSD,H1: Stop Order Margin: 0.00

15:56:59 TestEA-1 EURUSD,H1: Stop/Limit Order Margin: 0.00

15:56:59 TestEA-1 EURUSD,H1: Using MarketInfo() -

15:56:59 TestEA-1 EURUSD,H1: Initial Margin: 100000.00

15:56:59 TestEA-1 EURUSD,H1: Maintenance Margin: 100000.00

15:56:59 TestEA-1 EURUSD,H1: Required Margin: 3200.00

I'm not sure yet whether this is a MT4/MQL issue or if the problem resides with my broker (I have a regulated U.S. broker which has offices/branches in several other countries). So, for now, I'm continuing to use MarketInfo() for some information.

 
Thirteen:


For me, it appears that SymbolInfoDouble() isn't a complete replacement to MarketInfo(). In particular, I have a b509 function that determines whether I have enough free margin to open and maintain a trade, given all other open trades. That function uses MarketInfo(Symbol(), MODE_MARGINREQUIRED) to determine how much free margin I need per 1 standard lot to open the trade. As I am upgrading some of my functions to b625+, I have found that SymbolInfoDouble() doesn't seem to provide that same piece of information. For example:

15:56:59 TestEA-1 EURUSD,H1: Using SymbolInfoDouble() -

15:56:59 TestEA-1 EURUSD,H1: Initial Margin: 100000.00

15:56:59 TestEA-1 EURUSD,H1: Maintenance Margin: 100000.00

15:56:59 TestEA-1 EURUSD,H1: Long Order Margin: 0.00

15:56:59 TestEA-1 EURUSD,H1: Short Order Margin: 0.00

15:56:59 TestEA-1 EURUSD,H1: Limit Order Margin: 0.00

15:56:59 TestEA-1 EURUSD,H1: Stop Order Margin: 0.00

15:56:59 TestEA-1 EURUSD,H1: Stop/Limit Order Margin: 0.00

15:56:59 TestEA-1 EURUSD,H1: Using MarketInfo() -

15:56:59 TestEA-1 EURUSD,H1: Initial Margin: 100000.00

15:56:59 TestEA-1 EURUSD,H1: Maintenance Margin: 100000.00

15:56:59 TestEA-1 EURUSD,H1: Required Margin: 3200.00

I'm not sure yet whether this is a MT4/MQL issue or if the problem resides with my broker (I have a regulated U.S. broker which has offices/branches in several other countries). So, for now, I'm continuing to use MarketInfo() for some information.

Don't know either. My previous answer was about the initial question with tick size. With mql5 there is a function OrderCalcMargin().