Indicator getting corrupted - page 5

 
Rosh:

What do you mean by corruptions? I have just attached your indicator at EURUSD M1 and I don't see any values.


The 32bit client terminal MetaTrader 4 shows the same picture. Are you sure that that provided indicator works?
 
Rosh:

The 32bit client terminal MetaTrader 4 shoes the same picture. Are you sure that that provided indicator works?
It looks like you've downloaded the original version of the example code (timestamped 2011.10.11 18:06). That doesn't draw anything for 25 minutes. In init(), it sets drawTime to TimeCurrent(), and only triggers any code in start() once (drawTime + 1500 < TimeCurrent()).

The second version, timestamped 2011.10.12 06:37, looks as though it should start drawing immediately.

But, anyway, the problems apparently don't start happening for several hours.
 
jjc:
It looks like you've downloaded the original version of the example code (timestamped 2011.10.11 18:06). That doesn't draw anything for 25 minutes.
Ok, I'll wait
 

The 32bit client terminal MetaTrader 4 shows the same picture. Are you sure that that provided indicator works?

- Yes. I am running the same indicator on a 32 bit machine also, since last night, approx 18 hrs. The problem is not occurring.

If you want another possible MT4 bug to pursue, what happens if you use Low[i] and High[i] rather than iLow() and iHigh() ?

- In my actual code iHighest / iHigh / iLowest / iLow etc are used.. Used High/Low in the example code to reduce complexity

 
RaptorUK:
I have an idea . . . but have to go out now, I've added the Indicator to a new chart, will test my idea when I get back and post results.

OK, just got back, chart looked fine since I first loaded the Indicator on . . then I tried my idea . . . I Paged Up to move the chart to the right so that new data would be downloaded . . and hey presto . .

This is what I suggested in this thread on 2011.10.07 19:08

 
RaptorUK:

OK, just got back, chart looked fine since I first loaded the Indicator on . . then I tried my idea . . . I Paged Up to move the chart to the right so that new data would be downloaded . . and hey presto . .

Okay, so you're hypothesising that the bar history is changing for some reason, and being back-filled, and the indicator is being affected because it only draws on a forward basis and doesn't follow the usual indicator behaviour of recalculating on the basis of things like IndicatorCounted() ?
 
jjc:
Okay, so you're hypothesising that the bar history is changing for some reason, and being back-filled, and the indicator is being affected because it only draws on a forward basis and doesn't follow the usual indicator behaviour of recalculating on the basis of things like IndicatorCounted() ?
I haven't look at the recent code . . but yes, something along the lines of what you have written.
 
RaptorUK:
I haven't look at the recent code . . but yes, something along the lines of what you have written.

Okay, in summary, what we appear to have is as follows:

* A normal indicator will use IndicatorCounted() to determine which bar values are "dirty" and need to be (re-)calculated.

* When you add extra bars to the history by scrolling back, IndicatorCounted() gets reset to zero. Therefore, at this point, a normal indicator will recalculate all its historic values.

* The indicator here doesn't do this. In effect, it ignores IndicatorCounted() and draws on a forward basis only.

* For some reason, AnkaSoftware's Win64 machine is periodically back-filling with older data but the Win32 machine isn't. The operating system is probably just coincidence in this context.

* It's a bit naughty that MT4 doesn't adjust the indicator buffers in the light of the new bars which have been added, and instead relies on the indicator code recalculating all the old values because IndicatorCounted() is reset. (However, it's reasonably justifiable, because the addition of older bar values to many indicators potentially affects subsequent calculations. For example, an EMA will change, albeit by a tiny value, if you add an extra bar at the beginning of the history.)

 
jjc:

* It's a bit naughty that MT4 doesn't adjust the indicator buffers in the light of the new bars which have been added, and instead relies on the indicator code recalculating all the old values because IndicatorCounted() is reset.

Actually, thinking about it, that's wrong. There's a good reason why MT4 tries to tell the indicator to recalculate everything, and that scenario may well have been applying here.

Let's say that the indicator has been running for a while, but there is then a disconnection from the broker which lasts for multiple bars. On re-connection MT4 will receive a tick and start drawing indicator values for the latest bar. Separately, asynchronously, and more slowly, it will receive the historic data for the missing bars which took place during the disconnection. These get inserted into the middle of the bar history, and therefore it's necessary for any normal indicator to redraw old values starting from at least the beginning of the disconnection period. In practice, it's understandable that MT4 takes the approach "redraw everything". The only quibble is whether MT4 should automatically change the buffer values to EMPTY_VALUE if they're potentially invalid.
 

Does this issue affects indicators-based ONLY?

how about others, say High[], low[], or iHigh, iLow, iLowest, iBarshift, etc, etc...., that's what I rather know and be clear about.