//+------------------------------------------------------------------+ //| SQ_Kaufman_v1.0.mq5 | //| SQ_Kaufman v1.01 Copyright 2015, fxborg | //| http://blog.livedoor.jp/fxborg/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, fxborg" #property link "http://blog.livedoor.jp/fxborg/" #property version "1.01" #property indicator_separate_window #property indicator_buffers 9 #property indicator_plots 2 #property indicator_type1 DRAW_LINE #property indicator_color1 DodgerBlue #property indicator_type2 DRAW_LINE #property indicator_color2 clrRed #property indicator_width1 2 #property indicator_width2 1 #property indicator_style2 STYLE_DOT //--- input ENUM_TIMEFRAMES CalcTF=PERIOD_M5; // Calclation TimeFrame input int VolatPeriod=7; // Volatility Period input int SmoothPeriod=3; // Smooth Period input int SlowPeriod=70; // SlowPeriod //--- //input ENUM_MA_METHOD MaMethod=MODE_EMA; // Ma Method //input ENUM_APPLIED_PRICE MaPriceMode=PRICE_TYPICAL; // Ma Price Mode //--- int Scale=PeriodSeconds(PERIOD_CURRENT)/PeriodSeconds(CalcTF); //--- //--- //--- double SmoothSQBuffer[]; double SlowSQBuffer[]; double SQBuffer[]; double SlowVolatBuffer[]; double SlowStdDevBuffer[]; double BarVolatBuffer[]; double VolatBuffer[]; double MaBuffer[]; double PriceMaBuffer[]; double StdDevBuffer[]; double PriceBuffer[]; //--- //---- 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]; } SQBuffer[i]=(dmax-dmin)/VolatBuffer[i]; int forth = third+MathMax(SmoothPeriod,SlowPeriod); if(i<=forth)continue; double avg=0; for(int j=0;j