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
Hello,
Thanks again.
I've read the information on your link and the others posted and they all make sense. As a matter of fact I even looked on the Internet and found the exact description of what my OTHER problem was on my OTHER platform and it had to do with the way different processors handle or accomodate floating points. Essentially: you can land up with the same issue as you've described i.e. while a particular value should LOGICALLY or MATHEMATICALLY be exactly equal to another value in some cases it may not be because something like the fifteenth decimal place is different.
But that's not the issue here. I just checked my original (after removing the SetIndexEmptyValue( 0, 0.0 ) (EXACTLY the way I did it this morning), copied the source to all the different MetaTrader 4 installations, deleted the existing compiled files, and even deleted the chart cache history (although there was nothing wrong with the charts at any time today) and, well, it's working perfectly on each and every installation. Go figure.
Of course NOW (being the kind of person that I am) I'd like to try and duplicate the errors that I was getting this morning. You know: the proverbial 'WHY'??? LOL!!! As I said: with absolutely NO changes to the code other than the removal of the SetIndexEmptyValue( 0, 0.0 ) (or the removal of my 'workaround' of SetIndexEmptyValue( 0, 0.0000001 ) everything is 100% and working as it should.
I've been trying to think of what software I was running BEFORE trying to fix all of this up this morning .........
Wait: it's just dawned on me now. There was indeed ONE change that I made a while ago (before things started to work) which I forgot about until typing this reply (because I noticed something odd happening even with my 'workaround' and it was this):
Originally (and as per the WORKING code example above I had this statement):
if( TimeYear( Time[i] ) >= 2011 ) if( TimeMonth( Time[i] ) >= 7 )
I changed that at some point this afternoon (before things 'came right as if by magic') to this:
if( TimeYear( Time[i] ) >= 2011 && TimeMonth( Time[i] ) >= 7 )
That's the ONLY change that I made to the orignal code and now it's all working. What the one could have to do with the other I do not know. My only guess is that the reason that it worked with the former in my example working code is because in the example working code I was simply 'forcing' a 0 or a 1 value to the buffer whereas in the indicator the values are calculated values. It's ILOGICAL that this change could have had anything to do with this issue but maybe the additional '>=' and the seperate if( ) functions sent my code into a 'spin'.
So there's a good test I suppose. Change the statement above to it's original form i.e. if( TimeYear( Time[i] ) >= 2011 ) if( TimeMonth( Time[i] ) >= 7 ) and see what happens. In which case you're ALL right as to what the problem WAS although it definitely was not something obvious.
Regards,
Dale.
if( TimeYear( Time[i] ) >= 2011 ) if( TimeMonth( Time[i] ) >= 7 )
I changed that at some point this afternoon (before things 'came right as if by magic') to this:
if( TimeYear( Time[i] ) >= 2011 && TimeMonth( Time[i] ) >= 7 )
That's the ONLY change that I made to the orignal code and now it's all working.
So there's a good test I suppose. Change the statement above to it's original form i.e. if( TimeYear( Time[i] ) >= 2011 ) if( TimeMonth( Time[i] ) >= 7 ) and see what happens. In which case you're ALL right as to what the problem WAS although it definitely was not something obvious.
Regards,
Dale.
Also I don't understand what you are actually trying to achieve. Why are you trying to initialize the value to zero? If you want the line to completely go away then initialize it with EMPTY_VALUE
buffer[i] = EMPTY_VALUE; // make the line disappear
and if you want it to be a visible flat line at zero then to this
buffer[i] = 0;
and don't change the SetEmptyValue() since this is already set to EMPTY_VALUE (which is 0x7fffffff) by default which is probably what most people want to use anyways (and some EAs even rely on). Maybe you should explain what you are actually trying to achieve (before you explain what you did), because without knowing what your code is actually supposed to achieve it is difficult to discuss how you should implement it.
Hello everyone.
Zbit: that's just the point. I WANT a line to be drawn if / when the indicator value is zero. The SetIndexEmptyValue( 0, 0.0 ) function will STOP any zero values from being displayed. That's it's function so far as I can tell. Using your example: setting buffer[i] = 0; and then including a SetIndexEmptyValue( 0, 0.0 ) function will NOT show the zero line on the indicator. The line will only be shown if you do NOT include the SetIndexEmptyValue( 0, 0.0 ) in your example. And my problem WAS this: let's say that the indicator has three consecutive points or values after the calculation being done e.g. 14, 0, and -23 and they should be joined by a line. If you include a SetIndexEmptyValue( 0, 0.0 ) function the three points will NOT be joined because the middle point is a zero (there will be no line and it will appear as a 'break' in the line as is shown in my first first chart posted on this thread and what started this 'debacle' in the first place). That was my problem but it APPEARS to be sorted out now i.e. I've just excluded the SetIndexEmptyValue( 0, 0.0 ) from the code and it's working perfectly. The ONLY problem is that the FIRST time I tried this yesterday (or was it this morning i.e. I forget now) it DIDN'T work and basically 'flatlined' my entire indicator with a value for ALL points to some ridiculous number and I have no explanation as to why it's working fine now because other than the one change noted above, which logically should have had NO impact on this, I had changed nothing else AT ALL in the code.
As far as that code goes:
The two different versions did NOT display the same results. The first version i.e. if( TimeYear( Time[i] ) >= 2011 ) if( TimeMonth( Time[i] ) >= 7 ) had the effect of showing data if EITHER the year was greater than or equal to 2011 OR the month was greater than or equal to 7. The second version i.e. if( TimeYear( Time[i] ) >= 2011 && TimeMonth( Time[i] ) >= 7 ) resulted in data being shown ONLY if the year was greater than or equal to 2011 AND the month was greater than or equal to 7 (the latter being what I wanted). Whether or not that's SUPPOSED to be the case I know not but in practice and testing that's what happened.
RaptorUK:
Your guess is as good as mine (as to why it didn't work at first and now is fine no matter HOW many times I recompile it or how many different charts or timeframes I use it on or which MetaTrader 4 installation I use it on). I don't have the answer. As you note: that small change (related to the year and month) should really not have affected anything. The only thing I can think of now is that when I first made the change there was some memory corruption or I was getting corrupt data from my Internet connection at the time (it's wireless and actually was 'acting up' yesterday at or around the same time if I recall BUT as I noted before that could not have made any difference because the chart data was already cached and trading was closed). And for the sake of argument I did INDEED do the above test (changing the year and month function formats and other than the behaviour detailed above the indicator itself was still correct). So like I said: WHO knows. All I know is that I am 100% sure that I changed NOTHING else and it didn't work in the morning and, after rebooting my PC on occasion since then, it's working. That's as much as I can tell you or think of.
Regards,
Dale.