Download MetaTrader 5
To add comments, please log in or register
Find out how to install MetaTrader on Mac OS
theDUDE
43
theDUDE 2012.08.11 18:08 

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
683
Pawel Wojnarowski 2012.08.11 18:56  
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 2012.08.11 19:06  

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
683
Pawel Wojnarowski 2012.08.11 23:32  
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