//+------------------------------------------------------------------+ //| accel_trend.mq5 | //| accel_trend Copyright 2016, fxborg | //| http://fxborg-labo.hateblo.jp/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2016, fxborg" #property link "http://fxborg-labo.hateblo.jp/" #property version "1.00" #include #property indicator_levelcolor Silver #property indicator_minimum 0 #property indicator_maximum 1 #property indicator_buffers 7 #property indicator_plots 2 #property indicator_separate_window #property indicator_type1 DRAW_COLOR_HISTOGRAM #property indicator_color1 clrCornflowerBlue,clrSalmon #property indicator_width1 4 //+------------------------------------------------------------------+ //--- input parameters input double InpAccelSpeed=0.45; // Accel Speed input int InpAccelPeriod=20; // AccelMA Period input int InpAccelSmooth=12; //Smoothing input int InpSigPeriod=15; //Signal Period; double InpThreshhold=0.04; // Threshhold int AccelPeriod=int(InpAccelSpeed*20); double alpha=MathMax(0.001,MathMin(1,InpAccelSpeed)); //---- will be used as indicator buffers double MA[]; double MOM[]; double VOLAT[]; double Accel[]; double HIST[]; double CLR[]; double MAIN[]; double SIG[]; //---- declaration of global variables // SuperSmoother Filter double SQ2=sqrt(2); double A1 = MathExp( -SQ2 * M_PI / InpAccelSmooth ); double B1 = 2 * A1 * MathCos( SQ2 *M_PI / InpAccelSmooth ); double C2 = B1; double C3 = -A1 * A1; double C1 = 1 - C2 - C3; int min_rates_total; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //---- Initialization of variables of data calculation starting point min_rates_total=2; //--- indicator buffers int i=0; SetIndexBuffer(i++,HIST,INDICATOR_DATA); SetIndexBuffer(i++,CLR,INDICATOR_COLOR_INDEX); SetIndexBuffer(i++,MAIN,INDICATOR_DATA); SetIndexBuffer(i++,SIG,INDICATOR_DATA); SetIndexBuffer(i++,MA,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,MOM,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,VOLAT,INDICATOR_CALCULATIONS); for(int j=0;jdmax)dmax=dsum; if(dsum