Download MetaTrader 5

any difference????

To add comments, please log in or register
theDUDE
43
theDUDE  

I'm just wondering if there is any difference between the two lines of code below.... (for calculating the spread)



1:

double Spread_1=NormalizeDouble(SymbolInfoDouble(Symbol(),SYMBOL_ASK) - SymbolInfoDouble(Symbol(),SYMBOL_BID),_Digits);

_______________

2:

MqlTick current_price;

double Spread_2=NormalizeDouble((current_price.ask-current_price.bid),_Digits);

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Symbol Properties - Documentation on MQL5
Pawel Wojnarowski
685
Pawel Wojnarowski  
IMHO there shouldn't be any difference, unless there is a difference in execution time of both approaches. Possibly a good idea would be to create 2 separate functions, loop each of them e.g. a 100 times in the script and run it in the profiler to see the execution time. If such test proves that there really is a difference in execution time, I'd expect #2 to be slightly faster.
theDUDE
43
theDUDE  

When you go to the documentation page for 'ENUM_SYMBOL_INFO_DOUBLE', and look at the description for 'SYMBOL_BID', it says that it gives the best sell offer.

What the hell does 'best' mean, are there more than one bid offers? Confused.... :-(

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Symbol Properties - Documentation on MQL5
Pawel Wojnarowski
685
Pawel Wojnarowski  
theDUDE:

When you go to the documentation page for 'ENUM_SYMBOL_INFO_DOUBLE', and look at the description for 'SYMBOL_BID', it says that it gives the best sell offer.

What the hell does 'best' mean, are there more than one bid offers? Confused.... :-(

It just refers to current prices at the market. Probably the phrasing of this description is a little bit unfortunate. However, nothing to do with MQL5 itself. 
To add comments, please log in or register