
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I solved at least one problem!
The indicator CaVol 'starts' with this way:
The problem with the recursive initialization of a new instance of the indicator CaVol happens if CallingCaVol calls CaVol that way:
I forgot the informative 'first parameter' and I could not imagine that this leads to that infinite loop of initializations :(
As soon as I call CaVol That way:
everything is fine - the calculation is correct as the values are the same as if CaVol was started directly on the chart!. So far so good - if I were able to understand that!
CaVol("",20,1.0, /*now use defaults*/ idxBuffer, shift); is correct but
CaVol(20,1.0, /*now use defaults*/ idxBuffer, shift); fails in an totally surprising way - I would expect false values but not initialization until the pc crashes!!
The first string parameter becomes 20 - with no effect on any further calculation.
The second parameter becomes 1 which is within the working tolerance, even though it is not intended, that should lead to different values
The third parameter should be set to its default value like all the others!
So why the hell do I get that stupid loop until the pc dies?
Anyway it could be a nice and simple feature to tease users ;)
But I still don't understand the other problem why is printed in the expert log:
despite CaVol was called by CallingCaVol?
As the reference shows:
"The name of the executed Expert Advisor, script, custom indicator, or library, depending on the MQL4 program, from which this function has been called."
But this is definitely not the case!
CaVol(20,1.0, /*now use defaults*/ idxBuffer, shift); fails in an totally surprising way - I would expect false values but not initialization until the pc crashes!!
The first string parameter becomes 20 - with no effect on any further calculation.
The second parameter becomes 1 which is within the working tolerance, even though it is not intended, that should lead to different values
The third parameter should be set to its default value like all the others!
So why the hell do I get that stupid loop until the pc dies?
Anyway it could be a nice and simple feature to tease users ;)
Yeah it's why I wrote :
Right. Though I didn't check with 1090. But normal behavior is to use default parameters when they are not set explicitly. You can provide 0, 1, or x parameters. Of course you can't "jump" a parameter.
But I still don't understand the other problem why is printed in the expert log:
despite CaVol was called by CallingCaVol?
As the reference shows:
"The name of the executed Expert Advisor, script, custom indicator, or library, depending on the MQL4 program, from which this function has been called."
But this is definitely not the case!
Read it again. Of course it's the case, the function WindowExpertName() is called by CaVol, not by CallingCaVol.
CallingCaVol calling CaVol doesn't matter.
1) "Of course you can't "jump" a parameter."
Well if I miss to enter a parameter the next parameters are shifted 'upwards'. This jump of parameter simply does not take place, they are just shifted - no?
If the 'new' parameter are in an allowed range than only the values of the indicator should be different, but here it causes an infinite loop of creating new instances of this indicators each time iCustom calls CaVol and that is really a different quality - no?
2) "CallingCaVol calling CaVol doesn't matter."
Ah, I got it!
While coding Classes I wanted to know where I am and there __FILE__ doesn't make sense but WindowExpertName() does the trick - so I thought even in this case I can get the 'most outside' program. Even the name of WindowExpertName suggest this idea as CallingCaVol is running in the Chart-Window not CaVol!!
Ok, Alain, how can an indicator like CaVol know, whether it running directly on the chart (so it plays all its gimmicks) or it is called by another ea, indi, ... and it should provide only the values in the buffer?
1) "Of course you can't "jump" a parameter."
Well if I miss to enter a parameter the next parameters are shifted 'upwards'. This jump of parameter simply does not take place, they are just shifted - no?
If the 'new' parameter are in an allowed range than only the values of the indicator should be different, but here it causes an infinite loop of creating new instances of this indicators each time iCustom calls CaVol and that is really a different quality - no?
There is no infinite loop (at least not in the first sense of this term). Usually when you use iCustom() the indicator is called (OnInit(), OnCalculate()...) and it remains in memory, in the background. If you call the same indicator, with same parameters (same symbol,period), from elsewhere it will use this instance which is already in memory. It's recognized by it's signature (I don't have any details about how it's implemented).
If you missed a parameter like you did, certainly when it's a string, and your iCustom use an int or double, MT4 is not able to recognize the signature, so each time it call a new instance of the indicator, which of course soon or later will lead to memory issue.
2) "CallingCaVol calling CaVol doesn't matter."
Ah, I got it!
While coding Classes I wanted to know where I am and there __FILE__ doesn't make sense but WindowExpertName() does the trick - so I thought even in this case I can get the 'most outside' program.
Ok, Alain, how can an indicator like CaVol know, whether it running directly on the chart (so it plays all its gimmicks) or it is called by another ea, indi, ... and it should provide only the values in the buffer?
The simplest is just to use an input parameter. The last one after your significant parameters, set it to false by default. When you call your indicator from an external source, just set your last iCustom parameter to true.
CaVol(20,1.0, /*now use defaults*/ idxBuffer, shift); fails in an totally surprising way - I would expect false values but not initialization until the pc crashes!!The simplest is just to use an input parameter. The last one after your significant parameters, set it to false by default. When you call your indicator from an external source, just set your last iCustom parameter to true.
Hmm - this should be something an indicator have to find out itself! There are so many predefined variables and this must be done 'manually' :(
"...so each time it call a new instance of the indicator, which of course soon or later will lead to memory issue."
As I said a nice and simple feature to tease the user - and if you make that a bit in a sophisticated way, e.g. at random speed, you can drive them nuts until they found out why their pc crashes!
It matters :(
The problem is that if CaVol is called by another indicator some of its graphical things are shown on the chart some don't :(
So e.g.the indicator window is not shown but OBJ_RECTANGLE_LABEL are shown and OBJPROP_TEXT aren't ... kind of a mess!
"If you insist, it should be told via a parameter." For what do I have a computer if I have to things 'manually' that could be done automatically!
Hmm - this should be something an indicator have to find out itself! There are so many predefined variables and this must be done 'manually' :(
You always have to code it anyway, your graphical objects will not decide alone to hide themselves ;-) Try this function :
"...so each time it call a new instance of the indicator, which of course soon or later will lead to memory issue."
As I said a nice and simple feature to tease the user - and if you make that a bit in a sophisticated way, e.g. at random speed, you can drive them nuts until they found out why their pc crashes!
I doubt that will crash a PC. It will crash MT4, maybe...
Let's see I just started a test to verify :-D
I doubt that will crash a PC. It will crash MT4, maybe...