Erroneous Data at beginning of indicator

 

Hello, I'm new to programming in MQL4, about 8 months now. This is the first time I've had to directly seek help and this problem is driving me nuts. I've written a zero cross indicator, generally the values should fall between -5.0000 to +5.0000. Given the daily chart, my indicator will start on some ridiculously high number and won't fall into place for about 7 months worth of candles. The starting number is always a whole number of 1840700268.xxxx with a varying fraction no matter what asset or time period I place the indicator on. Another minor issue I'm having is I'm trying to put up and down arrows on the indicator window for directional signals but I'm getting small x's instead. At one point the arrows did start printing but they reverted back to the small x's for no apparent reason. I did try chopping the available price data in half for my calculations, just in case I was accessing outside the available price data of the chart but all that did is move the issue to the middle of the chart. Any help would be appreciated. Please see chart pictures and code below.

 
OK, I think I have the arrow issue resolved, Now if I can get the erroneous data resolved, I'll be a happy camper!
 
pacman869 #:
OK, I think I have the arrow issue resolved, Now if I can get the erroneous data resolved, I'll be a happy camper!

Try preloading the buffers with zero instead of their default EMPTY_VALUE which is really a very high value and may be the issue.  


Place these in OnInit()

SetIndexEmptyValue(0,0);

SetIndexEmptyValue(1,0);

SetIndexEmptyValue(2,0);

 
maximo #:

Try preloading the buffers with zero instead of their default EMPTY_VALUE which is really a very high value and may be the issue.  


Place these in OnInit()

SetIndexEmptyValue(0,0);

SetIndexEmptyValue(1,0);

SetIndexEmptyValue(2,0);

Thank you Sir, That did the trick! I fail to understand why I haven't seen that in any other code, but the other indicator code I've looked at did not have this issue. In any event I'm grateful for your help.