I've got no idea what this error is about.
Here's the error message in full: <<unresolved extern variable 'xiDC2CLR'>>
The error is flagged on only the first extern encountered. If I delete that line, I get the same error on the next one, on and on until there were no little piggies left.
Can someone tell me what's wrong with this code?
The error you're encountering, "unresolved extern variable 'xiDC2CLR'", indicates that the variable xiDC2CLR is declared as an external variable but is not defined or initialized anywhere in your code.
In MQL, when you use the extern keyword to declare a variable, you are essentially indicating that the variable's value will be provided by the user or will be accessible from outside the current code file. However, you need to define or initialize these variables somewhere in your code or in an include file. Use "Input" and cancel the extern. Remember to close your statements.
You should also learn how to use debugging. i Got these excellent links from another developer, go visit them
Code debugging: https://www.metatrader5.com/en/metaeditor/help/development/debugError Handling and Logging in MQL5: https://www.mql5.com/en/articles/2041
Tracing, Debugging and Structural Analysis of Source Code, scroll down to: "Launching and Debuggin": https://www.mql5.com/en/articles/272
- www.metatrader5.com
I've got no idea what this error is about.
Here's the error message in full: <<unresolved extern variable 'xiDC2CLR'>>
The error is flagged on only the first extern encountered. If I delete that line, I get the same error on the next one, on and on until there were no little piggies left.
Can someone tell me what's wrong with this code?
extern, from relatively recently, means something different from what you're used to:
https://www.mql5.com/en/docs/basis/variables/externvariables
Replace extern with input
- www.mql5.com
Replace with input if this should be the indicator settings. But the strange thing is that you are not initializing these variables and below you have an input variable which you have initialized. In general, it is not clear what you are trying to do
The error you're encountering, "unresolved extern variable 'xiDC2CLR'", indicates that the variable xiDC2CLR is declared as an external variable but is not defined or initialized anywhere in your code.
In MQL, when you use the extern keyword to declare a variable, you are essentially indicating that the variable's value will be provided by the user or will be accessible from outside the current code file. However, you need to define or initialize these variables somewhere in your code or in an include file. Use "Input" and cancel the extern. Remember to close your statements.
You should also learn how to use debugging. i Got these excellent links from another developer, go visit them
Code debugging: https://www.metatrader5.com/en/metaeditor/help/development/debugError Handling and Logging in MQL5: https://www.mql5.com/en/articles/2041
Tracing, Debugging and Structural Analysis of Source Code, scroll down to: "Launching and Debuggin": https://www.mql5.com/en/articles/272
Thanks man, but sorry, wrong track. Here's the code you stated is missing (it's in OnInit):
//+------------------------------------------------------------------+ //| External parameters initialization | //+------------------------------------------------------------------+ // xiDC2CLR = DarkOrange; xsDC2_IRO_A = "MA"; xiDC2_IRO_IPRM_A = 15; xdDC2_IRO_IPRM_A = 15;
Your explanation doesn't account for why I only get the error on the first in the list, and why when I delete that declaration, it suddenly throws the same error on the next statement (now the first) which compiled fine as long as it wasn't the first one.
As far as debugging, I've done a bunch of it in the past, but you can't debug what you can't compile -- unless MT5 does that differently, too.
extern, from relatively recently, means something different from what you're used to:
https://www.mql5.com/en/docs/basis/variables/externvariables
Replace extern with input
Thanks, I'll give that a try. But that doesn't explain why I'm getting that compile error.
Replace with input if this should be the indicator settings. But the strange thing is that you are not initializing these variables and below you have an input variable which you have initialized. In general, it is not clear what you are trying to do
Yeah, sometimes it's not clear to me either. Just what happens when switching to a different environment and don't know the rules yet.
When I declared the variables as extern and tried to initialize them in the declaration, the compiler told me that's a no-no, too. So I declared them as you see and initialized them in OnInit.
Yeah, changing the to input variables worked, thanks.
It's been some years, but as I remember, MT4 wouldn't let you programmatically change the value of an input variable, but it would an extern, so I always used externs for validating and defaulting user input.
Thanks man, but sorry, wrong track. Here's the code you stated is missing (it's in OnInit):
Your explanation doesn't account for why I only get the error on the first in the list, and why when I delete that declaration, it suddenly throws the same error on the next statement (now the first) which compiled fine as long as it wasn't the first one.
This will need some looking into. I am not even sure what to make of this, if i read through the code i cant see what you are trying to achieve? Maybe another dev can assist. Im out
Yeah, sometimes it's not clear to me either. Just what happens when switching to a different environment and don't know the rules yet.
When I declared the variables as extern and tried to initialize them in the declaration, the compiler told me that's a no-no, too. So I declared them as you see and initialized them in OnInit.
Yeah, changing the to input variables worked, thanks.
It's been some years, but as I remember, MT4 wouldn't let you programmatically change the value of an input variable, but it would an extern, so I always used externs for validating and defaulting user input.
input color xiDC2CLR = DarkOrange; // Pair 2 divergence plot line color input string xsDC2_IRO_A = "MA"; // Pair 2(A) Primary: (MA,MACD,Stoch,Stoch_S,PSAR,CML,CT,CB,RML,RT,RB,ZZ,ZZLN,ZZLO,ZZHI) input int xiDC2_IRO_IPRM_A = 15; // Period for primary indicator (int) input double xdDC2_IRO_IPRM_A = 15.0; // Period for primary indicator (double)
extern now means different from what it meant in MT4 a few years ago.
https://www.mql5.com/en/docs/basis/variables/inputvariables
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 mql5-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. External variables are always reinitialized immediately before the OnInit() is called.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I've got no idea what this error is about.
Here's the error message in full: <<unresolved extern variable 'xiDC2CLR'>>
The error is flagged on only the first extern encountered. If I delete that line, I get the same error on the next one, on and on until there were no little piggies left.
Can someone tell me what's wrong with this code?