//+------------------------------------------------------------------+ //| test_price.mq4 | //| Copyright 2018, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2018, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_separate_window #property indicator_buffers 1 #property indicator_plots 1 //--- plot line1 #property indicator_label1 "line1" #property indicator_type1 DRAW_HISTOGRAM #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 2 //--- input parameters input int Bar_PLUS=12; //--- indicator buffers double line1Buffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,line1Buffer); IndicatorDigits(Digits); //--- 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,j,limit,count; if(prev_calculated==0) { limit=rates_total-Bar_PLUS -1; } else limit=rates_total-prev_calculated; for(i=limit; i>=0 && !IsStopped(); i--) { count= 0; for(j=i;j<=i+Bar_PLUS;j++) { if(open[j]close[j]) count--; } line1Buffer[i]=count; } //--- return(rates_total); } //+------------------------------------------------------------------+