Hello,
when ii try to change the value of a setting "input Takeprofit" then i get the compiler error message "constant cannot be modified" but why? It was always possible in the mql4 language to change the value of such a extern setting parameter.
Is there a solution? I am thinking to write again the old style "extern Takeprofit" then it does work. But why with "input" it does not work or does i make somethink wrong?
Hello,
when ii try to change the value of a setting "input Takeprofit" then i get the compiler error message "constant cannot be modified" but why? It was always possible in the mql4 language to change the value of such a extern setting parameter.
Is there a solution? I am thinking to write again the old style "extern Takeprofit" then it does work. But why with "input" it does not work or does i make somethink wrong?
Because "input" parameters are read only. If you want to use a new feature, I strongly suggest you to read the documentation.
The input storage class defines the external variable. The input modifier is indicated before the data type. A variable with the input modifier can't be changed inside mql4-programs, such variables can be accessed for reading only. Values of input variables can be changed only by a user from the program properties window.
Add new variable TakeProfit2, copy value of TakeProfit input to TakeProfit2, then modify and use TakeProfit2 in the code.
that was also a way i was thinking, but i did wonder why it was not more possible to change the variable when i use the "input" declaration
The documentation is clear | https://docs.mql4.com/en/basis/variables/inputvariables | A variable with the input modifier can't be changed inside mql4-programs, such variables can be accessed for reading only. Values of input variables can be changed only by a user from the program properties window |
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
when ii try to change the value of a setting "input Takeprofit" then i get the compiler error message "constant cannot be modified" but why? It was always possible in the mql4 language to change the value of such a extern setting parameter.
Is there a solution? I am thinking to write again the old style "extern Takeprofit" then it does work. But why with "input" it does not work or does i make somethink wrong?