
 #property copyright "eevviill"
 #property link      "http://alievtm.blogspot.com"
 #property version   "1.0"
 //#property icon "\\Files\\evi.ico"
 #property strict
 #property indicator_separate_window

 #property indicator_buffers 2
 #property indicator_color1 clrLightBlue
 #property indicator_color2 clrRed
 #property indicator_width1 1
 #property indicator_width2 1
 #property indicator_minimum 0
 #property indicator_maximum 1


 extern string emp1 = "//////main settings/////////////";
 extern int Bars_To_Count = 300;
extern string ind_name = "ADX_WildersDMI_v1m";
extern double buy_level = 20;
extern double sell_level = 20;
extern ENUM_TIMEFRAMES TF1 = PERIOD_CURRENT;
extern ENUM_TIMEFRAMES TF2 = PERIOD_CURRENT;
extern ENUM_TIMEFRAMES TF3 = PERIOD_CURRENT;
extern int       MA_Length  =1; // Period of additional smoothing 
extern int       DMI_Length  =14; // Period of DMI
extern int       ADX_Length  =14; // Period of ADX
extern int       ADXR_Length =14; // Period of ADXR
extern int       UseADX     =1; // Use ADX: 0-off,1-on
extern int       UseADXR    =1; // Use ADXR: 0-off,1-on






 double up_histog[];
 double down_histog[];



/////////////////////////////////////////////////////////////////
 int OnInit()
  {
 SetIndexBuffer(0,up_histog);
 SetIndexStyle(0,DRAW_HISTOGRAM);
 SetIndexLabel(0,"UP arrow");

 SetIndexBuffer(1,down_histog);
 SetIndexStyle(1,DRAW_HISTOGRAM);
 SetIndexLabel(1,"DOWN arrow");


   return(INIT_SUCCEEDED);
  }



//////////////////////////////////////////////////////////////////
 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[])
  {
   //no bars
 if(Bars<20) return(rates_total);
  
  //history update
  int all=rates_total;
  int counted=prev_calculated;
  if(all-counted>1)
  {
  ArrayInitialize(up_histog,EMPTY_VALUE);
  ArrayInitialize(down_histog,EMPTY_VALUE);
  counted=0;
  }
   
  int limit=MathMin(all-counted,Bars_To_Count);
 double adx_dmi1=0;
 double adx_dmi2=0;
  double adx_dmi3=0;

   //main
 for(int i=limit;i>=0;i--)
 {
 if(i>Bars-20) i=Bars-20;

 if(i==0)
 {
 up_histog[i]=EMPTY_VALUE;
 down_histog[i]=EMPTY_VALUE;
 }
 adx_dmi1=iCustom(Symbol(),TF1,ind_name,MA_Length,DMI_Length,ADX_Length,ADXR_Length,UseADX,UseADXR,0,iBarShift(Symbol(),TF1,Time[i]));
 adx_dmi2=iCustom(Symbol(),TF2,ind_name,MA_Length,DMI_Length,ADX_Length,ADXR_Length,UseADX,UseADXR,0,iBarShift(Symbol(),TF2,Time[i]));
 adx_dmi3=iCustom(Symbol(),TF3,ind_name,MA_Length,DMI_Length,ADX_Length,ADXR_Length,UseADX,UseADXR,0,iBarShift(Symbol(),TF3,Time[i]));

if(adx_dmi1>=buy_level && adx_dmi2>=buy_level && adx_dmi3>=buy_level) up_histog[i]=1;
if(adx_dmi1<=sell_level && adx_dmi2<=sell_level && adx_dmi3<=sell_level) down_histog[i]=1;
 }




   

   return(rates_total);
  }
  


