//+------------------------------------------------------------------+ //| moving MinMax | //| | //| original mq5 version made by investeo | //| coversion to mq4 by mladen //+------------------------------------------------------------------+ #property copyright "www,forex-tsd.com" #property link "www,forex-tsd.com" #property indicator_separate_window #property indicator_buffers 7 #property indicator_color1 DeepSkyBlue #property indicator_color2 PaleVioletRed #property indicator_color3 Yellow #property indicator_color4 DeepSkyBlue #property indicator_color5 PaleVioletRed #property indicator_color6 DeepSkyBlue #property indicator_color7 PaleVioletRed #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 #property indicator_width4 1 #property indicator_width5 1 #property indicator_width6 2 #property indicator_width7 2 // // // // // extern int Smoothing = 5; extern int Window = 300; extern int Price = PRICE_CLOSE; // // // // // double mmUp[]; double mmDn[]; double mmUph[]; double mmDnh[]; double mmUpa[]; double mmDna[]; double mmYeh[]; double prices[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // int init() { IndicatorBuffers(8); SetIndexBuffer(0,mmUph); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(1,mmDnh); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(2,mmYeh); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexBuffer(3,mmUpa); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,233); SetIndexBuffer(4,mmDna); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,234); SetIndexBuffer(5,mmUp); SetIndexBuffer(6,mmDn); SetIndexBuffer(7,prices); IndicatorShortName("Moving MinMax ("+Smoothing+","+Window+")"); return(0); } int deinit() { return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // double S[]; double work[][10]; #define sQiip1 0 #define sQiim1 1 #define sPiip1 2 #define sPiim1 3 #define dQiip1 4 #define dQiim1 5 #define dPiip1 6 #define dPiim1 7 #define sui 8 #define dui 9 // // // // // int start() { int scount = Window+2*Smoothing; int i,k,limit,counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit = MathMin(Bars-counted_bars,Bars-1); if (ArrayRange(work,0) != Window) ArrayResize(work,Window); if (ArrayRange(S,0) != scount) ArrayResize(S ,scount); // // // // // for(i=limit; i>=0; i--) prices[i] = iMA(NULL,0,1,0,MODE_SMA,Price,i); ArrayCopy(S,prices,0,0,scount); for (i=0; idnval) { dnval=mmDn[i]; dnind=i; } if(mmUp[i]>upval) { upval=mmUp[i]; upind=i; } mmUph[i] = EMPTY_VALUE; mmDnh[i] = EMPTY_VALUE; mmUpa[i] = EMPTY_VALUE; mmDna[i] = EMPTY_VALUE; mmYeh[i] = EMPTY_VALUE; } if(upind