Нужна помощь по идикатору

 

Индикатор напрочь вешает терминал. Мог бы кто нибудь его подправить?

//+------------------------------------------------------------------+
//|                                                   2ZZ+Signal.mq4 |
//|                          Copyright © 2008, HomeSoft-Tartan Corp. |
//|                                              http://fxexperts.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, HomeSoft-Tartan Corp."
#property link      "http://fxexperts.ru"

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 IndianRed
#property indicator_color2 LightSlateGray
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_color5 Green
#property indicator_color6 Red

//---- indicator parameters
extern int    SnakeRange   = 3; 
extern int    FilterPeriod = 21; 
extern double MartFiltr    = 2.0;
extern int    PriceConst   = 6;
extern int LDepth=20;
extern int BDepth=30;
extern int Deviation=5;
extern int Backstep=3;
extern int Alerts=0;
extern int kb=1;
extern int nBars=500;

double BZZBuff[],LZZBuff[],StartBuff[],StopBuff[],UpBuff[],DnBuff[],ssrone,ssrnul,bzz,lzz,ibzz,ilzz,bbzz,llzz,zz,zzold,sd,zzb,lzold;
int shift,zzbar,i,fs,fb,pr,k,ns,nb,bbar;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,BZZBuff);
   SetIndexBuffer(1,LZZBuff);
   SetIndexBuffer(2,StartBuff);
   SetIndexBuffer(3,StopBuff);  
   SetIndexBuffer(4,UpBuff); 
   SetIndexBuffer(5,DnBuff);   
    
   SetIndexStyle(0,DRAW_SECTION,STYLE_DOT,1,IndianRed);
   SetIndexStyle(1,DRAW_SECTION,STYLE_DOT,0,LightSlateGray);   
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID,1,Lime);
   SetIndexStyle(3, DRAW_LINE, STYLE_SOLID,1,Red);
   SetIndexStyle(4,DRAW_ARROW,EMPTY,1);
   SetIndexArrow(4,241); 
   SetIndexStyle(5,DRAW_ARROW,EMPTY,1);
   SetIndexArrow(5,242);
   
   SetIndexEmptyValue(0,0.0);  
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(2,0.0);  
   SetIndexEmptyValue(3,0.0); 
   SetIndexEmptyValue(4,0.0);
   SetIndexEmptyValue(5,0.0);
   
if (Period()==5) sd=1;  
if (Period()==15) sd=3;  
if (Period()==30) sd=5;   
if (Period()==60) sd=10;
if (Period()==240) sd=15;  
if (Period()==1440) sd=20;
if (Period()>1440) sd=25;
     
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   Comment("");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----

   if (Period()<5) {Comment("\n","  Работать можно на ТФ=M5 и выше. Смените ТФ!");return(0);}

  for (shift=nBars;shift>=0;shift--)
   {   
   if (bzz!=0 && lzz!=0 && bzz!=zzold && lzz!=zzold && bzz==lzz) zzold=bzz;
   
       bzz=iCustom(NULL,0,"ZZSA",BDepth,Deviation,Backstep,Alerts,nBars,0,shift+1);
       bbzz=iCustom(NULL,0,"ZZSA",BDepth,Deviation,Backstep,Alerts,nBars,0,shift);  
       BZZBuff[shift]=bbzz; 
   if (lzz!=0 && lzold!=lzz) lzold=lzz; 
       lzz=iCustom(NULL,0,"ZZS",LDepth,Deviation,Backstep,nBars,0,shift+1);
       llzz=iCustom(NULL,0,"ZZS",LDepth,Deviation,Backstep,nBars,0,shift);
       LZZBuff[shift]=llzz;
         
       ssrone=iCustom(NULL,0,"SSRC",SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,shift+1);
       ssrnul=iCustom(NULL,0,"SSRC",SnakeRange,FilterPeriod,MartFiltr,PriceConst,0,shift);   
       
  for (i=1;i<nBars;i++)
   {
       zzb=iCustom(NULL,0,"ZZSA",BDepth,Deviation,Backstep,Alerts,nBars,0,i);
   if (zzb!=0) {bbar=i;break;}         
   }
   if (bzz!=0 && lzz!=0) k=0;     
      
   if (k==0) 
   {   k=1; 
   if (bzz!=zzold && zzold>bzz) {fb=1;fs=0;nb=0;zzbar=shift+1;}
   if (bzz!=zzold && zzold<bzz) {fs=1;fb=0;ns=0;zzbar=shift+1;}
   }
   
   if (fs==1 && ssrone>ssrnul && ssrone>0 && ns==0 && bbar>=kb && Close[shift]<=zzold-3*sd*Point && Close[shift]<Open[shift])  
   {    
        ns=1;DnBuff[shift]=High[shift]+2*sd*Point; if (DnBuff[shift+1]!=0) DnBuff[shift+1]=0;
   }
   
   if (fb==1 && ssrone<ssrnul && ssrone<0 && nb==0 && bbar>=kb && Close[shift]>=zzold+3*sd*Point && Close[shift]>Open[shift]) 
   { 
        nb=1;UpBuff[shift]=Low[shift]-2*sd*Point; if (UpBuff[shift+1]!=0) UpBuff[shift+1]=0;
   }

   if (fb==1 && k==1 && lzold==zzold)
   {   
  for (i=zzbar;i>=zzbar-10;i--) 
   {   
   if (i>3) {StartBuff[i+1]=zzold+3*sd*Point;StopBuff[i+1]=zzold-sd*Point;}
   } 
       Comment("\n"," Возможна покупка по сигналу при цене от ",zzb+3*sd*Point," после закрытия бара");
       StopBuff[i]=0;StartBuff[i]=0; 
   }  
        
   if (fs==1 && k==1 && lzold==zzold)
   {
  for (i=zzbar;i>=zzbar-10;i--) 
   {
   if (i>3) {StartBuff[i+1]=zzold-3*sd*Point;StopBuff[i+1]=zzold+sd*Point;}//zzold-zzb
   }
       Comment("\n"," Возможна продажа по сигналу при цене от ",zzb-3*sd*Point," посде закрытия бара"); 
       StopBuff[i]=0;StartBuff[i]=0;   
   }
   
  for (i=zzbar+1;i<zzbar+nBars;i++) {StartBuff[i]=0;StopBuff[i]=0;} //????
   
   if ((fb==1 && Ask>zzold+3*sd*Point && ssrone<=ssrnul && ssrnul>0) || (fs==1 && Bid<zzold-3*sd*Point && ssrone>=ssrnul && ssrnul<0))
   {
       Comment("\n","  Чётких сигналов нет!  Но!!!",
               "\n","  Продажа возможна=",fs,"  Покупка возможна=",fb);StopBuff[i]=0;StartBuff[i]=0;
   }            
   }           
   //----
   return(0);
   }
//+------------------------------------------------------------------+
 

А чем не нравится оригинальный индикатор?

 
Какой еще оригинальный?
 
A1ex:
Какой еще оригинальный?
Файлы: