//+------------------------------------------------------------------+ //| SQ_Kaufman_v1.02.mq5 | //| SQ_Kaufman v1.02 Copyright 2015, fxborg | //| http://blog.livedoor.jp/fxborg/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, fxborg" #property link "http://blog.livedoor.jp/fxborg/" #property version "1.02" #property indicator_separate_window #property indicator_buffers 12 #property indicator_plots 4 #property indicator_type1 DRAW_COLOR_HISTOGRAM #property indicator_color1 clrGreen,clrRed #property indicator_type2 DRAW_LINE #property indicator_color2 clrGold #property indicator_type3 DRAW_LINE #property indicator_color3 clrSilver #property indicator_type4 DRAW_LINE #property indicator_color4 clrSilver #property indicator_width1 4 #property indicator_width2 1 #property indicator_width3 1 #property indicator_width4 1 #property indicator_style3 STYLE_DOT #property indicator_style4 STYLE_DOT //--- input ENUM_TIMEFRAMES CalcTF=PERIOD_M5; // Calclation TimeFrame input int VolatPeriod=10; // Volatility Period input int SmoothPeriod=3; // Smooth Period input int SlowPeriod=70; // SlowPeriod //--- input double Deviation=0.4; // Deviatoin //--- int Scale=PeriodSeconds(PERIOD_CURRENT)/PeriodSeconds(CalcTF); //--- //--- //--- double SQRangeBuffer[]; double SQColorBuffer[]; double SmoothSQBuffer[]; double SlowSQBuffer[]; double SQBuffer[]; double SlowVolatBuffer[]; double SlowStdDevBuffer[]; double BarVolatBuffer[]; double VolatBuffer[]; double StdDevBuffer[]; double MomBuffer[]; double MomMaBuffer[]; double MomHiBuffer[]; double MomLoBuffer[]; //--- //---- 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+SmoothPeriod; //--- if(i<=second)continue; double v=0.0; for(int j=0;jlow[i-j])dmin=low[i-j]; } //--- MomBuffer[i]=(close[i]-close[i-VolatPeriod])/MathMax(0.000000001,VolatBuffer[i]); SQBuffer[i]=(dmax-dmin)/MathMax(0.000000001,VolatBuffer[i]); //--- //--- int forth = third+MathMax(SmoothPeriod,SlowPeriod); if(i<=forth)continue; //--- double avg=0; for(int j=0;j=0)SQColorBuffer[i]=0.0; else SQColorBuffer[i]=1.0; //--- avg=0; for(int j=0;j