Extern does not work in MQL5?

 

Hello,


I am trying to use extern instead of Input because i am changing it value later on the code.


I am getting an error : extern variable initialization is not allowed 

 
anuj71:

Hello,


I am trying to use extern instead of Input because i am changing it value later on the code.


I am getting an error : extern variable initialization is not allowed 

Please read the documentation.

MQL5 extern is comparable to C/C++ extern keyword.

MQL4 uses the keyword for a different functionality.

They are not compatible.

In MQL5 there is no way of changing an input variable. They are considered const.
 
Dominik Egert #:
In MQL5 there is no way of changing an input variable. They are considered const.

Ok, So, what is alternative way? any idea.


Let say, i setup input SL = 10, later if i want to change something like this if(SL < StopLevel) SL= StopLevel;. How can i do that?

 
anuj71 #:

Ok, So, what is alternative way? any idea.


Let say, i setup input SL = 10, later if i want to change something like this if(SL < StopLevel) SL= StopLevel;. How can i do that?

Have a global variable in the program, assign the input to it and use that instead of the input variable.

Better would be, you "rage-quit" the app and tell the user to input proper settings, telling him what values are valid.


Reason: