Time: 2018-08-18 | Download file:Rainbow_oscillator_-_binary.mq4
//+------------------------------------------------------------------+ //| rainbow oscillator.mq4 | //| mladen | //+------------------------------------------------------------------+ #property copyright "www.forex-tsd.com" #property link "www.forex-tsd.com" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 PaleVioletRed #property indicator_width1 2 #property indicator_minimum -1.1 #property indicator_maximum 1.1 // // // // // extern int RmaPeriod = 2; extern int RmaDepth = 10; extern int RmaPrice = PRICE_CLOSE; // // // // // #define MAX_depth 50 double trend[]; double pBuffer[][MAX_depth]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // int init() { SetIndexBuffer(0,trend); RmaPeriod = MathMax(RmaPeriod,2); RmaDepth = MathMax(MathMin(RmaDepth,MAX_depth),5); IndicatorShortName("Binary rainbow oscillator ("+RmaPeriod+","+RmaDepth+")"); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // #define initialMin EMPTY_VALUE #define initialMax -EMPTY_VALUE int start() { int counted_bars=IndicatorCounted(); int i,k,l,r,limit; if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=MathMin(Bars-counted_bars,Bars-1); 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,RmaPrice,i); double minp = initialMin; double maxp = initialMax; double sum = 0; for (k=0; kRmaPeriod) { for (l=0, price=0; l 0) trend[i] = 1; if (rangeo < 0) trend[i] = -1; } } return(0); }