How can we make this indicator show arrows on candle open . not after its closed

 

Hey guys . as you can see this indicator has the option to Alert on current bar , but it doesnt have the option to show arrow on candle open or when the alert comes . 

how can we make this indicator show arrows when it alerts on current bar ? thanks a lot 


#property indicator_chart_window
#property indicator_buffers 2
#property indicator_width1 1
#property indicator_color1 Lime
#property indicator_width2 1
#property indicator_color2 Red
extern int qual=4;
extern int len=11;
extern int Distance = 1;
extern int Countbars=10000;
input bool               alertsOn         = true;                      // Alerts true/false?
input bool               alertsOnCurrent  = false;                     // Alerts open bar true/false?
input bool               alertsMessage    = true;                      // Alerts pop-up message true/false?
input bool               alertsSound      = false;                     // Alerts sound true/false?
input bool               alertsNotify     = false;                     // Alerts push notification true/false?
input bool               alertsEmail      = false;                     // Alerts email true/false?
input string             soundFile        = "alert2.wav";              // Sound file to use
double Up[];
double Dn[],trend[];
double point;
double bs=0;
double index=0;
double bindex=0;
double sindex=0;
double length=0;
double ret=0;

int init() {
if(Digits==3 || Digits==5) {
point=10*Point;
}
   else{                     
        point=Point;

}

   IndicatorBuffers(3);
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexBuffer(0, Up);
   SetIndexArrow(0,233);
      SetIndexStyle(1, DRAW_ARROW);

      SetIndexBuffer(1, Dn);
   SetIndexArrow(1,234);
   SetIndexBuffer(2,trend);

   

   return (0);
}

int deinit() {
   return (0);
}

int start() {
bool TurnedUp = false;
bool TurnedDown = false;
 int i,limit,limit2;
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0) 
   return(-1);
 
   limit=Countbars-counted_bars;
   if (i> limit2) 
   limit2= i;    
   if (limit2 <Countbars-1)
   limit =Countbars- 1; 
  
  for( i=limit; i>=0; i--) {
  
  if (Close[i]>Close[i+4]){ 
 
bindex=bindex+1;

}
 
if(Close[i]<Close[i+4]){ 

sindex=sindex+1;
}

ret=0;
index=0;
trend[i] = 0;


if ((bindex>qual) && (Close[i]<Open[i])&& (High[i]>=High[iHighest(Symbol(),0,MODE_HIGH,len,i+1)])) { 
index=1;
bindex=0;
ret=-1;
trend[i] =-1;
}
if ((sindex>qual) && (Close[i]>Open[i])&& (Low[i]<= Low[iLowest(Symbol(),0,MODE_LOW,len,i+1)])) {
index=-1;
sindex=0;
ret=1;
trend[i] = 1;
}

Up[i] = EMPTY_VALUE;
Dn[i] = EMPTY_VALUE;
if (ret==1 && i!=0){
Up[i]=Low[i]-Distance*point;
}

if (ret==-1 && i!=0){ 
Dn[i]=High[i]+Distance*point;

}

}
   
if (i> limit2) limit2= i;

if (alertsOn)
   {
      int whichBar = 1; if (alertsOnCurrent) whichBar = 0;
      if (trend[whichBar] != trend[whichBar+1])
      if (trend[whichBar] == 1)
            doAlert("down");
      else  doAlert("up");       
   }    
return (0);
}

//
//
//

string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int    iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};

string timeFrameToString(int tf)
{
   for (int i=ArraySize(iTfTable)-1; i>=0; i--) 
         if (tf==iTfTable[i]) return(sTfTable[i]);
                              return("");
}



//------------------------------------------------------------------
//                                                                  
//------------------------------------------------------------------
//
//
//
//
//

void doAlert(string doWhat)
{
   static string   previousAlert="nothing";
   static datetime previousTime;
   string message;
   
      if (previousAlert != doWhat || previousTime != Time[0]) {
          previousAlert  = doWhat;
          previousTime   = Time[0];

          //
          //
          //

          message = timeFrameToString(_Period)+" "+_Symbol+" at "+TimeToStr(TimeLocal(),TIME_SECONDS)+" Forex Trend Champion "+doWhat;
             if (alertsMessage) Alert(message);
             if (alertsNotify)  SendNotification(message);
             if (alertsEmail)   SendMail(_Symbol+" Forex Trend Champion ",message);
             if (alertsSound)   PlaySound("alert2.wav");
      }
}
 
8ball.niavash ebpour: how can we make this indicator show arrows when it alerts on current bar ? 
  1. “We” are not going to make anything, you are.

    You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
              No free help (2017)

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2018)

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
              No free help (2017)

  2. Add one or two arrow buffer(s). Where you call doAlert, set the arrow.