//+------------------------------------------------------------------+ //| Price_Extreme_Indicator.mq5 | //| Copyright 2018, MetaQuotes Software Corp. | //| https://mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2018, MetaQuotes Software Corp." #property link "https://mql5.com" #property version "1.00" #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 //--- plot BorderHigh #property indicator_label1 "Border High" #property indicator_type1 DRAW_LINE #property indicator_color1 clrYellow #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- plot BorderLow #property indicator_label2 "Border Low" #property indicator_type2 DRAW_LINE #property indicator_color2 clrBlue #property indicator_style2 STYLE_SOLID #property indicator_width2 1 //--- input parameters input int InpMultiplier=5; // Length of levels //--- indicator buffers double BufferBorderHigh[]; double BufferBorderLow[]; //--- global variables int multiplier; int coeff; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- settings parameters multiplier=(InpMultiplier<1 ? 1 : InpMultiplier); coeff=PeriodSeconds()*multiplier; //--- indicator buffers mapping SetIndexBuffer(0,BufferBorderHigh,INDICATOR_DATA); SetIndexBuffer(1,BufferBorderLow,INDICATOR_DATA); PlotIndexSetInteger(0,PLOT_SHIFT,multiplier); PlotIndexSetInteger(1,PLOT_SHIFT,multiplier); //--- 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[]) { //--- Checking for minimum number of bars if(rates_total1) { limit=rates_total-1-multiplier; } else limit+=multiplier+2; //--- calculate indicator for(int i=0; ilast_bar) res=0; else { const int shift=::Bars(Symbol(),timeframe,time,last_bar); if(shift>0) res=shift-1; } } return(res); } //+------------------------------------------------------------------+