//+------------------------------------------------------------------+ //| hp_oscillator v1.00.mq5 | //| HP Oscillator v1.00 Copyright 2015, fxborg | //| http://fxborg-labo.hateblo.jp/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, fxborg" #property link "http://fxborg-labo.hateblo.jp/" #property version "1.00" #include #property indicator_separate_window #property indicator_buffers 3 #property indicator_plots 2 #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_level1 50 #property indicator_type1 DRAW_LINE #property indicator_color1 DodgerBlue #property indicator_width1 2 #property indicator_type2 DRAW_LINE #property indicator_color2 Gold #property indicator_style2 STYLE_DOT #property indicator_width2 1 //--- input parameters input int Inp1stPeriod=8; // Oscillator Period input int InpLambda=20; // HP Lambda input int InpCalc_Period=200;//HP Calc Period input int InpRePaint_Period=10;// RePaint Period //---- will be used as indicator buffers double OscBuffer[]; double SigBuffer[]; double MainBuffer[]; //---- 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+InpRePaint_Period*2; //--- indicator buffers mapping SetIndexBuffer(0,MainBuffer,INDICATOR_DATA); SetIndexBuffer(1,OscBuffer,INDICATOR_DATA); SetIndexBuffer(2,SigBuffer,INDICATOR_CALCULATIONS); IndicatorSetInteger(INDICATOR_DIGITS,2); //--- PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0); PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,0); //--- PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total); PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total); //--- string short_name="HP Oscillator 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=0; Hx--) { ayResult[Hx]=Ak[Hx]-Bk[Hx]*H1-Ck[Hx]*H2; H2=H1; H1=ayResult[Hx]; } //--- } //+------------------------------------------------------------------+