Code:
//+------------------------------------------------------------------+
//| Color_Ma.mq4.mq4
//| pipsforever
//| http://www.trader-forex.fr/forum/programmation/30240-changer-la-couleur-dune-mm.html#post87444
//+------------------------------------------------------------------+
#property copyright "pipsforever"
#property link "http://www.trader-forex.fr/forum/programmation/30240-changer-la-couleur-dune-mm.html#post87444"
#property indicator_chart_window
#property indicator_buffers 4
extern int Fast = 10;
extern int Slow = 20;
extern color Up = PaleGreen;
extern color Down=Bisque;
extern color Ma_1 = Black;
extern color Ma_2 = Black;
double H1[];
double H2[];
double M1[];
double M2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0,H1);
SetIndexStyle(0,DRAW_HISTOGRAM,0,5,Up);
SetIndexBuffer(1,H2);
SetIndexStyle(1, DRAW_HISTOGRAM,0,5,Down);
SetIndexBuffer(2,M1);
SetIndexStyle(2,DRAW_LINE,0,2,Ma_1);
SetIndexBuffer(3,M2);
SetIndexStyle(3,DRAW_LINE,0,2,Ma_2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
for (int i =0; i<Bars-Slow; i++)
{
H1[i] = iMA(Symbol(),0,Fast,0,MODE_SMA,PRICE_CLOSE,i);
H2[i] = iMA(Symbol(),0,Slow,0,MODE_SMA,PRICE_CLOSE,i);
M1[i] = iMA(Symbol(),0,Fast,0,MODE_SMA,PRICE_CLOSE,i);
M2[i] = iMA(Symbol(),0,Slow,0,MODE_SMA,PRICE_CLOSE,i);
}
//----
return(0);
}
//+------------------------------------------------------------------+