//+------------------------------------------------------------------+ //| rmo.mq4 | //| mladen | //| Rahul Mohindar Oscillator | //| originaly developed by : ???????? | //+------------------------------------------------------------------+ #property copyright "copyleft mladen" #property link "mladenfx@gmail.com" #property indicator_chart_window #property indicator_buffers 6 #property indicator_color1 Red #property indicator_color2 Blue #property indicator_color3 Red #property indicator_color4 Blue #property indicator_color5 Red #property indicator_color6 Blue #property indicator_width1 1 #property indicator_width2 1 #property indicator_width3 1 #property indicator_width4 1 // // // // // extern int MALength = 2; extern int Depth = 10; extern int SignalsSmooth = 30; extern int Smooth = 81; extern int Price = PRICE_CLOSE; extern bool ShowRMO = true; extern bool ShowSignals = true; // // // // // #define MAX_depth 30 #define MAX_array 36 #define RMO_price 30 #define RMO_raw 31 #define RMO_smooth 32 #define RMO_signal 33 #define RMO_signas 34 #define RMO_trend 35 // // // // // double buffer1[]; double buffer2[]; double buffer3[]; double buffer4[]; double buffer5[]; double buffer6[]; double pBuffer[][MAX_array]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // int init() { SetIndexBuffer(0,buffer1); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(1,buffer2); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(2,buffer3); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexBuffer(3,buffer4); SetIndexStyle(3,DRAW_HISTOGRAM); SetIndexBuffer(4,buffer5); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,234); SetIndexBuffer(5,buffer6); SetIndexStyle(5,DRAW_ARROW); SetIndexArrow(5,233); // // // // // if (!ShowSignals) ShowRMO = true; // // // // // MALength = MathMax(MALength,2); Depth = MathMax(MathMin(Depth,MAX_depth),2); IndicatorShortName("rmo ("+MALength+","+Depth+","+Smooth+")"); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // int start() { double alpha = 2.0/(Smooth+1.0); double alphs = 2.0/(SignalsSmooth+1.0); int counted_bars=IndicatorCounted(); int i,l,r,limit; if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; if (ArrayRange(pBuffer,0) != Bars) ArrayResize(pBuffer,Bars); // // // // // for(i=limit, r=Bars-limit-1; i>=0; i--,r++) { double price = iMA(NULL,0,1,0,MODE_SMA,Price,i); pBuffer[r][RMO_price] = price; double high = price; double low = price; double sum = 0; // // // // // for (int k=0; k high) high = pBuffer[r-k][RMO_price]; if (pBuffer[r-k][RMO_price] < low && r>=k) low = pBuffer[r-k][RMO_price]; pBuffer[r][k] = price; if (r>MALength) { for (l=0, price=0; lClose[i]) { buffer3[i] = Open[i]; buffer4[i] = Close[i]; } else { buffer4[i] = Open[i]; buffer3[i] = Close[i]; } } else { buffer1[i] = Low[i]; buffer2[i] = High[i]; if (Open[i]pBuffer[r][RMO_signas]) pBuffer[r][RMO_trend] = 1; if (pBuffer[r][RMO_signal]