//+------------------------------------------------------------------+
//| Guppy Mulitple Moving Average (Short double).mq4|
//|
candlexu@163.Com|
//| |
//+------------------------------------------------------------------+
#property copyright "2008 candlexu"
#property indicator_chart_window
//#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Yellow//Magenta
#property indicator_color2 Red
#property indicator_color3 Magenta
#property indicator_color4 DeepSkyBlue
#property indicator_color5 Orchid
#property indicator_color6 Red
#property indicator_color7 Aqua
#property indicator_color8 Red
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 3
#property indicator_width6 3
#property indicator_width7 2
#property indicator_width8 2
extern int ma7= 7;
extern int ma13= 13;
extern int ma26= 26;
extern int ma104= 104;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer1_1[];
double ExtMapBuffer2[];
double ExtMapBuffer2_2[];
double ExtMapBuffer3[];
double ExtMapBuffer3_3[];
double ExtMapBuffer4[];
double ExtMapBuffer4_4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer1_1);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtMapBuffer2);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,ExtMapBuffer2_2);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,ExtMapBuffer3);
SetIndexStyle(5,DRAW_LINE);
SetIndexBuffer(5,ExtMapBuffer3_3);
SetIndexStyle(6,DRAW_LINE);
SetIndexBuffer(6,ExtMapBuffer4);
SetIndexStyle(7,DRAW_LINE);
SetIndexBuffer(7,ExtMapBuffer4_4);
//----
return(0);
}
int deinit()
{
return(0);
}
int start()
{
int i,j,limit,counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i=0; i<limit; i++){
ExtMapBuffer1
=iMA(NULL,0,ma7,0,MODE_SMA,PRICE_CLOSE,i);
ExtMapBuffer2=iMA(NULL,0,ma13,0,MODE_SMA,PRICE_CLOSE,i);
ExtMapBuffer3=iMA(NULL,0,ma26,0,MODE_SMA,PRICE_CLOSE,i);
ExtMapBuffer4=iMA(NULL,0,ma104,0,MODE_SMA,PRICE_CLOSE,i);
}
for(j = Bars-counted_bars-1;j>=0;j--)
{
if(ExtMapBuffer1[j]>ExtMapBuffer1[j+1]) ExtMapBuffer1_1[j]=ExtMapBuffer1[j]; else ExtMapBuffer1_1[j]=EMPTY_VALUE;
if(ExtMapBuffer2[j]>ExtMapBuffer2[j+1]) ExtMapBuffer2_2[j]=ExtMapBuffer2[j]; else ExtMapBuffer2_2[j]=EMPTY_VALUE;
if(ExtMapBuffer3[j]>ExtMapBuffer3[j+1]) ExtMapBuffer3_3[j]=ExtMapBuffer3[j]; else ExtMapBuffer3_3[j]=EMPTY_VALUE;
if(ExtMapBuffer4[j]>ExtMapBuffer4[j+1]) ExtMapBuffer4_4[j]=ExtMapBuffer4[j]; else ExtMapBuffer4_4[j]=EMPTY_VALUE;
}
return(0);
}
//+------------------------------------------------------------------+
这个就是变色均线指标。可不懂怎么放到副图中去。