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.
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?
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?
EntryPrice = MathFloor( EntryPrice / PriceStep) * PriceStep;
- The market can jump more than a tick, but ticksize is a constant.
- You only have to normalize price for pending orders. See https://www.mql5.com/en/forum/146370
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.
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.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.