Change Indicator Line Color(Repeated Question After 5 Years)

 

this is a way to use MA in our code. but how can we change the style of line in the code?

I want two MOVING AVERAGE indicatror showed in page with two different color.

MA_Handle =iMA(NULL,PERIOD_M1,MA_Period,MA_Shift,MODE_SMA,PRICE_CLOSE);

something like this, with-ought using Chart Templates.

MA_Handle =iMA(NULL,PERIOD_M1,MA_Period,MA_Shift,MODE_SMA,PRICE_CLOSE,MA_Line_Color,MA_Line_Width);
                                                                      ?????????????,????????????? 
 
Boob Wood:

this is a way to use MA in our code. but how can we change the style of line in the code?

I want two MOVING AVERAGE indicatror showed in page with two different color.

something like this, withought using chart Templet.

What is a templet?

You get a handle to be able to access the MA values. Nothing is shown on the chart. You can't change line style/colour with the handle.

 
Keith Watford:

What is a templet?

You get a handle to be able to access the MA values. Nothing is shown on the chart. You can't change line style/colour with the handle.

Sorry,  Chart Templates is correct.

 

seems I have same problem.

Still no way to do it.

https://www.mql5.com/en/forum/38961

Set Indicator Line Color Through EA
Set Indicator Line Color Through EA
  • 2015.01.07
  • www.mql5.com
Hi guys, How to change an indicator line color after add it to the chart by an expert advisor...
 

Create another copy of the same indicator just with a different color and call them both.

Or copy the buffers and redraw them, you can use a different color for each candle.

Or create the indicator with 20 buffers that have the same data just a different color and only use the one with the desired color.

There are so many ways to accomplish something why do you say 

Boob Wood:

Still no way to do it.

 
Boob Wood:

seems I have same problem.

Still no way to do it.

https://www.mql5.com/en/forum/38961

I temporarily solved the problem.   

Copied MA.MQL5 into MA_RED.MQL5 And MA_BLUE.MQL5 I changed the color in the source of them and using handles using ICustom.

I know it is not a processional solution, but it solved my problem. 

Will be happy to see your solutions too. 

  MA_Blue_Handle  =iCustom(NULL,PERIOD_M1,"MA_Blue",MovingBluePeriod,0,MODE_SMA,PRICE_CLOSE);
  MA_Red_Handle   =iCustom(NULL,PERIOD_M1,"Ma_Red" ,MovingRedPeriod ,0,MODE_SMA,PRICE_CLOSE);
 
Marco vd Heijden:

Create another copy of the same indicator just with a different color and call them both.

Or copy the buffers and redraw them, you can use a different color for each candle.

Or create the indicator with 20 buffers that have the same data just a different color and only use the one with the desired color.

There are so many ways to accomplish something why do you say 

Thanks. I found one of them. Your comment appriciated.

thanks so much.

 
Boob Wood:

I temporarily solved the problem.   

Copied MA.MQL5 into MA_RED.MQL5 And MA_BLUE.MQL5 I changed the color in the source of them and using handles using ICustom.

I know it is not a processional solution, but it solved my problem. 

Will be happy to see your solutions too. 

If you are to make a custom version, just add the colors as standard parameters and apply them to your buffers in the code.
 
Boob Wood :

I temporarily solved the problem.   

Copied MA.MQL5 into MA_RED.MQL5 And MA_BLUE.MQL5 I changed the color in the source of them and using handles using ICustom.

I know it is not a processional solution, but it solved my problem. 

Will be happy to see your solutions too. 

You now have 2 MA indicators :)

Congratulations

 
what func that gui call can change of 

#property indicator_color1  clrRed

without change it in separate files 

is matetrader5 opensource to see what fucn call indicator ?
 
lol258 #: what func that gui call can change of 

 #property indicator_color1  clrRed

Perhaps you should read the manual.
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

Drop the property and call the function Custom IndicatorsPlotIndexSetIntegerENUM_PLOT_PROPERTY_INTEGER → PLOT_LINE_COLOR

Reason: