InOnCalculate I can easily use array elements like high by index. Is it also possible to access the index elements of this array in ExtFunc? When calling my function, should I pass the array-argument by reference, via pointer or something else? So far I've managed to minimize the error messages to: "'high' - parameter conversion is not allowed" and "'high' - constant variable cannot be passed as reference" regarding the same line of my function call with the array argument from OnCalculate. Is it hopeless or is there a solution?
So far in OnCalculate I have resorted to copying high to another array:
and then use CopyOfHigh in ExtFunc instead of using high-array directly.
Just pass the array to your function by reference
bool ExtFunc (string str, int P, int i, double & high[])
{
if (high[i] < high[i-1]) return(false);
return(true);
}
intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
int i=0;
if ExtFunc("s",60,i,high) == 1)
Buffer[i] = high[i];
}
TheSymbolInfoInteger() function returns value of long type (see Reference), while DIGITS is declared as int. This is an implicit type conversion. See "Type conversion".
The meaning of this message varies, depending on the context in which it is being considered.
For example:
1. "Make an explicit type conversion!"
int DIGITS = (int) SymbolInfoInteger(Symb,SYMBOL_DIGITS);
2. "Possible data twitching with implicit type conversion." // This is a literal translation.
This is understandable, since the long type returned by the function has a larger size and covers a wider range of values.
Another option that comes to my mind most often lately:
3. "MetaQuotes staff doesn't understand how cool, attractive, and effective it would be to learn if error messages and mql5 compiler warnings were given in the user's native language."
... how cool, attractive, and effective it would be to learn if mql5 compiler error messages and warnings were given in the user's native language."
Yeah it wouldn't be bad. Although I personally am already a bit savvy in English, and translators are a dime a dozen these days, but again, this takes up valuable time, which is not so much. Some people don't have enough of it to use a translator for such a complicated subject as trading on financial markets + programming. MetaTrader 5 is a multi-language platform. I wish the messages and comments in the help examples (we sometimes come across them) were in the language that has been selected in the terminal.
I have a suspicion that if the indicator is activated through iCustom, it is calculated on every tick. And it doesn't depend on the calls to it through the CopyBuffer. Is it correct?
If it is correct, then is it possible to disable the calculation of indicator and enable it only before calling the CopyBuffer?
I have a suspicion that if the indicator is activated through iCustom, it is calculated on every tick. And it doesn't depend on the calls to it through the CopyBuffer. Is it correct?
It depends on the logic of the custom indicator. Actually, it can re-calculate its values once a day, skipping all the other ticks. So to say, according to the author's will.
masharov:
If so, is it possible to disable the recalculation of indicator and enable it only before calling the CopyBuffer?
Basically, some people try to use this monster approach: create a copy of the indicator via iCustom, copy the required data, delete the copy of the indicator. The procedure is repeated as needed.
There is also OnTimer() function, I haven't worked with it myself, but maybe you can adapt it to your task.
When I call my function, should I pass the array by reference, via pointer or something else?
Read the section about passing parameters by value and by reference:
MQL5 Reference / Language Basics / Functions / Passing Parameters
Read the section in the Reference Manual about passing parameters by value and by reference:
MQL5 Reference / Language Basics / Functions / Passing Parameters
Actually, I've just come from there and the compilation errors I mentioned in my previous message have happened after reading the above section.
Now I've reread it carefully - it's all about const and where to put it.
Thanks, I've figured it out.
InOnCalculate I can easily use array elements like high by index. Is it also possible to access the index elements of this array in ExtFunc? When calling my function, should I pass the array-argument by reference, via pointer or something else? So far I've managed to minimize the error messages to: "'high' - parameter conversion is not allowed" and "'high' - constant variable cannot be passed as reference" regarding the same line of my function call with the array argument from OnCalculate. Is it hopeless or is there a solution?
So far in OnCalculate I have resorted to copying high to another array:
and then use CopyOfHigh in ExtFunc instead of using high-array directly.Just pass the array to your function by reference
Greetings all!
What does the warning mean:
possible loss of data due to type conversion expert.mq5
when compiling it? It says this:
What's wrong?
Simply pass the array to your function by reference
Not exactly:
Greetings all!
What does the warning mean:
possible loss of data due to type conversion expert.mq5
when compiling? It says this:
What's wrong?
What the warning means:
possible loss of data due to type conversion
The meaning of this message varies, depending on the context in which it is being considered.
For example:
1. "Make an explicit type conversion!"
2. "Possible data twitching with implicit type conversion." // This is a literal translation.
This is understandable, since the long type returned by the function has a larger size and covers a wider range of values.
Another option that comes to my mind most often lately:
3. "MetaQuotes staff doesn't understand how cool, attractive, and effective it would be to learn if error messages and mql5 compiler warnings were given in the user's native language."
... how cool, attractive, and effective it would be to learn if mql5 compiler error messages and warnings were given in the user's native language."
I have a suspicion that if the indicator is activated through iCustom, it is calculated on every tick. And it doesn't depend on the calls to it through the CopyBuffer. Is it correct?
If it is correct, then is it possible to disable the calculation of indicator and enable it only before calling the CopyBuffer?
I have a suspicion that if the indicator is activated through iCustom, it is calculated on every tick. And it doesn't depend on the calls to it through the CopyBuffer. Is it correct?
It depends on the logic of the custom indicator. Actually, it can re-calculate its values once a day, skipping all the other ticks. So to say, according to the author's will.
If so, is it possible to disable the recalculation of indicator and enable it only before calling the CopyBuffer?
Basically, some people try to use this monster approach: create a copy of the indicator via iCustom, copy the required data, delete the copy of the indicator. The procedure is repeated as needed.
There is also OnTimer() function, I haven't worked with it myself, but maybe you can adapt it to your task.