今現在、次の足に代わる直前に矢印が出てアラートが鳴るのですが条件を満たした時点で矢印+アラートを表示するにはどこをどのように変更したら良いのですか?
宜しくおねがいします

int    i;
double high, low, smin, smax;
double val1[];
double val2[];
double Bor_BufferH[];
double Bor_BufferL[];
double Range;
bool   uptrend, old;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
    SetIndexStyle(0, DRAW_ARROW, EMPTY,2);
    SetIndexArrow(0, 233);       
    SetIndexBuffer(0, val1);     
    SetIndexDrawBegin(0, 2*POI);
    //
    SetIndexStyle(1, DRAW_ARROW, EMPTY,2);
    SetIndexArrow(1, 234);       
    SetIndexBuffer(1, val2);      
    SetIndexDrawBegin(1, 2*POI);
    //
    SetIndexStyle(2, DRAW_NONE);
    SetIndexBuffer(2, Bor_BufferH);
    SetIndexLabel(2, "High");
    SetIndexDrawBegin(2, 2*POI);
    //
    SetIndexStyle(3, DRAW_NONE);
    SetIndexBuffer(3, Bor_BufferL);
    SetIndexLabel(3, "Low");
    SetIndexDrawBegin(3, 2*POI);
    //
    val1[i] = low- Range*0.5;
    val2[i] = high + Range*0.5;
    //----
    return(0);
}

//+------------------------------------------------------------------+
//| Calculation of SilverTrend lines                                 | 
//+------------------------------------------------------------------+
int start()
{   
    int counted_bars = IndicatorCounted();

    if(counted_bars > 0) counted_bars--;
    //----
    if(Bars <= POI + 0)        return(0);
    //---- initial zero
    uptrend       =false;
    old           =false;
    GlobalVariableSet("goSELL", 0); 
    GlobalVariableSet("goBUY", 0); 
    string sAlertMsg;

    static datetime prevtime=0;

    if(prevtime == Time[0]) {
        return(0);
    }

    prevtime = Time[0];

    //----
    for(i = CountBars - POI; i >= 0; i--)
    { 
        high = High[iHighest(Symbol(),0,MODE_HIGH,POI,i)]; 
        low = Low[iLowest(Symbol(),0,MODE_LOW,POI,i)]; 
        smax = high - (high - low)* Borra / 100; 
        smin = low + (high - low)* Borra / 100;  
        val1[i] = 0;  
        val2[i] = 0;

        if(Close[i] < smin && i!=0 ){
            uptrend = false;
        }
        if(Close[i] > smax && i!=0 ){
            uptrend = true;       
        }       

        if(uptrend != old && uptrend == false){
            val2[i] = high;

            if(i == 0){
                GlobalVariableSet("goBUY",1);
            }
        }

        if(uptrend != old && uptrend == true ){
            val1[i] = low;

            if(i == 0){
                GlobalVariableSet("goSELL",1);
            }
        }

        old=uptrend;
        Bor_BufferH[i]=high - (high - low)*Borra / 100;
        Bor_BufferL[i]=low +  (high - low)*Borra / 100;

        //Alerts an Email    
        if(val1[1] > 0 && i==0){
            sAlertMsg=" Buy - "+Symbol()+" "+TF2Str(Period())+": Signal Up";
            if (Alert_Popup) Alert(sAlertMsg);
            if (AlertsSound) PlaySound(Symbol()+".wav");      
            if (Alert_Email) SendMail( sAlertMsg, "MT4 Alert!\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS )+"\n"+sAlertMsg);
        }

        if(val2[1] > 0 && i==0){
            sAlertMsg="Sell - "+Symbol()+" "+TF2Str(Period())+": Signal Down";
            if (Alert_Popup) Alert(sAlertMsg);
            if (AlertsSound) PlaySound(Symbol()+".wav");     
            if (Alert_Email) SendMail( sAlertMsg, "MT4 Alert!\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS )+"\n"+sAlertMsg);
        }
        //
    }
    return(0);
}
//-----------------------------------------------------------------------------
// function: TF2Str()
// Description: Convert time-frame to a string
//-----------------------------------------------------------------------------
string TF2Str(int iPeriod) {
    switch(iPeriod) {
        case PERIOD_M1: return("M1");
        case PERIOD_M5: return("M5");
        case PERIOD_M15: return("M15");
        case PERIOD_M30: return("M30");
        case PERIOD_H1: return("H1");
        case PERIOD_H4: return("H4");
        case PERIOD_D1: return("D1");
        case PERIOD_W1: return("W1");
        case PERIOD_MN1: return("MN1");
        default: return("M"+iPeriod);
    }
}
//+------------------------------------------------------------------+