//| Copyright 2019, Aleksey Panfilov. | //| filpan1@yandex.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2018, Aleksei Panfilov. filpan1@yandex.ru" #property link "filpan1@yandex.ru" #property version "1.1" #property indicator_chart_window #property indicator_buffers 3 #property indicator_plots 3 #property indicator_label1 "Line1" #property indicator_type1 DRAW_SECTION #property indicator_color1 clrSilver #property indicator_style1 STYLE_SOLID #property indicator_width1 4 #property indicator_label2 "Line2" #property indicator_type2 DRAW_LINE #property indicator_color2 clrOrangeRed #property indicator_style2 STYLE_SOLID #property indicator_width2 2 #property indicator_label3 "Line3" #property indicator_type3 DRAW_LINE #property indicator_color3 clrBlue #property indicator_style3 STYLE_SOLID #property indicator_width3 2 input double Delta_Kagi =40; int PRED_CHISLO_BAROV,y,yy; double Znach; double Znach_SR,VremVerh,VremNis; double High_Bar, Low_Bar, Delta, tendency; double Total_Volume; datetime time_Pred; double a1_Buffer[]; double a2_Buffer[]; double a3_Buffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { SetIndexBuffer(0,a1_Buffer,INDICATOR_DATA); SetIndexBuffer(1,a2_Buffer,INDICATOR_DATA); SetIndexBuffer(2,a3_Buffer,INDICATOR_DATA); //---- PlotIndexSetInteger(0,PLOT_SHIFT,-1); PlotIndexSetInteger(1,PLOT_SHIFT,-1); PlotIndexSetInteger(2,PLOT_SHIFT,-1); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0); //---- ArraySetAsSeries(a3_Buffer,true); ArraySetAsSeries(a2_Buffer,true); ArraySetAsSeries(a1_Buffer,true); 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,limit; ArraySetAsSeries(open,true); ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); ArraySetAsSeries(time,true); if(prev_calculated==0)// first calculation { limit= rates_total-1000; if(limit<1)return(0); for(i=rates_total-1;i>=limit;i--) { a1_Buffer[i]=open[limit]; a2_Buffer[i]=open[limit]; a3_Buffer[i]=open[limit]; } } else limit=rates_total-prev_calculated; for(i=limit;i>=0 && !IsStopped();i--) //====================================================================================================== { if( time[i+1] != time_Pred ) { a1_Buffer[i+1]= 0; y=y+1; //-------------------------------------------------------------------------------------------------- if( tendency <= 0 ) { if( high[i+1] >= VremVerh ) { VremVerh = high[i+1]; y=0; } if((VremVerh - low[i+1])/_Point >= Delta_Kagi ) { tendency = 1; VremNis = low[i+1]; a1_Buffer[i+y]= VremVerh; } } //-------------------------------------------------------------------------------------------------- if( tendency >= 0 ) { if( VremNis >= low[i+1] ) { VremNis = low[i+1]; y=0; } if((high[i+1] - VremNis)/_Point >= Delta_Kagi ) { tendency = -1; VremVerh = high[i+1]; a1_Buffer[i+y]= VremNis; } } //-------------------------------------------------------------------------------------------------- time_Pred = time[i+1] ; a2_Buffer[i+0]= VremNis; a3_Buffer[i+0]= VremVerh; } } //==================================================================================================================== return(rates_total); } //+------------------------------------------------------------------+