Time: 2010-09-11 | Download file:Stochastic_RSI_2.mq4
//+------------------------------------------------------------------+ //| Stochastic RSI | //| mladen | //+------------------------------------------------------------------+ #property copyright "www.forex-tsd.com" #property link "www.forex-tsd.com" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 DeepSkyBlue #property indicator_color2 PaleVioletRed #property indicator_width1 2 #property indicator_style2 STYLE_DOT #property indicator_level2 20 #property indicator_level1 80 #property indicator_minimum 0 #property indicator_maximum 100 // // // // // extern int RsiPeriod = 14; extern int RsiPrice = PRICE_CLOSE; extern int StochasticKPeriod = 14; extern int StochasticSlowing = 3; extern int StochasticSlowingMaMethod = MODE_SMA; extern int StochasticDPeriod = 3; extern int StochasticDMaMethod = MODE_SMA; // // // // // double stochRsi[]; double stochRsiSignal[]; double rsi[]; double stoch[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // int init() { IndicatorBuffers(4); SetIndexBuffer(0,stochRsi); SetIndexBuffer(1,stochRsiSignal); SetIndexBuffer(2,rsi); SetIndexBuffer(3,stoch); // // // // // IndicatorShortName("Stochastic RSI ("+RsiPeriod+","+StochasticKPeriod+","+StochasticSlowing+","+StochasticDPeriod+")"); 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); // // // // // for(i=limit; i>=0; i--) { rsi[i] = iRSI(NULL,0,RsiPeriod,RsiPrice,i); double min = rsi[ArrayMinimum(rsi,StochasticKPeriod,i)]; double max = rsi[ArrayMaximum(rsi,StochasticKPeriod,i)]; stoch[i] = 0; if (min!=max) stoch[i] = 100.0*(rsi[i]-min)/(max-min); } for(i=limit; i>=0; i--) stochRsi[i] = MathMin(MathMax(iMAOnArray(stoch ,0,StochasticSlowing,0,StochasticSlowingMaMethod,i),0),100); for(i=limit; i>=0; i--) stochRsiSignal[i] = MathMin(MathMax(iMAOnArray(stochRsi,0,StochasticDPeriod,0,StochasticDMaMethod ,i),0),100); return(0); }