//+------------------------------------------------------------------+ //| Ma Filter.mq4 | //| Copyright © 2011, MadWill | //| http://www.evgeno.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, MadWill" #property link "http://www.evgeno.ru" #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Red #property indicator_color2 Blue #property indicator_color3 DarkGray #property indicator_color4 LimeGreen #property indicator_color5 Magenta #property indicator_color6 White #property indicator_width1 2 #property indicator_width2 2 #property indicator_width4 2 #property indicator_width5 2 extern int MA_Period=110; extern int MA_Method=2; extern int Hist_MA=25; extern int Lenght=3000; extern int Step=3; //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; double ExtMapBuffer5[]; double ExtMapBuffer6[]; int BarTime,i,j; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexBuffer(2,ExtMapBuffer3); SetIndexStyle(3,DRAW_ARROW,EMPTY,2); SetIndexArrow(3,217); SetIndexBuffer(3,ExtMapBuffer4); SetIndexEmptyValue(3,0.0); SetIndexStyle(4,DRAW_ARROW,EMPTY,2); SetIndexArrow(4,218); SetIndexBuffer(4,ExtMapBuffer5); SetIndexEmptyValue(4,0.0); SetIndexStyle(5,DRAW_LINE); SetIndexBuffer(5,ExtMapBuffer6); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars; if(counted_bars==0) limit-=1+Hist_MA; for(i=limit;i>=1;i--) { double NewLevel=iMA(Symbol(),0,MA_Period,0,MA_Method,0,i); double OldLevel=iMA(Symbol(),0,MA_Period,0,MA_Method,0,i+Step); ExtMapBuffer3[i]=NewLevel-OldLevel; double Lev; Lev=0; for(j=i;jExtMapBuffer3[i]) { ExtMapBuffer1[i]=ExtMapBuffer3[i]; //ExtMapBuffer3[i]=0; } else ExtMapBuffer1[i]=0; if(ExtMapBuffer1[i]!=0 && ExtMapBuffer1[i+1]==0) { ExtMapBuffer5[i]=ExtMapBuffer3[i]; } else ExtMapBuffer5[i]=0; if(ExtMapBuffer2[i]!=0 && ExtMapBuffer2[i+1]==0) { ExtMapBuffer4[i]=ExtMapBuffer3[i]; } else ExtMapBuffer4[i]=0; } /* double NewLevel=iMA(Symbol(),0,MA_Period,0,MA_Method,0,i); double OldLevel=iMA(Symbol(),0,MA_Period,0,MA_Method,0,i+Step); ExtMapBuffer3[i]=NewLevel-OldLevel; double Lev; Lev=0; for(j=i;jExtMapBuffer3[i]) { ExtMapBuffer1[i]=ExtMapBuffer3[i]; //ExtMapBuffer3[i]=0; } else ExtMapBuffer1[i]=0; */ //---- return(0); } //+------------------------------------------------------------------+ int once() { for(i=Lenght;i>=1;i--) { double NewLevel=iMA(Symbol(),0,MA_Period,0,MA_Method,0,i); double OldLevel=iMA(Symbol(),0,MA_Period,0,MA_Method,0,i+Step); ExtMapBuffer3[i]=NewLevel-OldLevel; double Lev; Lev=0; for(j=i;jExtMapBuffer3[i]) { ExtMapBuffer1[i]=ExtMapBuffer3[i]; //ExtMapBuffer3[i]=0; } else ExtMapBuffer1[i]=0; if(ExtMapBuffer1[i]!=0 && ExtMapBuffer1[i+1]==0) { ExtMapBuffer5[i]=ExtMapBuffer3[i]; } else ExtMapBuffer5[i]=0; if(ExtMapBuffer2[i]!=0 && ExtMapBuffer2[i+1]==0) { ExtMapBuffer4[i]=ExtMapBuffer3[i]; } else ExtMapBuffer4[i]=0; } if(ExtMapBuffer4[i]!=0) Alert("Signal BUY!"); if(ExtMapBuffer5[i]!=0) Alert("Signal SELL!"); } //+------------------------------------------------------------------+