//+------------------------------------------------------------------+ //| iglevels.mq4 | //| Frostow | //| https://www.mql5.com/en/users/frostow | //+------------------------------------------------------------------+ #property indicator_chart_window #property indicator_buffers 2 s#property indicator_plots 2 #property indicator_color1 clrGreen #property indicator_type1 DRAW_LINE #property indicator_width1 2 #property indicator_color2 clrBlue #property indicator_type2 DRAW_LINE #property indicator_width2 2 input int TDLevel=1;//Level of points input int NumberOfDots=3;//Number of points input double Delta=0.0001; double TDLU[],TDLD[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { ChartRedraw(0); SetIndexBuffer(0,TDLU); SetIndexBuffer(1,TDLD); SetIndexEmptyValue(0,0.0); SetIndexEmptyValue(1,0.0); SetIndexLabel(0,"ГУ U"); SetIndexLabel(1,"ГУ D"); ObjectCreate(0,"U horizontal level",OBJ_HLINE,0,iTime(NULL,0,0),0); ObjectCreate(0,"D horizontal level",OBJ_HLINE,0,iTime(NULL,0,0),0); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double GetLevelPrice(int ud,int n,double delta,int level) { double TDU[]; double TDD[]; ArrayResize(TDU,n,n); ArrayResize(TDD,n,n); ArrayInitialize(TDU,0); ArrayInitialize(TDD,0); for(int Buffer=0; Buffer<2; Buffer++) { int N=0; int Fails=0; bool r=false; for(int i=0; r==false; i++) { double d=iCustom(NULL,0,"itddots",level,Buffer,i); if(d>0) { if(N>0) { if(Buffer==0) double cp=TDU[N-1]; else cp=TDD[N-1]; if(MathAbs(d-cp)<=delta) { if(Buffer == 0) TDU[N] = d; else TDD[N]=d; N++; } else { Fails++; } } else { if(Buffer == 0) TDU[N] = d; else TDD[N]=d; N++; } } if(Fails>2 || N>n) r=true; } } double ATDU = 0; double ATDD = 0; N=0; for(i=0; i