The gap represents the flat areas of moving average.
I don't know how to fill it though, maybe a coder can help.
Hello, I have developed a Moving Average, which consists of two lines with different colors. However, I have the problem that when the color changes, there is a gap. Is there a way to fill this gap? Many thanks in advance.
Copy the middle points into both buffers. You should add one more if statement to check if it's a middle point and copy the previous value of the MA to the current buffer.
Do you mean this?
if(MovingAverageBuffer[i]<MovingAverageBuffer[i+1]) { MovingAverageBufferRed[i]=MovingAverageBuffer[i]; if(MovingAverageBufferBlue[i+1]>0) { MovingAverageBufferRed[i+1]=MovingAverageBuffer[i+1]; } } else if(MovingAverageBuffer[i]>MovingAverageBuffer[i+1]) { MovingAverageBufferBlue[i]=MovingAverageBuffer[i]; if(MovingAverageBufferRed[i+1]>0) { MovingAverageBufferBlue[i+1]=MovingAverageBuffer[i+1]; } }
Do you mean this?
Don't. That will cause a classical repaint
If you want colors in separate buffers, then use the mode applied in mt4 nrp indicators - and then you shall need at least 3 buffers to make it non-repainting - but if you plan to use multiple buffers to check trend, then you are on a wrong path (it is much easier to only read a color buffer then to use multiple buffers to try to find out a "trend"/"slope")
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, I have developed a Moving Average, which consists of two lines with different colors. However, I have the problem that when the color changes, there is a gap. Is there a way to fill this gap? Many thanks in advance.