Just started my journey MQ4 -> MQ5 .... lost! Little help please.

 

Ok, knew it would not be easy but even simple things are stumping me :-(

 How do I retrieve the Bid price?

I have...

 Comment(NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits));

Within the OnCalculate(...

and this is returning '0'

In another indi I tried it and worked fine and returned bid price so why not this time ??

 TIA.

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
 

Thanks for reply.

Me being me I want to plunge in and learn as I go.

I understand from the link that I could create an MT4.mqh to emulate the MT4 constants but I would rather learn the correct MT5 syntax. 

Just to humour me could you explain why the  Comment(NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits));

worked in 1 indi but returned a '0' in another?  What would be the likely cause? Or how would I track it down?

(I see a long journey ahead :-(  ) 

Thanks 

 
MadMik:

Thanks for reply.

Me being me I want to plunge in and learn as I go.

I understand from the link that I could create an MT4.mqh to emulate the MT4 constants but I would rather learn the correct MT5 syntax. 

Just to humour me could you explain why the  Comment(NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits));

worked in 1 indi but returned a '0' in another?  What would be the likely cause? Or how would I track it down?

(I see a long journey ahead :-(  ) 

Thanks 

The first thing to do is always to check the documentation first : SymbolInfoDouble()
 
angevoyageur:
The first thing to do is always to check the documentation first : SymbolInfoDouble()

Yep, had done that and gone around in circles!!

Head now hurts :-(

THE ANSWER!!....

The code was being saved to a different folder (Did not think of that did you!... neither did I) as I have a live and a demo account of MT5 and was testing in demo but code was being updated in live.

Onward..... 

 
MadMik:

Yep, had done that and gone around in circles!!

Head now hurts :-(

THE ANSWER!!....

The code was being saved to a different folder (Did not think of that did you!... neither did I) as I have a live and a demo account of MT5 and was testing in demo but code was being updated in live.

Onward..... 

If you get 0 as value, that means you have an error, you have to check which one :

Return Value

The value of double type. In case of execution failure, information about the error can be obtained using GetLastError() function:

5040 – invalid string parameter for specifying a symbol name,

4301 – unknown symbol (financial instrument),

4302 – symbol is not selected in "Market Watch" (not found in the list of available ones),

4303 – invalid identifier of a symbol property.

Reason: