Need help to improve my indicator - page 2

 

I have revised my indicator, but the MT4 platform crashes whenever I run the indicator. Is there anyone who can find the bug in the code below? In advance I appreciate your kind attention.

//+------------------------------------------------------------------+
//|                                                      S_Rev.mq4 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "mjstock78@gmail.com"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property description ""
#property version   "1.0"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_width1 0
#property indicator_width2 0
#property indicator_color1 clrLimeGreen
#property indicator_color2 clrOrangeRed

double high1=0,low1=0,high2=0,low2=0,high3=0,low3=0;
double high,low;
double buffBuy[];
double buffSell[];
string Direction;
int cb = 0;
int bar ;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   int draw = 0;
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,110);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,110);
   SetIndexEmptyValue(0,0.0);
   SetIndexLabel(0,"Buy");
   SetIndexLabel(1,"Sell");
   SetIndexDrawBegin(0,draw);
   SetIndexDrawBegin(1,draw);
   SetIndexBuffer(0,buffBuy);
   SetIndexBuffer(1,buffSell);
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectsDeleteAll(0,OBJ_ARROW);
   return(0);
  }
//+------------------------------------------------------------------+
int start()
  {
   int IndicatorCounted = cb;
   if (bar == Time[0]) return(0);
   int x;
   if(Bars<=100) return(0);
   if (cb<0) return(-1);
   if (cb>0) cb--;
   x=Bars-cb;
   
   low1=iClose(NULL,0,x);   //assuming fisrt candle to be bear candle
   
   high1=iOpen(NULL,0,x);   //assuming fisrt candle to be bear candle
   if (low1>iOpen(NULL,0,x))  //then first candle is a bull candle
       {high1=iClose(NULL,0,x);   
        low1=iOpen(NULL,0,x);}
       
   
   
   for(int i=x-1; i<x; i--)
   {
    if (iClose(NULL,0,i)<low1 && low2==0 && low3==0)
           {low2=iClose(NULL,0,i); 
            high2=low1;
            continue;
            }

    if (iClose(NULL,0,i)>high1 && high2==0 && high3==0)
           {high2=iClose(NULL,0,i); 
            low2=high1;
            continue;
            }

    if (iClose(NULL,0,i)<low2 && iClose(NULL,0,i)<low1 && low2!=0 && low3==0)
           {low3=iClose(NULL,0,i); 
            high3=low2;
            continue;
            }

    if (iClose(NULL,0,i)>high2 && iClose(NULL,0,i)>high1 && high2!=0 && high3==0)
           {high3=iClose(NULL,0,i); 
            low3=high2;
            continue;
            } 
            
    
    if (high3>MathMax(high1,high2))//high3>high1 && high3>high2)
        high=high3;
       else 
          high=MathMax(high1,high2);   
        
    if (low3<MathMin(low1,low2))
        low=low3;
       else 
        low=MathMin(low1,low2);                                  
     
    
    if (iClose(NULL,0,i)<low && low1!=0 && low2!=0 && low3!=0)        
            {buffSell[i] = High[i]+200*Point;
             Direction= "Sell";
             high1=high2;
             low1=low2;
             high2=high3;
             low2=low3;
             high3=low3;
             low3=iClose(NULL,0,i);}
             
                              
    if (iClose(NULL,0,i)>high && high1!=0 && high2!=0 && high3!=0)        
            {buffBuy[i] = Low[i]-200*Point;
             Direction= "Buy";
             high1=high2;
             low1=low2;
             high2=high3;
             low2=low3;
             low3=high3;
             high3=iClose(NULL,0,i);}        
    
    
//    else 
//        {
//         j++;
         if (Direction=="Sell")
              buffSell[i] = High[i]+200*Point;
         if (Direction=="Buy")
              buffBuy[i] = Low[i]-200*Point;
//        }           
         
   } 
   
   return(0);  
   }
//+------------------------------------------------------------------+