//+------------------------------------------------------------------+ //| bwhp_filter.mq5 | //| bwhp_filter Copyright 2016, fxborg | //| http://fxborg-labo.hateblo.jp/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2016, fxborg" #property link "http://fxborg-labo.hateblo.jp/" #property version "1.00" #property indicator_separate_window #define PId 3.1415926535897932384626433832795 #property indicator_levelcolor Silver #property indicator_buffers 1 #property indicator_plots 1 #property indicator_type1 DRAW_LINE #property indicator_color1 clrRed #property indicator_width1 2 unsigned int NumChann=1; // channels number double InpCutoff = 1.0; // cutoff frequency, in Hz input double InpFs = 14.0; // cutoff frequency in pediord input unsigned int InpNum_pole=2; // filter order int InpHighpass=1; // 0:lowpass, 1:highpass double Fc=InpCutoff/InpFs; /* normalized cut-off frequency, Hz */ double DEN[]; double NUM[]; double FILT[]; int min_rates_total=10; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { if(InpNum_pole>12) { Alert("error initializing expert!"); return(INIT_FAILED); } //--- //--- SetIndexBuffer(0,FILT,INDICATOR_DATA); //--- PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE); main(NUM,DEN); min_rates_total=ArraySize(NUM)*2; //--- digits return(0); } //+------------------------------------------------------------------+ //| 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); //--- int begin_pos=min_rates_total; first=begin_pos; if(first+1