Help me find the draw arrow in this indcater

 

This indicater help me draw an arrow in the chart. I wan add a alert when it draw a arrow. but i can't find where is the draw arrow order and where i should add the alert order. Thank a lot

double     ExtBuffer0[]; 
double     ExtBuffer1[]; 
double     ExtBuffer2[];

extern int fastma = 5;
extern int slowma = 34; 
extern int isshowsignaltype1 = 1; 
extern int isshowsignaltype2 = 1; 
extern int divergencebars = 4; 
extern int mode = 0; 
int normalizeperiod = 200;
string indicatorname;
double BuyBuffer[];     
double SellBuffer[];    
double BufferSignalType[]; 
int flagdivergence;
int foundpik; 
double pikprice1, pikprice2; int foundpikprice1,foundpikprice2; 
int lastipikprice = 0;


#define LINEAO       "linebetweenpik"
#define LINEPRICE    "linebetweenpprice"

double getpikprice( int howbars, int shift, double dir, int flaglastbar=0 ){
  
  
  

  
  
  int lastminmaxx = 5;
  int i = -howbars;
  if( flaglastbar == 1 )i=0; 
  if( i+shift < 0 )i=0;
  
  double lastminmax = 0;
  lastipikprice = 0;
  for( ; i < howbars; i ++ ){
    
    bool condition;
    int nexti =  i+iif(shift==0 || flaglastbar == 1, 0, -1)+shift;
    
    if( dir > 0 ){ 
     
      condition = High[i+shift] > lastminmaxx ;
    }else{
     
      condition = ((Low[i+shift] < lastminmax) || (lastminmax == 0));
    }
  
    if( condition ){
      double ret  = iif(dir>0, High[i+shift], Low[i+shift] );
     
      lastipikprice = i+shift;
      lastminmax = ret;
      
    }
  }
  return(lastminmax);
}

int init()
  {
   //---- drawing settings
   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   IndicatorDigits(Digits+1);
   SetIndexDrawBegin(0,slowma);
   SetIndexDrawBegin(1,slowma);
   SetIndexDrawBegin(2,slowma);
//---- 3 indicator buffers mapping
   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);
//---- name for DataWindow and indicator subwindow label
   if( mode == 0 )indicatorname = "AODivergence";
   if( mode == 1 )indicatorname = "AODivergenceNormilized";
   if( mode == 2 )indicatorname = "RSIDivergence";
 
   IndicatorShortName(indicatorname);
   
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);
//---- initialization done


   SetIndexStyle( 3, DRAW_ARROW, EMPTY );
   SetIndexArrow( 3, 233 );
   SetIndexStyle( 4, DRAW_ARROW, EMPTY );
   SetIndexArrow( 4, 234 );

   //ArrayResize( BuyBuffer, 1 );
   //ArrayResize( SellBuffer, 1 );
 
 
   SetIndexBuffer( 3, BuyBuffer   );
   SetIndexEmptyValue(3,0);
   SetIndexBuffer( 4, SellBuffer   );
   SetIndexEmptyValue(4,0);
   //ArrayInitialize(BuyBuffer, 0 ); 
   //ArrayInitialize(SellBuffer, 0 );
 
   int drawtype = DRAW_ARROW ;
   SetIndexBuffer(5,BufferSignalType );
   SetIndexStyle( 5, DRAW_NONE);
   SetIndexEmptyValue(5,0);
   
 


   return(0);
  }



int delline( string prefiks, string name ){

       if(StringSubstr(name, 0, StringLen(prefiks)  ) != prefiks) return(0);
           
       ObjectDelete(name);   

}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit(){   

for(int i = ObjectsTotal() - 1; i >= 0; i--)
     {
       string label = ObjectName(i);
       delline(LINEAO, label); 
       delline(LINEPRICE, label); 
     }
   return(0);


return(0);  }
 


double CalcAO( int limit ){
    for(int i=limit; i>=1; i--){
      if( mode == 0) ExtBuffer0[i]=iMA(NULL,0,fastma,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,slowma,0,MODE_SMA,PRICE_MEDIAN,i);
      if( mode == 1){
        ExtBuffer0[i]=iMA(NULL,0,fastma,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,slowma,0,MODE_SMA,PRICE_MEDIAN,i);
        ExtBuffer1[i]= ExtBuffer0[i];
        double fndmax = ExtBuffer1[i+1]; double fndmin = fndmax;
        for(int j = i+1; j<i+1+normalizeperiod; j++ ){
          fndmax= MathMax(fndmax, ExtBuffer1[j]);
          fndmin = MathMin(fndmin, ExtBuffer1[j]);
        }
       double diff = fndmax-fndmin;
        if(diff == 0 )diff = 1;
        //if( limit > normalizeperiod ){
         // Print("for i = ", i,  " fnd min is ", fndmin, "fndmax is ", fndmax );
       
          ExtBuffer0[i] = (ExtBuffer1[i]-fndmin)/diff-0.5 ;  ///(fndmax - fndmin);
        //}
      } 
      
      if( mode == 2) ExtBuffer0[i]=iRSI(NULL,0,slowma,PRICE_CLOSE,i)-50;
     
    }
 //---- dispatch values between 2 buffers
   bool up=true;  double current, prev;
   for(i=limit-1; i>=0; i--){
      current=ExtBuffer0[i];
      prev=ExtBuffer0[i+1];
      if(current>prev) up=true;
      if(current<prev) up=false;
      if(!up){
         ExtBuffer2[i]=current;
         ExtBuffer1[i]=0.0;
      }else{
         ExtBuffer1[i]=current;
         ExtBuffer2[i]=0.0;
      }
     
   }
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

bool isitpik( int i ){
  if( ExtBuffer0[i]>0 && ExtBuffer0[i]>ExtBuffer0[i+1] && ExtBuffer0[i]>ExtBuffer0[i-1])return(true);
  if( ExtBuffer0[i]<0 && ExtBuffer0[i]<ExtBuffer0[i+1] && ExtBuffer0[i]<ExtBuffer0[i-1])return(true);
}

bool findpik(int curaoi ){
 
  double curao = ExtBuffer0[curaoi+1]; //!!!!
  //double prevao = ExtBuffer0[curaoi+1];
  //double prevprevao = ExtBuffer0[curaoi+2];
  bool flag = false; 
  //if( curao > 0 && curao < prevao && prevao > prevprevao )flag = true;
  //if( curao < 0 && curao > prevao && prevao < prevprevao )flag = true;
  //if( !flag )return(false);
  if( !isitpik(curaoi+1))return(false);   
  foundpik = 0; 
  
     
  for( int i = 2+curaoi; i < Bars; i++ ){
    
    if(  sign ( ExtBuffer0[ i ] ) != sign( ExtBuffer0[ i-1 ] ))return( false ); //・・・0
    double cur =  ExtBuffer0[ i ]; 
    double prevcur = ExtBuffer0[ i+1 ];
    pikprice1 = 0; pikprice2 = 0; foundpikprice1 = 0; foundpikprice2 = 0;
    if( cur*prevcur < 0){
      prevcur = 0;
    }
    if( cur < 0 )cur=-cur;
    if( prevcur < 0 )prevcur=-prevcur;
      
    
    double comp=curao;
    if(comp < 0) comp = -comp;
    if( isitpik(i) && cur>comp ){ 
      flagdivergence = 0;foundpikprice1 = 0; foundpikprice2 = 0;
      pikprice1 = getpikprice(divergencebars, curaoi, curao, 1 )*sign(curao); 
      foundpikprice1 = lastipikprice; //curaoi;
     
      pikprice2 = getpikprice(divergencebars, i, curao )*sign(curao);
     
      foundpikprice2 = lastipikprice; //foundpikprice2 = i ;
      if( pikprice2 < pikprice1 ){
       
        flagdivergence = 1; 
       
      }else{
      
      }
      foundpik = i;
      return (true );
    }
  } 
 
  return (false );
  
}

int drawline(){

 
  
}
bool ShowSignals(int i, bool itispik, bool flagdivergence  ){
  BuyBuffer[i] = 0; SellBuffer[i] = 0; BufferSignalType[i]=OP_NONE;
  
  int cmd = OP_BUY;

  if(!itispik)return( false );
  if(!flagdivergence && isshowsignaltype1 == 1 )return(false);
  if(i>Bars-100+slowma)return(false);
  if(ExtBuffer0[i]>0){
    cmd = OP_SELL;
  }
  if(cmd==OP_BUY){
    BuyBuffer[i]= ExtBuffer0[i];  
  
  }else{
    SellBuffer[i]= ExtBuffer0[i];  
  }
  BufferSignalType[i]=cmd;
  
}
int start(){
  int    counted_bars=IndicatorCounted();
  if(counted_bars<0) return(-1);
  
  if(counted_bars>0) counted_bars--;
  int limit=Bars-counted_bars-1;
  SetIndexDrawBegin(5, Bars );  
  
  //limit = 500;
  CalcAO(limit);
  int numwindow = WindowFind(indicatorname); 
  if( numwindow == -1 )numwindow = 0;
  for( int i = limit; i>0; i -- ){
     
     string addname = "_ao_";
     if( mode == 1 )addname = "_aonorm_";
     if( mode == 2 )addname =  "_rsi_" ;
     string objname = LINEAO+addname+Time[i];
     ObjectDelete(objname  );
     string objnameprice = LINEPRICE+Time[i];
     ObjectDelete(objnameprice  );
     bool isfoundpik = findpik(i); 
     if(  isfoundpik  ){
    
       ObjectCreate(objname, OBJ_TREND, numwindow, Time[foundpik], ExtBuffer0[foundpik], Time[i+1], ExtBuffer0[i+1]   );
       color linc = Blue;
       ObjectSet(objname   , OBJPROP_RAY, 0);
       ObjectSet(objname   , OBJPROP_WIDTH, 2);
       ObjectSet(objname   , OBJPROP_COLOR, linc);
       if( flagdivergence == 1 ){
         double drp2 = pikprice2*sign(pikprice2);
         double drp1 = pikprice1*sign(pikprice1);
         
         ObjectCreate(objnameprice, OBJ_TREND, 0, Time[foundpikprice2], drp2, Time[foundpikprice1], drp1   );
         ObjectSet(objnameprice   , OBJPROP_RAY, 0);
         ObjectSet(objnameprice   , OBJPROP_WIDTH, 2);
         ObjectSet(objnameprice   , OBJPROP_COLOR, linc);
       
       }
 
       //・・湜
     }else{
       //Print("淲 ・・ ");
     }
     ShowSignals(i, isfoundpik, iif( flagdivergence==1, true, false ) );
     //Print(ExtBuffer0[i],ExtBuffer1[i],ExtBuffer2[i],BuyBuffer );
  }
  
  return(0);
}
//+------------------------------------------------------------------+
int sShowSignals(int i ){
  BuyBuffer[i] = 0; SellBuffer[i] = 0; BufferSignalType[i]=OP_NONE;
 
  
  return( 0 );


  
  }

int sign( double v ) {if( v < 0 ) return( -1 );  return( 1 ); }
double iif( bool condition, double ifTrue, double ifFalse ){  if( condition ) return( ifTrue ); return( ifFalse );}
string iifStr( bool condition, string ifTrue, string ifFalse ) {  if( condition ) return( ifTrue );  return( ifFalse ); }
string SignalToStr(int sig ){
  if( sig == OP_BUYLIMIT ) return ("OP_BUYLIMIT" );
  if( sig == OP_SELLLIMIT ) return ("OP_SELLLIMIT" );
  if( sig == OP_BUY ) return ("OP_BUY" ); 
  if( sig == OP_BUYSTOP ) return ("OP_BUYSTOP" );
  if( sig == OP_SELL ) return ("OP_SELL" );
  if( sig == OP_SELLSTOP ) return ("OP_SELLSTOP" );
  if( sig == OP_NONE ) return ("OP_NONE" );
  if( sig == OP_CLOSEORDER ) return ("OP_CLOSEORDER" );

  return ( "undefined type if signal "+ sig  );

} 


  




int getoldertimeframe(int passedframe=0){
  int curper = Period();
  if(passedframe!=0)curper=passedframe;
  
  if( curper == PERIOD_M1 )return (PERIOD_M5);
  if( curper == PERIOD_M5)return (PERIOD_M15);
  if( curper == PERIOD_M15)return (PERIOD_M30);
  if( curper == PERIOD_M30)return (PERIOD_H1);
  if( curper == PERIOD_H1)return (PERIOD_H4);
  if( curper == PERIOD_H4)return (PERIOD_D1);
  if( curper == PERIOD_D1)return (PERIOD_W1);
  if( curper == PERIOD_W1)return (PERIOD_MN1);
  if( curper == PERIOD_MN1)return (0);
  return (0);
}

// ---- Money Management








double LotSize(double StopLossInPips, double RiskPercent, int desigion=1, double addsumtodepo = 0 ){ 
 int Leverage =  AccountLeverage(); 
 double PipValue = MarketInfo(Symbol(), MODE_TICKVALUE);
 double lotMM, FreeMargin;
 //Print("addsumtodepo is ", addsumtodepo );
 FreeMargin = AccountBalance( )+addsumtodepo  ; //AccountFreeMargin();
 lotMM = NormalizeDouble((FreeMargin*RiskPercent/100)/(StopLossInPips*PipValue),desigion);
 double minlot = 0.1;
 Print("ヨ褊・・渼=", PipValue, " ム粽碚蓖鐱 裝籵=", FreeMargin, " ミ頌・", RiskPercent, " ラ頌・ ・・", lotMM);
 if(desigion == 2) minlot = 0.01;
 
   if (lotMM < minlot ) lotMM = minlot ;//Lots;
   if  (lotMM > 100) lotMM = 100;
   return (lotMM);
} 
 

string PeriodToStr( int curper ){
  if( curper == PERIOD_M1 )return ("M1");
  if( curper == PERIOD_M5)return ("M5");
  if( curper == PERIOD_M15)return ("M15");
  if( curper == PERIOD_M30)return ("M30");
  if( curper == PERIOD_H1)return ("H1");
  if( curper == PERIOD_H4)return ("H4");
  if( curper == PERIOD_D1)return ("D1");
  if( curper == PERIOD_W1)return ("W1");
  if( curper == PERIOD_MN1)return ("MN1");
  return ("・鮏 淲 ⅰ蒟・・)    ");
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
  • www.mql5.com
Drawing Styles - Indicator Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: