Hi
Is there a moving average indicator that changes color with direction similar to Hull?
Thanks
Gil

- www.mql5.com
You can modify the code in here https://www.mql5.com/en/docs/customind/plotindexsetinteger
Thanks for information,,, but this 'plotindexsetinteger' indicator is actually "Color Line" which already included in MT5....... but this indicator not always changing it's bullish-bearish color.......
I need very-very-very simple 'Color Moving Average' for MT5,,,, especially EMA 5-10,,,,,, without dot symbol, without alert sound/pop-up, and without more extra text information....... but maybe add color setting for bullish-bearish.
So, it should be original Moving Average (same as MT5 built-in) but with bullish-bearish color.
If it only need few adjustment, which part i should modify? ........ I'm really blind about programming.
or if this kind MA indicator is already there, where can I download?
Thank You
--------------------------------------
I found the indicator that I need is "Var Mov Avg",,,,,,, it showing every up-down direction in color,,,,, but this indicator have too many information, such as popup alert, dot symbol, text,,,,,,,,,, and it's too disturbing for me.
Sorry can't upload the coding here, because it might somebody's copyright,,,,,, but it easily found in google.
Thanks for information,,, but this 'plotindexsetinteger' indicator is actually "Color Line" which already included in MT5....... but this indicator not always changing it's bullish-bearish color.......
I need very-very-very simple 'Color Moving Average' for MT5,,,, especially EMA 5-10,,,,,, without dot symbol, without alert sound/pop-up, and without more extra text information....... but maybe add color setting for bullish-bearish.
So, it should be original Moving Average (same as MT5 built-in) but with bullish-bearish color.
If it only need few adjustment, which part i should modify? ........ I'm really blind about programming.
or if this kind MA indicator is already there, where can I download?
Thank You
--------------------------------------
I found the indicator that I need is "Var Mov Avg",,,,,,, it showing every up-down direction in color,,,,, but this indicator have too many information, such as popup alert, dot symbol, text,,,,,,,,,, and it's too disturbing for me.
Sorry can't upload the coding here, because it might somebody's copyright,,,,,, but it easily found in google.
Open MetaEditor (from Mt5 press F4), press Ctrl + N and select "Custom Indicator" to create new indicator. name your indicator, click next, select "OnCalculate (... prices)", click next and click finish.
Copy and paste the code from https://www.mql5.com/en/docs/customind/plotindexsetinteger to your new indicator.
Do this :
Find some code, to delete or to add with another code
#property indicator_width1 3 //<<-- find this and add the code below it //--- input parameters input int MA_Period=3; input int MA_Shift=0; input ENUM_MA_METHOD MA_Method=MODE_SMMA; input ENUM_APPLIED_PRICE MA_Price=PRICE_CLOSE; //--- indicator buffers //<<-- find this to add the code above double ColorLineBuffer[];
Find these codes and delete them all, we don't need them
//+------------------------------------------------------------------+ //| get color index | //+------------------------------------------------------------------+ int getIndexOfColor(int i) { int j=i%300; if(j<100) return(0);// first index if(j<200) return(1);// second index return(2); // third index }
Find these codes and delete to replace with another code
//--- static int ticks=0,modified=0; int limit; //--- first calculation or number of bars was changed if(prev_calculated==0) { //--- copy values of MA into indicator buffer ColorLineBuffer int copied=CopyBuffer(MA_handle,0,0,rates_total,ColorLineBuffer); if(copied<=0) return(0);// copying failed - throw away //--- now set line color for every bar for(int i=0;i<rates_total;i++) ColorBuffer[i]=getIndexOfColor(i); } else { //--- copy values of MA into indicator buffer ColorLineBuffer int copied=CopyBuffer(MA_handle,0,0,rates_total,ColorLineBuffer); if(copied<=0) return(0); ticks++;// ticks counting if(ticks>=5)//it's time to change color scheme { ticks=0; // reset counter modified++; // counter of color changes if(modified>=3)modified=0;// reset counter ResetLastError(); switch(modified) { case 0:// first color scheme PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,clrRed); PlotIndexSetInteger(0,PLOT_LINE_COLOR,1,clrBlue); PlotIndexSetInteger(0,PLOT_LINE_COLOR,2,clrGreen); Print("Color scheme "+modified); break; case 1:// second color scheme PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,clrYellow); PlotIndexSetInteger(0,PLOT_LINE_COLOR,1,clrPink); PlotIndexSetInteger(0,PLOT_LINE_COLOR,2,clrLightSlateGray); Print("Color scheme "+modified); break; default:// third color scheme PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,clrLightGoldenrod); PlotIndexSetInteger(0,PLOT_LINE_COLOR,1,clrOrchid); PlotIndexSetInteger(0,PLOT_LINE_COLOR,2,clrLimeGreen); Print("Color scheme "+modified); } } else { //--- set start position limit=prev_calculated-1; //--- now we set line color for every bar for(int i=limit;i<rates_total;i++) ColorBuffer[i]=getIndexOfColor(i); } }
...and replace it with this code
int limit; if (prev_calculated == 0) limit = prev_calculated + MA_Period + 1; else limit = prev_calculated - 1; //--- copy values of MA into indicator buffer ColorLineBuffer int copied=CopyBuffer(MA_handle,0,0,rates_total,ColorLineBuffer); if(copied<=0) return(0);// copying failed - throw away //Print ("rates total ",rates_total," prev_calc ",prev_calculated," limit ",limit," copied ", copied); for (int i = limit; i < rates_total; i++) { //--- now set line color for every bar if (ColorLineBuffer [i-1] == ColorLineBuffer [i]) ColorBuffer[i] = 0; else if (ColorLineBuffer [i-1] < ColorLineBuffer [i]) ColorBuffer[i] = 1; else ColorBuffer[i] = 2; }
Then press F7 to compile, if you're doing it right there will be no problem and you will have what you want.
You may also want to change this code for the color
#property indicator_type1 DRAW_COLOR_LINE //<<-- find this #property indicator_color1 clrRed,clrLime,clrBlue //<<-- this is the code for the color #property indicator_style1 STYLE_SOLID //<<-- find this

- www.mql5.com
Thanks Phi.nuts and all guys here...........
I'll try it,,,,, and if i success to compile, i will upload it here.......
Thanks Phi.nuts and all guys here...........
I'll try it,,,,, and if i success to compile, i will upload it here.......
Just don't forget to copyright it on your name. There's a case that other user stole the code and published it in code base as his code.
Better yet post it as your code in code base
It works...... compiled without error.
Thanks phi.nuts
---------------------------------
but it seems something wrong with indicator setting. I try to change any MA Period, MA Method into "Simple, Exponential, Smoothed - Close Price, Open Price, etc"..... but the result still the same..... maybe still more work to improve this.
but currently, this version is 90% closed for what i need.

- www.mql5.com
It works...... compiled without error.
Thanks phi.nuts
---------------------------------
but it seems something wrong with indicator setting. I try to change any MA Period, MA Method into "Simple, Exponential, Smoothed - Close Price, Open Price, etc"..... but the result still the same..... maybe still more work to improve this.
but currently, this version is 90% closed for what i need.
Ah yes, I didn't check that yesterday :(
Will be back later.
Ah yes, I didn't check that yesterday :(
Will be back later.
Find this code
//--- indicator buffers mapping SetIndexBuffer(0,ColorLineBuffer,INDICATOR_DATA); SetIndexBuffer(1,ColorBuffer,INDICATOR_COLOR_INDEX); //--- get MA handle MA_handle=iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE); //---
Replace with this
//--- indicator buffers mapping SetIndexBuffer(0,ColorLineBuffer,INDICATOR_DATA); SetIndexBuffer(1,ColorBuffer,INDICATOR_COLOR_INDEX); PlotIndexSetInteger(0, PLOT_SHIFT, MA_Shift); //--- get MA handle MA_handle=iMA(Symbol(),_Period,MA_Period, 0,MA_Method,MA_Price);
And please reply back for the err.
Sorry about that.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
Is there a moving average indicator that changes color with direction similar to Hull?
Thanks
Gil