Error Message: "parameter conversion not allowed" passing values to a function in an external *.mqh file
You are passing an array of MainArrayBasis. | MainArrayBasis MainArray[], TempMainArray[]; ⋮ LinearRegression(TempMainArray, … |
The function requires an array of MainArrayBasesLR | void LinearRegression(MainArrayBasisLR &TempMainArrayLR[], … |
@William Roeder: Thanks for the answer. After many iterations I am still at the beginning having the same Error Message. Some of the iterations were:
1. Innitially I assumed that the struct array on both is the same, and therefore it should be the same type (the innitial state). I have received the already known Error Message.
struct MainArrayBasis { datetime time; // Last price update time double Close; // Close price };
vs
struct MainArrayBasisLR { datetime timeLR; // Last price update time double CloseLR; // Close price };
2. Later on I have modified the LinearRegression.mqh in the struct to look similar to the Main file. I have received the same Error Message.
struct MainArrayBasis { datetime time; // Last price update time double Close; // Close price };
vs
struct MainArrayBasis { datetime timeLR; // Last price update time double CloseLR; // Close price };
3. Trying to use the struct array from the Main file as a global parameter, I have disabled the struct array in the file:
//struct MainArrayBasis // { // datetime timeLR; // Last price update time // double CloseLR; // Close price // }; AND void LinearRegression(MainArrayBasis &TempMainArrayLR[], int TempMainArrayCounterLR, double &gradientLR, double &c_pointLR)
But after all I am geting even more error Messages of different types.
So maybe I haven't understand you clearly what you have written on the table. Could you tell me if there is some wrong assumption? as well as any more detailed suggestion?
As one of the articles in the forum as a guide I have used:
https://www.mql5.com/en/forum/358732
Thanks
- 2020.12.24
- www.mql5.com
-
The include file defines the struct. Drop with the other one.
- Grzegorz Galazka #: 1. Innitially I assumed that the struct array on both is the same,
MainArrayBasis and MainArrayBasisLR are two completely different struct. Only you think thay are the same.
- Grzegorz Galazka #: 2. Later on I have modified the LinearRegression.mqh in the struct to look similar to the Main file.
You define the same struct twice, in the main and in the included. Can't do that. Drop the other one.
@William Roeder: thanks for the prompt answer. I got your point and is completely logic. It is necessary to use the same struct on the Main file as well as in the included function.
I have tried to use a similar syntax as in the article https://www.mql5.com/en/forum/358732 where the struct is declared as a Global Variable (outside all functions in the Main file). But in my case I have to feed the MainArrayTemp constantly inside the OnCalculate() function in the Main file. Than I again tried to pass the struct arrays to the function and is not working.
So I had to reformulated my question: Which command or syntax should I use to pass a local struct array into an external function in an *.mqh file?
Thanks for your help!
- 2020.12.24
- www.mql5.com
Grzegorz Galazka #: Which command or syntax should I use to pass a local struct array into an external function | void LinearRegression(MainArrayBasis &TempMainArrayLR[], int TempMainArrayCounterLR, double &gradientLR, double &c_pointLR) |
Just call the function. | MainArrayBasis locArr[]; … LinearRegression(locArr, …); |
@William Roeder: Thanks again!
After applying your recommendations and setting the struct array declaration in the global scope I got no Error Message on the Main file but in the *.mqh file. So after checking many articles I have found this one where you helped another guy with a similar situation few years ago:
https://www.mql5.com/en/forum/203579
Forum on trading, automated trading systems and testing trading strategies
#include and declaring global variables
William Roeder, 2017.06.06 16:49
mqh files do not get errors. You do not compile them. You include them in the main program and compile that. |
So considering that I received no Error Message after compiling the Main file, everything should be ok? What do you mean with "including them in the main program and compile that"?
The Error Message that I receive from the *.mqh is attached to the comment. There you can see that the Struct Array data type on the Main files global scope apparently had no efect (MainArrayBasis - declaration without type) and therefore the declared structure (TempMainArrayLR) is "undeclared". Is this normal in functions in separated *.mqh files? Can I consider that the problem is solved?
Thanks for the help :)
- 2017.06.06
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Good Day Everyone!
I am a freetime and hobby programer with not so much experience in MQL5 but I do my best and only ask for help as a last option. Since many days I am trying to solve a problem until I finally have decided to post it in the forum. I will appreciate strongly if you can hep me with it :).
In a Main File I have created an Array of Struct that I am trying to pass to a function in an external *.mqh file. I have checked many articles in the forum but I am not able to find what is wrong. Here is the code:
Main File (OnInit and other less important parts were obviated):
External *.mqh file
The error message is this:
I will appreciate your help with this topic
Thanks