//+------------------------------------------------------------------+ //| Swing Strength.mq5 | //| Swing Strength v2.0 Copyright 2015, fxborg | //| http://fxborg-labo.hateblo.jp/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, fxborg" #property link "http://fxborg-labo.hateblo.jp/" #property version "2.0" #include #property indicator_separate_window #property indicator_buffers 12 #property indicator_plots 1 #property indicator_type1 DRAW_COLOR_LINE #property indicator_color1 Red,Gray,DodgerBlue #property indicator_type2 DRAW_FILLING #property indicator_color2 DarkSlateGray #property indicator_width1 2 //--- input parameters input int Inp1stPeriod=7; // 1st Period input int Inp2ndPeriod=21;// 2nd Period input int InpSMoothing=2;// Smoothing Period int InpAtrPeriod=100; // SATR double InpThreshold=0.05;// Threshold Level double tema_alpha = 2.0 /(1.0 + InpAtrPeriod); int InpThresholdPeriod=100;// ThreshHold Period //---- will be used as indicator buffers double EMA1[]; double EMA2[]; double EMA3[]; double TEMA[]; double TR[]; double ATR[]; double UpBuffer[]; double DnBuffer[]; double RawBuffer[]; double SmoothBuffer[]; double MainBuffer[]; double ColorBuffer[]; double SigBuffer[]; double SlowBuffer[]; //---- declaration of global variables int min_rates_total; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //---- Initialization of variables of data calculation starting point min_rates_total=Inp1stPeriod+Inp2ndPeriod; //--- indicator buffers mapping int i=0; SetIndexBuffer(i++,MainBuffer,INDICATOR_DATA); SetIndexBuffer(i++,ColorBuffer,INDICATOR_COLOR_INDEX); SetIndexBuffer(i++,SlowBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,SigBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,RawBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,SmoothBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,ATR,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,TEMA,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,TR,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,EMA1,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,EMA2,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,EMA3,INDICATOR_CALCULATIONS); //--- //--- PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total); //--- string short_name="Swing Strength v2.00"; IndicatorSetString(INDICATOR_SHORTNAME,short_name); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- int i,first; if(rates_total<=min_rates_total) return(0); //--- //+----------------------------------------------------+ //|Set Median Buffeer | //+----------------------------------------------------+ int begin_pos=min_rates_total; first=begin_pos; if(first+1=ma-th)sign=1; else if( SmoothBuffer[i]>ma)sign=2; else if( SmoothBuffer[i]