Download MetaTrader 5

SymbolInfoDouble : what's that phenomenom ?

To add comments, please log in or register
Publish your article. We will translate it into other languages!
Icham Aidibe
10044
Icham Aidibe 2014.10.30 17:03 

Hi there !

Need help (quite quickly !), lost money because of ...

   double LastPrice=SymbolInfoDouble(Symbol(),SYMBOL_LAST);
   printf("Prix actuel : %G", LastPrice);

----------> Returns : 
2014.10.30 16:01:02.979 Prix actuel : 0

Did I miss something ? Is there anyway to return the current price (ask/bid) ? 


EDIT : do I have to write to the service desk, it seems to me the syntax is definitively good ?

Alain Verleyen
Moderator
30744
Alain Verleyen 2014.10.30 17:11  
blouf:

Hi there !

Need help (quite quickly !), lost money because of ...

Did I miss something ? Is there anyway to return the current price (ask/bid) ?

See SymbolInfoDouble()  documentation :

Note

It is recommended to use SymbolInfoTick() if the function is used for getting information about the last tick. It may well be that not a single quote has appeared yet since the terminal is connected to a trading account. In such a case, the requested value will be indefinite.

In most cases, it is enough to use SymbolInfoTick() function allowing a user to receive the values of Ask, Bid, Last, Volume and the time of the last tick's arrival during a single call.

When you are using a function, you ALWAYS have to check the returned value. I don't know why you got a value of 0 but obviously there was an error.

P.S: It seems it's common situation.

Alain Verleyen
Moderator
30744
Alain Verleyen 2014.10.30 17:20  
blouf:

Hi there !

Need help (quite quickly !), lost money because of ...

Did I miss something ? Is there anyway to return the current price (ask/bid) ? 


EDIT : do I have to write to the service desk, it seems to me the syntax is definitively good ?

See also https://www.mql5.com/en/forum/18935
Icham Aidibe
10044
Icham Aidibe 2014.10.30 17:24  
angevoyageur:

See SymbolInfoDouble()  documentation :

When you are using a function, you ALWAYS have to check the returned value. I don't know why you got a value of 0 but obviously there was an error.

Checking always the returned value is kinda ... errrr ... I either don't know why, I will write to the service desk. How am I supposed to use SymbolInfoTick ?

   MqlTick Tick;
   double LastPrice=SymbolInfoTick(Symbol(),Tick.ask);

Debug :

'ask' - parameter conversion not allowed
Alain Verleyen
Moderator
30744
Alain Verleyen 2014.10.30 17:32  
blouf:

Checking always the returned value is kinda ... errrr ... I either don't know why, I will write to the service desk.

It's good programming practice. But you are free to do it or not :-)

How am I supposed to use SymbolInfoTick ?

Debug :

See an example here.
Icham Aidibe
10044
Icham Aidibe 2014.10.30 17:37  
angevoyageur:
It's good programming practice. But you are free to do it or not :-)

See an example here.
Indeed, it's a good a habit to have, I do it differently, I write the code, test it and read the debug windows. But such an error ... on such a platform, with such the money I lost ... I may change my habits :/
To add comments, please log in or register