//+------------------------------------------------------------------+ //| SQ_Kaufman_v1.1.mq5 | //| SQ_Kaufman v1.1 Copyright 2015, fxborg | //| http://blog.livedoor.jp/fxborg/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, fxborg" #property link "http://blog.livedoor.jp/fxborg/" #property version "1.1" #property indicator_separate_window #property indicator_buffers 13 #property indicator_plots 4 #property indicator_type1 DRAW_COLOR_ARROW #property indicator_color1 clrRed, clrGold,clrLime, clrGreen #property indicator_type2 DRAW_COLOR_LINE #property indicator_color2 clrDodgerBlue,clrRed #property indicator_type3 DRAW_LINE #property indicator_color3 clrBlue #property indicator_type4 DRAW_NONE #property indicator_width1 4 #property indicator_width2 2 #property indicator_width3 1 #property indicator_style3 STYLE_DOT //--- input ENUM_TIMEFRAMES CalcTF=PERIOD_M10; // Calclation TimeFrame input int VolatPeriod=10; // Volatility Period input int VolatSmooth=5; // Volatility Smooth Period input int VolatSlowPeriod=70; // Volatility Slow Period input double VolatMid=0.3; // Volatility Mid Deviation input int MomPeriod=25; // Mom Period input int MomSmooth=5; // Mom Smooth Period int WildersPeriod=14; // WildersPeriod //--- int Scale=PeriodSeconds(PERIOD_CURRENT)/PeriodSeconds(CalcTF); //--- //--- //--- double VolatBuffer[]; double Volat2Buffer[]; double SQColorBuffer[]; double SQBuffer[]; double SlowVolatBuffer[]; double SlowStdDevBuffer[]; double BarVolatBuffer[]; double StdDevBuffer[]; double MomColorBuffer[]; double MomBuffer[]; double MomMaBuffer[]; double MomSarBuffer[]; double MomAtrBuffer[]; double SQSigBuffer[]; double DmyBuffer[]; double UpDnBuffer[]; //--- //---- declaration of global variables int min_rates_total; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { if(PeriodSeconds(PERIOD_CURRENT)(time[i]-10)) { double prev_price= tf_rates[pos].open; if((tf_bar_count==0 && pos>0 )||tf_bar_count>0) prev_price= tf_rates[pos-1].close; dsum+=MathAbs(prev_price-tf_rates[pos].close); tf_bar_count++; } //--- } //--- BarVolatBuffer[i]=dsum; int second=begin_pos+VolatPeriod; if(i<=second)continue; double volat=0.0; for(int j=0;jlow[i-j])dmin=low[i-j]; } //--- SQBuffer[i]=(dmax-dmin)/MathMax(0.000000001,Volat2Buffer[i]); //--- int forth = third+VolatSmooth+VolatSlowPeriod; if(i<=forth)continue; //--- double avg1,avg2; avg1=0; for(int j=0;j= -mid && VolatBuffer[i]<=0)SQColorBuffer[i]=1.0; else if(VolatBuffer[i]<= mid && VolatBuffer[i]>0)SQColorBuffer[i]=2.0; else SQColorBuffer[i]=3.0; SQSigBuffer[i]=0; //--- int sixis =fifth+MomPeriod; if(i<=sixis)continue; double avg=0; for(int j=0;jdv)) tr=dv; } else if(MomMaBuffer[i]>tr) { tr=MomMaBuffer[i]-dar; if((MomMaBuffer[i-1]>dv) && (tr=MomSarBuffer[i])MomColorBuffer[i]=0; else MomColorBuffer[i]=1; DmyBuffer[i]=-MomMaBuffer[i]; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double CalcUpDn(const double &o[],const double &h[],const double &l[],const double &c[],const int i) { double up= MathMax(0,(c[i]-o[i])) + (c[i]-l[i]); double dn= MathMax(0,(o[i]-c[i])) + (h[i]-c[i]); double dir=(up/MathMax(0.0000001,(up+dn))); return dir-0.5; }