Here is an article about your question: https://www.mql5.com/en/articles/135
Creating Multi-Colored Indicators in MQL5
- www.mql5.com
In this article, we will consider how to create multi-colored indicators or convert the existing ones to multi-color. MQL5 allows to represent the information in the convenient form. Now it isn't necessary to look at a dozen of charts with indicators and perform analyses of the RSI or Stochastic levels, it's better just to paint the candles with different colors depending on the values of the indicators.
if (MaBuffer[i]>MaBuffer[i-lookback]) {ColorBuffer[i]=0;} if (MaBuffer[i]<MaBuffer[i-lookback]) {ColorBuffer[i]=1; }
I think this is what's needed but it doesn't work. I'm guessing because at the start of the moving average to the very left of the chart it's trying to compare the two ma's 30 bars apart but there is nothing there to compare it with. I'm not sure if I am right about that or what to do about it. Anyone got any ideas?
On a side note, after looking at some of the mql5 documentation, is it not possible in mt5 to just get a moving average by using iMA, it seems you have to fill it into a buffer before you can do anything with it?! So in mt4 you would just use iMA(Symbol(),1,malength,0,matype,0,1); and it would give you the ma value for the previous close and you can't just do that in mt5?
Anybody got any ideas about this?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello, I have the indicator in the code below which colours a moving average depending on whether it is going up or down. I would like to change it so that it looks back 30 bars so it only is green if the ma is higher than it was 30 bars ago or red if it is lower than 30 bars ago. I did this on the mt4 version with no problems but I am new to mt5 and just can't figure it out. I don't get the iCustomMA syntax and what r means? Anyway, if anyone could point me in the right direction I would appreciate it. Thanks