//+------------------------------------------------------------------+ //| MACD_3_DEMA.mq4 | //+------------------------------------------------------------------+ #property link "http://www.forexfactory.com/showthread.php?t=29419" #property indicator_separate_window #property indicator_buffers 8 #property indicator_level1 0.0 #property indicator_color1 Blue #property indicator_color2 Blue #property indicator_color3 Red #property indicator_color4 Red #property indicator_color5 Green #property indicator_color6 Orange #property indicator_color7 SkyBlue #property indicator_color8 Tomato #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 #property indicator_width4 2 #property indicator_width5 2 #property indicator_width6 2 #property indicator_width7 2 #property indicator_width8 2 //---- input parameters extern int Fast1 = 5, Fast2 = 13, Slow = 50; extern bool DEMAs = true; //---- indicator buffers double Fast1_Buffer[], Fast2_Buffer[], Blue1_Buffer[], Blue2_Buffer[], Red1_Buffer[], Red2_Buffer[], Green_Buffer[], Ornge_Buffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorShortName("MACD of 3 DEMAs("+Fast1+","+Fast2+","+Slow+")"); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexStyle(3,DRAW_HISTOGRAM); SetIndexStyle(4,DRAW_HISTOGRAM); SetIndexStyle(5,DRAW_HISTOGRAM); SetIndexStyle(6,DRAW_LINE); SetIndexStyle(7,DRAW_LINE); SetIndexBuffer(0,Blue1_Buffer); SetIndexBuffer(1,Blue2_Buffer); SetIndexBuffer(2,Red1_Buffer); SetIndexBuffer(3,Red2_Buffer); SetIndexBuffer(4,Green_Buffer); SetIndexBuffer(5,Ornge_Buffer); SetIndexBuffer(6,Fast1_Buffer); SetIndexBuffer(7,Fast2_Buffer); } int start() { int limit = Bars-1-IndicatorCounted(); //---- DEMAs and MACD for(int i = limit; i >= 0; i--) { if(DEMAs) { Fast1_Buffer[i] = iCustom(NULL,0,"DEMA",Fast1,0,i)- iCustom(NULL,0,"DEMA",Slow, 0,i); Fast2_Buffer[i] = iCustom(NULL,0,"DEMA",Fast2,0,i)- iCustom(NULL,0,"DEMA",Slow, 0,i); } else { Fast1_Buffer[i] = iMA(NULL,0,Fast1,0,MODE_EMA,PRICE_CLOSE,i)- iMA(NULL,0,Slow, 0,MODE_EMA,PRICE_CLOSE,i); Fast2_Buffer[i] = iMA(NULL,0,Fast2,0,MODE_EMA,PRICE_CLOSE,i)- iMA(NULL,0,Slow, 0,MODE_EMA,PRICE_CLOSE,i); } Green_Buffer[i] = 0.0; Ornge_Buffer[i] = 0.0; Blue1_Buffer[i] = 0.0; Blue2_Buffer[i] = 0.0; Red1_Buffer[i] = 0.0; Red2_Buffer[i] = 0.0; //---- Colored Bars if(Fast1_Buffer[i]-Fast2_Buffer[i] > Fast1_Buffer[i+1]-Fast2_Buffer[i+1]) { Blue1_Buffer[i] = Fast1_Buffer[i]; Blue2_Buffer[i] = Fast2_Buffer[i]; } else { Red1_Buffer[i] = Fast1_Buffer[i]; Red2_Buffer[i] = Fast2_Buffer[i]; } if(Fast2_Buffer[i] > Fast2_Buffer[i+1]) { if(Fast1_Buffer[i] > 0.0 && Fast2_Buffer[i] > 0.0) Green_Buffer[i] = MathMin(Fast1_Buffer[i],Fast2_Buffer[i]); if(Fast1_Buffer[i] < 0.0 && Fast2_Buffer[i] < 0.0) Green_Buffer[i] = MathMax(Fast1_Buffer[i],Fast2_Buffer[i]); } else { if(Fast1_Buffer[i] > 0.0 && Fast2_Buffer[i] > 0.0) Ornge_Buffer[i] = MathMin(Fast1_Buffer[i],Fast2_Buffer[i]); if(Fast1_Buffer[i] < 0.0 && Fast2_Buffer[i] < 0.0) Ornge_Buffer[i] = MathMax(Fast1_Buffer[i],Fast2_Buffer[i]); } } //---- return(0); }
Sample
Analysis
Market Information Used:
Indicator Curves created:
Implements a curve of type DRAW_HISTOGRAM
Implements a curve of type DRAW_LINE
Indicators Used:
Moving average indicator
Custom Indicators Used:
DEMA
Order Management characteristics:
Other Features: