Can I get the properties from code?

 

Steps:

1. Define the property like this:

#property version "1.00"

2. How can I get version from code? Like Print("Current version: "+property.version)?

 

It's not documented and I didn't know it was even possible, until I saw the indicator below using the property name as a predefined variable name.

#property copyright "Alexander Elgin"
#property link      "alexmost113@mail.ru"
#define INDICATOR_NAME "Fractal Support Resistance"

#property indicator_color1 Green
#property indicator_style1 STYLE_DOT#property indicator_color5 FireBrick
#property indicator_style5 STYLE_SOLIDint styles[PERIODS_NUMBER] = {indicator_style1, indicator_style2, indicator_style3, indicator_style4, indicator_style5};
color colors[PERIODS_NUMBER] = {indicator_color1, indicator_color2, indicator_color3, indicator_color4, indicator_color5};
Unfortunately it doesn't work with version (MT4 1170,) but it's not necessary, either.
#define VERSION "123.0"
#property version VERSION
⋮
   Print(VERSION);
 
William Roeder:

It's not documented and I didn't know it was even possible, until I saw the indicator below using the property name as a predefined variable name.

Unfortunately it doesn't work with version (MT4 1170,) but it's not necessary, either.

I used this method before until MQL upgraded editor to have project. A project has a GUI for version setting. Please see my attached picture. The definition of "#property version" in code is conflict with version in GUI. One have to modify 3 places to maintain the project. It's tired.

GUI
 
Amy Liu:

I used this method before until MQL upgraded editor to have project. A project has a GUI for version setting. Please see my attached picture. The definition of "#property version" in code is conflict with version in GUI. One have to modify 3 places to maintain the project. It's tired.

From my experience "project" is not usable in practice due to several similar "features". Reported to Metaquotes on Russian forum but no answer.

The project version should not be used for the underlying source code version.
 
Alain Verleyen:

From my experience "project" is not usable in practice due to several similar "features". Reported to Metaquotes on Russian forum but no answer.

The project version should not be used for the underlying source code version.

Thank you Alain.

 

Ha ~ I get same request
If we can make suggest to Metaquotes make this as a new feature? 

This can help us.

 

useful information, thanks for sharing guys :-)


@METAQUOTE could you please add enumeration of #property items and reading of their values in MQL4/5 ?
 
As far as I know, #property is equal to #define as for the code.
So you can ask #ifdef and get the info this way into your code.
At least I use it this way.


 
Dominik Egert: As far as I know, #property is equal to #define as for the code. So you can ask #ifdef and get the info this way into your code. At least I use it this way.

Only some of the "properties" work that way. Things like Indicator properties ("indicator_buffers", "indicator_label", "indicator_color", etc.) work as you describe but others like "version" or "copyright" do not.

EDIT: This is the case for current builds MT4 (build 1335) and MT5 (build 2940).

 
Good to know. Thank you.

I use defines to set all properties, therefore I have solved it the other way around.

I did not know there are difference.