Download MetaTrader 5

Changing timeframe causes indicator to "ghost"

To add comments, please log in or register
Share your program via Code Base. Gain access to millions of traders!
kstar
12
kstar 2014.01.29 04:10 

Hi,

I'm looking for some help. I'm just starting out programming and I've used the widely available fractals.mq4 indicator as a base to play around with (https://www.mql5.com/en/code/7982). However, I've noticed that if I have the fractals indicator attached to a chart, something weird happens when I change timeframes - the indicator will plot, but then if you try to move the chart back in time it will plot extra points in a seemingly random pattern (pics below).

As I've used the fractals.mq4 as a base for other indicators, I'm getting the same issue on these too. Can anyone tell me what is going on please? I've checked the deinit code, and I'm getting REASON_CHARTCHANGE so I think that's functioning normally. I've also tried this on two different broker platforms and I get the same error.

Thanks in advance

Normal indicator:

normal

Ghosted indicator:

ghosted

qjol
3243
qjol 2014.01.29 07:14  
by using iCustom() or iFractals() u dont need the indicator output on the chart at all
whroeder1
14530
whroeder1 2014.01.29 14:26  
kstar: play around with (https://www.mql5.com/en/code/7982). Changing timeframe causes indicator to "ghost"
The indicator assumes that the buffers are set to empty like the documentation says. It never sets, non-fractal bars to zero. Mt4 bug.
   while(i>=2)
     {
ExtDownFractalsBuffer[i]=0; // Added
ExtUpFractalsBuffer[i]  =0; // code.

      //----Fractals up
kstar
12
kstar 2014.01.29 17:17  
qjol:
by using iCustom() or iFractals() u dont need the indicator output on the chart at all
Thanks qjol, I do indeed use iFractals() where I can, but I'd written my own indicators from this base. Thanks for the reply
kstar
12
kstar 2014.01.29 17:19  
WHRoeder:
The indicator assumes that the buffers are set to empty like the documentation says. It never sets, non-fractal bars to zero. Mt4 bug.

Thanks WHRoeder, you're a genius! That solved my issue instantly :)

I'll bear this bug in mind in the future

To add comments, please log in or register