Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 927

 
Artyom Trishkin:

Storage folder: File --> Open Data Folder --> MQL4\Experts\Here.ex4

If this is the case, but EA is not visible in navigator, then ... congratulations - you have run out of possible programs in navigator. You need to delete something. Unfortunately, MetaTrader4 has a limit on the number of programmes the Navigator can see. I faced this problem when creating a large number of indicators. In order not to delete a lot of them I simply copied the code into a test file and compiled and ran it - that is how I always tested the indicators I needed in one file - erased the file contents, put a new code in it, compiled and tested - finished. Then the next one - erased the contents of the file, inserted new code into it ..., and so on in a circle ...

Thank you. I'll see... I'll write back here... There's not much in the way of software...
 
Artyom Trishkin:

File folder: File --> Open Data Folder --> MQL4\Experts\Here.ex4

If everything is the same, but the EA is not visible in the navigator, then ... congratulations - you have run out of possible programs in the navigator. You need to delete something. Unfortunately, MetaTrader4 has a limit to the number of programmes the Navigator can see. I faced this problem when creating a large number of indicators. In order not to delete a lot of them I simply copied the code into a test file and compiled and ran it - that is how I always tested the indicators I needed in one file - erased the file contents, put a new code in it, compiled and tested - finished. Then the next one - erased the contents of the file, inserted new code into it ..., and so on in a circle ...

copied into data directory - exps, indicators, scripts - not enough. In the NAVIGATOR ...July - no.

In the folder, where I start terminal from, it is also present. Not in NAVIGATOR.




ARTEM - THANK YOU. I RESTARTED THE TERMINAL - IT IS THERE.



 

I want to create an array and put values in the created array, but I want to feed the values through function variables, etc. Example.

int q=8,w=9;

int mas[2]={q,w}. What we should do is mas[0]=q,mas[1]=w. Is there any way to substitute variables that already store the necessary calculations and put it into an array? Is it possible to do this with macros?

 
Seric29:

I want to create an array and put values in the created array, but I want to feed the values through function variables, etc. Example.

int q=8,w=9;

int mas[2]={q,w}. What we should do is mas[0]=q,mas[1]=w. Is it possible to create an array by substituting variables that already store the needed calculations and put them into the array? Is it possible to do this with macros?

You can't. Earlier this week, someone discussed it in the "bugs, errors, questions" thread - the result is impossible.

 
Igor Makanu:

You can't, at the beginning of the week in the "bugs, bugs, questions" thread someone discussed it - the result is no

I see. I've seen someone use a macro to assign the number of columns when declaring an array, although passing values of columns or rows when initializing an array via a variable is forbidden in mql, but someone did it through a macro. Here's the subjecthttps://www.mql5.com/ru/forum/95351.

#define ODD 5

double Max_D1[ODD];

double Low_D1[ODD];

 
Seric29:

I see. I've seen someone use a macro to assign the number of columns when declaring an array, although passing columns or rows when initializing an array via a variable is forbidden in mql, but someone used a macro to do it. Here's the subject https://www.mql5.com/ru/forum/95351.

#define ODD 5

double Max_D1[ODD];

double Low_D1[ODD];

and what is the point of this action? : can an array be initialized with variables instead of constants? - the answer is no.

Your macro will do the manual work of assigning a variable value to each element of the array, but the point isn't changed by this

 
Igor Makanu:

and the point of this action? how did you ask the question? : can an array be initialised with variables rather than constants? - the answer is no.

Your macro will do the manual work of assigning a variable value to each array element, but the essence will not change.

Well, I thought it would be possible to do something with it.

 
Igor Makanu:

and the point of this action? how did you ask the question? : can an array be initialised with variables rather than constants? - the answer is no.

Your macro will do the manual work of assigning a variable value to each element in the array, but the point doesn't change.

Can you create a function that returns a constant value to solve this problem?

 
Seric29:

Can a function be created that returns a constant value to solve this problem?

no you can't

You confuse the notions of initialization and assignment; they have the same essence, but the moments (when) of use are different; initialization is in the string where you describe an array - there you initialize it with constants and assignment, when you assign arbitrary values to an array (array elements) in any place after you describe it

I don't know how to explain what you're asking and why I'm writing that you can't

When using arrays there is no such a problem that you raise, apparently from the beginning of writing code you did not assume the use of an array, and now you only have to rewrite the code or assign a variable value to each array element manually

Sometimes, in order not to "multiply" variables, I can use an array if the array has more than 3-4 elements, the danger of mixing up the number of array elements while writing the program is high; I use constant values set with #define - the code is readable and you just can't make a mistake, something like this:

#define  open   0
#define  take   1
#define  loss   2
#define  profit 3
void OnStart()
  {
  double order[4];
  order[open] =  OrderOpenPrice();
  order[take] =  OrderTakeProfit();
  order[loss] =  OrderStopLoss();
  order[profit]= OrderProfit();
  }

perhaps I don't understand the unambiguity of your question:
Seric29:

Such question I want to create an array and immediately put values in the created array, but the values I want to feed through variables functions, etc. Example.

int q=8,w=9;

int mas[2]={q,w}. What we should do is mas[0]=q,mas[1]=w. Is it possible to create an array by substituting variables that already store the necessary calculations, and put it into an array? Is it possible to do this with macros?

when describing an array? - need to be initialised with variables? - answered 2 times above

or assign multiple variable values to an array? - the answer is also not possible, but due to invalid syntax:

you cannot apply variables in curly braces, i.e. {1,2,3} - this will be skipped by the compiler, but {a,b,c} - you cannot do so, because the compiler will expect either an arithmetic(logical) operation or operator = (lvalue, rvalue) ... So, you should study the language syntax, but it may be not about the language possibilities.

 
Igor Makanu:

No, you can't.

You mix up the concepts of initialization and assignment of values - the essence they have the same, but the moments (when) of use are different; initialization is in the string where you describe an array - there you initialize it with constants and assignment is, after you describe an array, you assign any values to an array ( array elements) in any place you want.

I don't know how to explain what you're asking and why I'm writing that you can't

When using arrays there is no such a problem that you raise, apparently from the beginning of writing code you did not assume the use of an array, and now you only have to rewrite the code or assign a variable value to each array element manually

Sometimes, in order not to "multiply" variables, I can use an array if the array has more than 3-4 elements, the danger of mixing up the number of array elements while writing the program is high; I use constant values set with #define - the code is readable and you just can't make a mistake, something like this:

Well, yes, there is a hybrid use of elements declared in the program. For example I declare input parameters and from these parameters I need to take global variables and look through them, but there is a problem input parameters can not be an array, the 2nd example I write a function and starts processing through loops, here is also better to use an array, I start arguments to an array and again the array of variables is impossible and have to as you wrote above one value in each cell, the 3rd example would be nice to be able to use as arguments function using an array (here he is budding) As for using arrays instead of variables, yes it makes programs compact and I do it that way too. You can write in variables at the moment of initialization in C++, maybe you can't in version 12 below, and here they made it cheaper, which led to such consequences. In general, I understand and thank you for the answers.

Reason: