//+------------------------------------------------------------------+ //| BuySell_Filter.mq4 | //| Copyright © 2008, masemus | //| Gresik@Indonesia | //+------------------------------------------------------------------+ #property copyright "Copyright © 2008, masemus" #property link "Gresik@Indonesia" #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 1 #property indicator_buffers 4 #property indicator_color1 Red #property indicator_color2 FireBrick #property indicator_color3 SeaGreen #property indicator_color4 Lime //---- input parameters extern int TF=0; extern int MA1Period = 4; extern int MA1_Shift = 0; extern int MA1_Method = 0; extern int MA1_Price_Type = 0; extern int MA2Period = 4; extern int MA2_Shift = 0; extern int MA2_Method = 0; extern int MA2_Price_Type = 1; extern int MA3Period = 20; extern int MA3_Shift = 0; extern int MA3_Method = 0; extern int MA3_Price_Type = 0; extern int MA4Period = 20; extern int MA4_Shift = 0; extern int MA4_Method = 0; extern int MA4_Price_Type = 1; extern string Display_Text = " Scalp"; //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; string TimeFrameStr; //+------------------------------------------------------------------+ //| 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_HISTOGRAM); SetIndexBuffer(3,ExtMapBuffer4); switch(TF) { case 1 : TimeFrameStr="Period_M1"; break; case 5 : TimeFrameStr="Period_M5"; break; case 15 : TimeFrameStr="Period_M15"; break; case 30 : TimeFrameStr="Period_M30"; break; case 60 : TimeFrameStr="Period_H1"; break; case 240 : TimeFrameStr="Period_H4"; break; case 1440 : TimeFrameStr="Period_D1"; break; case 10080 : TimeFrameStr="Period_W1"; break; case 43200 : TimeFrameStr="Period_MN1"; break; default : TimeFrameStr="Current TF"; TF=0; } IndicatorShortName("BS_Filter ("+TimeFrameStr+")" + Display_Text); //---- 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 < 1000; i++){ ExtMapBuffer1[i]=0; ExtMapBuffer2[i]=0; ExtMapBuffer3[i]=0; ExtMapBuffer4[i]=0; double MA1 = iMA(Symbol(),TF,MA1Period,MA1_Shift,MA1_Method,MA1_Price_Type,i); double MA2 = iMA(Symbol(),TF,MA2Period,MA2_Shift,MA2_Method,MA2_Price_Type,i); double MA3 = iMA(Symbol(),TF,MA3Period,MA3_Shift,MA3_Method,MA3_Price_Type,i); double MA4 = iMA(Symbol(),TF,MA4Period,MA4_Shift,MA4_Method,MA4_Price_Type,i); if(MA1>MA2 && MA1>MA3)ExtMapBuffer4[i] = 1; if(MA1<=MA2 && MA1>MA3){ExtMapBuffer2[i] = 1;} if(MA1>MA2 && MA1<=MA3)ExtMapBuffer3[i] = 1; if(MA1<MA2 && MA1<MA3){ExtMapBuffer1[i] = 1;} } //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Indicator Curves created:
Implements a curve of type DRAW_HISTOGRAM
Indicators Used:
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features: