//+------------------------------------------------------------------+ //| MovingMiniMax.mq5 | //| Copyright 2011, Investeo.pl | //| http://Investeo.pl | //+------------------------------------------------------------------+ #property copyright "Copyright 2011, Investeo.pl" #property link "http://Investeo.pl" #property description "Moving Mini-Max indicator" #property description "proposed by Z.K. Silagadze" #property description "from Budker Institute of Nuclear Physics" #property description "and Novosibirsk State University" #property description "Original paper can be downloaded from:" #property description "http://arxiv.org/abs/0802.0984" #property version "0.6" #property indicator_separate_window #property indicator_buffers 5 #property indicator_plots 3 #property indicator_type1 DRAW_COLOR_HISTOGRAM2 #property indicator_type2 DRAW_ARROW #property indicator_type3 DRAW_ARROW #property indicator_color1 Chartreuse, OrangeRed, Yellow #property indicator_color2 RoyalBlue #property indicator_color3 RoyalBlue #property indicator_width1 5 #property indicator_width2 4 #property indicator_width3 4 input int m=5; // Smoothing window width input int n=300; // Time window width double S[]; double sQiip1[],sQiim1[]; double sPiip1[],sPiim1[]; double dQiip1[],dQiim1[]; double dPiip1[],dPiim1[]; double sui[],dui[],uSi[],dSi[]; double upArrows[],dnArrows[]; double trend[]; int rCnt; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping //--- rCnt=0; ArrayResize(S,n+2*m); ArrayResize(sQiip1,n); ArrayResize(sQiim1,n); ArrayResize(sPiip1,n); ArrayResize(sPiim1,n); ArrayResize(sui,n); ArrayResize(dQiip1,n); ArrayResize(dQiim1,n); ArrayResize(dPiip1,n); ArrayResize(dPiim1,n); ArrayResize(dui,n); ArraySetAsSeries(uSi,true); ArraySetAsSeries(dSi,true); ArraySetAsSeries(upArrows,true); ArraySetAsSeries(dnArrows,true); ArraySetAsSeries(trend,true); SetIndexBuffer(0,uSi,INDICATOR_DATA); SetIndexBuffer(1,dSi,INDICATOR_DATA); SetIndexBuffer(2,trend,INDICATOR_COLOR_INDEX); SetIndexBuffer(3,upArrows,INDICATOR_DATA); SetIndexBuffer(4,dnArrows,INDICATOR_DATA); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0.0); PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0.0); PlotIndexSetInteger(1,PLOT_ARROW,234); PlotIndexSetInteger(2,PLOT_ARROW,233); PlotIndexSetInteger(0,PLOT_SHIFT,-(m-1)); PlotIndexSetInteger(1,PLOT_SHIFT,-(m-1)); PlotIndexSetInteger(2,PLOT_SHIFT,-(m-1)); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ void calcQii() { int i,k; for(i=0; i