Indicator works for a while, then stops working. Resumes working on any other period and when changed back to original period.

 

Perhaps someone has had this mq4 problem before, and found the cause and solution for this problem?

I have a custom indicator that works on some symbols continuously, but on some other symbols it will work for a while and then stop. Another similar indicator for the chart continues working when the first one stops. Both of these indicators are in panels below the main chart window. When the indicator stops, the current numeric values are no longer posted beside its short name ... the space previously occupied by the two numeric values contains nothing. However, the short name is still there. When the indicator stops, the values are no longer plotted. When the indicator stops there is nothing printed in the log file (like maybe some reason).

When the indicator stops, if you select that window and change the period, the indicator starts working again for the new period. If you then change back to the original period, the indicator works fine, including past the point where it stopped working earlier, and computes up to the latest bar. However, some indefinite time later it will stop again.

Has anyone seen this kind of problem with MT4 and discovered the cause? Or if you have not found the cause but have some ideas of possible causes, then please share those with me, and maybe we can find out what is happening here.

Thanks.

 

No, Personally I've not experienced nor heard of this problem before seeing your post. Did you write the indicators yourself? If those custom indicators were written by someone else, I'll suggest directing your question to them.

 
ubzen:

No, Personally I've not experienced nor heard of this problem before seeing your post. Did you write the indicators yourself? If those custom indicators were written by someone else, I'll suggest directing your question to them.


Thanks for responding. I am the programmer, ... otherwise I wouldn't be asking here.
 
limasierra88:

Perhaps someone has had this mq4 problem before, and found the cause and solution for this problem?

I have a custom indicator that works on some symbols continuously, but on some other symbols it will work for a while and then stop. Another similar indicator for the chart continues working when the first one stops. Both of these indicators are in panels below the main chart window. When the indicator stops, the current numeric values are no longer posted beside its short name ... the space previously occupied by the two numeric values contains nothing. However, the short name is still there. When the indicator stops, the values are no longer plotted. When the indicator stops there is nothing printed in the log file (like maybe some reason).

When the indicator stops, if you select that window and change the period, the indicator starts working again for the new period. If you then change back to the original period, the indicator works fine, including past the point where it stopped working earlier, and computes up to the latest bar. However, some indefinite time later it will stop again.

Has anyone seen this kind of problem with MT4 and discovered the cause? Or if you have not found the cause but have some ideas of possible causes, then please share those with me, and maybe we can find out what is happening here.

Thanks.


The problem seems to be related to the number of bars processed. Used on an M15 timeframe, the indicator halts more quickly than when used on an H4 timeframe. There does not seem to be any correlation to any particular bar ... nothing simple like at the nth bar it stops. The chart where the indicator seemed to be working longer was using a longer bar period. When changed to a shorter period, it halts similarly to the other charts.
 

When you change the period, the init() function is called. So perhaps this is "resetting" whatever in your logic has caused the indicator to go off the rails.

CB

 
cloudbreaker:

When you change the period, the init() function is called. So perhaps this is "resetting" whatever in your logic has caused the indicator to go off the rails.

CB


Sounds correct. Now if I had some clue as to what was sending it "off the rails".
 

Print() statements are your friend - for checking logic flow and for checking the content of variables.

CB

 
cloudbreaker:

Print() statements are your friend - for checking logic flow and for checking the content of variables.

CB


Print statements show that the indicator is continuing to run, with execution proceeding completely through the start routine. Next statement after the last print is "return(0);"

And the indicator is executing repeatedly every second or two, or within the same second.

However, the inidcator values next to the short name in the upper left corner are blank (not just some old values no longer changing), and the lines that the indicator implicitly draws on its display have stopped being drawn, as of a prior bar.

To me, that pretty much puts the problem inside the MT4 code, but perhaps I am still doing something that leads to the situation.

 

Through use of Print statements for debugging, I have found a couple of problems so far:

(1) When the indicator appears to "stop", it has generated an indicator value of <maximum positive integer> (0x7FFFFFFF) . I don't know if that value has any special significance to MT4, such as being an uninitialized variable or something. Clearly it is not a valid indicator value.

(2) The following code fragment compiled without error, even though the function Highest is not defined anywhere:

High[Highest(NULL,0,MODE_HIGH,Period_Q,i)]

Somehow, it appears that what used to be an iHighest function call was changed to become Highest. The amazing thing is that the resulting program worked at all with this error. The MetaEditor syntax coloring works correctly in identifying that Highest is not a known function. It is not colored, as a known function would be. However, fixing that problem did not fix the indicator problem.

(3) The index buffer calculation limit for a new tick was being miscalculated, which caused parts of the indicator algorithm to be skipped due to negative loop limits, which resulted in un-computed index buffer values. This seems to be the root cause of the visible symptoms of the problem.

With those problems repaired, the indicator appears to be working now. Thanks cloudbreaker for the assist and the push to check deeper.

 
limasierra88:

I am the programmer..

and not without skills :)

As you found, integer capacity is certainly limited

... otherwise I wouldn't be asking here

But sadly many do drop by with code that has been... acquired elsewhere and then want it fixed or extended..

-BB-

Reason: