//+------------------------------------------------------------------+ //| Divergence_STS_reverse.mq4 | //| Copyright © 2007, STS | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, STS" #property link "http://www.metaquotes.net" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 White #property indicator_color2 DarkBlue extern int FastEMA = 3; extern int SlowEMA = 10; extern int SignalEMA = 16; extern int barlength= 8; extern int barwidth= 1; extern int MaxBars=500; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ double downout[],upout[]; int init() { //---- indicators IndicatorBuffers(7); SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,barwidth); SetIndexBuffer(0,upout); SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,barwidth); SetIndexBuffer(1,downout); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- int c; int shift; double ema0,ema1,kurs0,kurs1; for (shift=0;shift<=MaxBars;shift++){ downout[shift]=0; upout[shift]=0; } c=0; for (shift=0;shift<=MaxBars;shift++){ ema0=iCustom(NULL,0,"ZeroLag MACD",FastEMA,SlowEMA,SignalEMA,0,shift); ema1=iCustom(NULL,0,"ZeroLag MACD",FastEMA,SlowEMA,SignalEMA,0,shift+1); //Kurs low's up, ind down --> down if(iLow(NULL,0,shift)>=iLow(NULL,0,shift+1)){ if(ema0=Point*barlength){ downout[shift]=Low[shift]; upout[shift]=High[shift]; c=c+1; } } } //Kurs high's down, ind up --> up if(iHigh(NULL,0,shift)<=iHigh(NULL,0,shift+1)){ if(ema0>ema1){ if (MathAbs(High[shift+1]-Low[shift+1])>=Point*barlength){ downout[shift]=High[shift]; upout[shift]=Low[shift]; c=c+1; } } } } //---- //Print(c); return(0); } //+------------------------------------------------------------------+