//+------------------------------------------------------------------+ //| Swing Strength.mq5 | //| Swing Strength v1.02 Copyright 2015, fxborg | //| http://fxborg-labo.hateblo.jp/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, fxborg" #property link "http://fxborg-labo.hateblo.jp/" #property version "1.02" #include #property indicator_separate_window #property indicator_buffers 7 #property indicator_plots 3 #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 double InpThreshold=0.1;// Threshold Level int InpThresholdPeriod=100;// ThreshHold Period int InpAtrPeriod=10; //---- will be used as indicator buffers double UpBuffer[]; double DnBuffer[]; double UpperLvBuffer[]; double LowerLvBuffer[]; double MainBuffer[]; double SmoothBuffer[]; 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 SetIndexBuffer(0,SmoothBuffer,INDICATOR_DATA); SetIndexBuffer(1,ColorBuffer,INDICATOR_COLOR_INDEX); SetIndexBuffer(2,UpperLvBuffer,INDICATOR_DATA); SetIndexBuffer(3,LowerLvBuffer,INDICATOR_DATA); SetIndexBuffer(4,SlowBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(5,SigBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(6,MainBuffer,INDICATOR_CALCULATIONS); //--- PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,EMPTY_VALUE); //--- PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total); PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total); //--- string short_name="Swing Strength v1.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]