Time: 2010-09-25 | Download file:Repulse_2.mq4
//+------------------------------------------------------------------+ //+------------------------------------------------------------------+ #property copyright "" #property link "" #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 LightGreen #property indicator_color2 Thistle #property indicator_color3 DimGray #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 #property indicator_level1 0.0 #property indicator_levelcolor DimGray // // // // // extern int RepulseLength = 5; // // // // // double repulse[]; double repulsh[]; double repulsl[]; double buffa[]; double buffb[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(5); SetIndexBuffer(0, repulsh); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(1, repulsl); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(2, repulse); SetIndexBuffer(3, buffa); SetIndexBuffer(4, buffb); return(0); } int deinit(){ return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int i,limit; if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit = MathMin(Bars-counted_bars,Bars-1); // // // // // double alpha = 2.0/(1.0+5.0*RepulseLength); for(i=limit; i>=0; i--) { double pricea = 100*(3.0*Close[i]-2.0*Low[iLowest(NULL,0,MODE_LOW,RepulseLength,i)]-Open[i+RepulseLength])/Close[i]; double priceb = 100*(Open[i+RepulseLength]+2.0*High[iHighest(NULL,0,MODE_HIGH,RepulseLength,i)]-3.0*Close[i])/Close[i]; if (i==Bars-1) { buffa[i] = pricea; buffb[i] = priceb; continue; } buffa[i] = buffa[i+1]+alpha*(pricea-buffa[i+1]); buffb[i] = buffb[i+1]+alpha*(priceb-buffb[i+1]); repulse[i] = buffa[i]-buffb[i]; repulsh[i] = EMPTY_VALUE; repulsl[i] = EMPTY_VALUE; if (repulse[i]>0) repulsh[i] = repulse[i]; if (repulse[i]<0) repulsl[i] = repulse[i]; } return(0); }