What is different between Symbol() and _Symbol

 

Dear,

I want to know what is different between Symbol() function and _Symbol variable.


I know both return current symbol name. but which should i use.

 
Use Symbol(). _Symbol is only there for historical reason.
 
Alain Verleyen:
Use Symbol(). _Symbol is only there for historical reason.


Sorry Alain, i don't understand. can you give me some code example. what u mean historical reason?

 
mohdhamidraza :


Sorry Alain, i don't understand. can you give me some code example. what u mean historical reason?

Use Symbol (). _Symbol - Is the legacy of the early programming language.
 
mohdhamidraza:


Sorry Alain, i don't understand. can you give me some code example. what u mean historical reason?

Backward compatibility.
 
mohdhamidraza:


Sorry Alain, i don't understand. can you give me some code example. what u mean historical reason?

What Alain is saying is _Symbol is what they used to use before they updated MQL4 to be more like MQL5.  Now, Symbol() is there instead of it.  It basically replaced _Symbol, but is still here so programs written in the older style of language will still work, i.e. backward compatibility.
 
mohdhamidraza:

Dear,

I want to know what is different between Symbol() function and _Symbol variable.


I know both return current symbol name. but which should i use.

Me also...I know _Symbol in the MQL4 reference, "The _Symbol variable contains the symbol name of the current chart.",  and the Symbol(), "Returns the name of a symbol of the current chart." , which makes us believe that one contains and the other returns....However I hear my friend Kirill Eremenko from Forexboat.com (I actually bought a couple of courses from UDEMY.com) state Symbol() is "Universal".

 

Alain Verleyen:
Use Symbol(). _Symbol is only there for historical reason.

Fantastic. 

 
mohdhamidraza:


Sorry Alain, i don't understand. can you give me some code example. what u mean historical reason?

Slower...Sorry "historical reason" does not compute.. If you can tell yourself how it is stored historically then you will be enabled to answer the relevance of the question "What, historical reason?" How does the coding store historically?  You will solve this later; for now. 

 
JD4:
What Alain is saying is _Symbol is what they used to use before they updated MQL4 to be more like MQL5.  Now, Symbol() is there instead of it.  It basically replaced _Symbol, but is still here so programs written in the older style of language will still work, i.e. backward compatibility.

Oh "historical reason", you understand that it is something to do with coding progress or progressing with coding.  Also with the way that the OnInit was InIt; changes happen.  Symbol() is "Universal" in a way that it can be understood by both MQL4 and MQL5; most probably.

 
Alain Verleyen:
Backward compatibility.

According to https://whatis.techtarget.com/definition/backward-compatible-backward-compatibility

Backward compatible refers to a hardware or software system that can successfully use interfaces and data from earlier versions of the system or with other systems.

What is backward compatible (backward compatibility)? - Definition from WhatIs.com
What is backward compatible (backward compatibility)? - Definition from WhatIs.com
  • whatis.techtarget.com
Backward compatible (or sometimes backward-compatible or backwards compatible) refers to a hardware or software system that can successfully use interfaces and data from earlier versions of the system or with other systems. For example, Perl, the scripting language, was designed to be backward compatible with awk, an earlier language that Perl...
Reason: