Custom Indicator Not Refreshing

 
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#define  SH_BUY   1
#define  SH_SELL  -1
//---- Parâmetros de entrada
extern bool SoundON=false;
extern int     AllBars=0;//Para quantos compassos contar. 0 - para todos.
extern int     Otstup=30;//Indent.
extern double  Per=9;//Período.
//----
int            SH,NB,i,UD;
double         R,SHMax,SHMin;
double         BufD[];
double         BufU[];
int flagval1=0;
int flagval2=0;
//+------------------------------------------------------------------+
//| Função de inicialização |                                        |
//+------------------------------------------------------------------+
int init()
  {
 
  
   //Em NB, escreva o número de barras para as quais o indicador é calculado
   if (Bars<AllBars+Per || AllBars==0) NB=Bars-Per; else NB=AllBars;
   IndicatorBuffers(2);
   IndicatorShortName("SHI_SilverTrendSig");
   SetIndexStyle(0,DRAW_ARROW,0,1);
   SetIndexStyle(1,DRAW_ARROW,0,1);
   SetIndexArrow(0,159);
   SetIndexArrow(1,159);
   SetIndexBuffer(0,BufU);
   SetIndexBuffer(1,BufD);
   SetIndexDrawBegin(0,Bars-NB);// O indicador será exibido apenas para barras NB
   SetIndexDrawBegin(1,Bars-NB);
   ArrayInitialize(BufD,0.0);//Preencha os dois buffers com zeros. Caso contrário, haverá lixo ao alterar o período.
   ArrayInitialize(BufU,0.0);
   return(0);
  }
//+------------------------------------------------------------------+
//| Função de desinicialização                                          |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Indicador Sobsna                                                    |
//+------------------------------------------------------------------+
int start()
  {
  
   int CB=IndicatorCounted();
  /* Aqui está o mesmo recurso de otimização. 
  Uma função introduzida na linguagem que retorna o número de
   barras contadas, e de forma muito inteligente. 
   Na primeira chamada do indicador é 0, está tudo claro, nada
   foi contado ainda, e então ele dá o número de barras contadas menos um. 
   Essa. se houver 100 barras no total,
   então uma função retornará 99. 
   Eu entrei neste código, acima determinei NB - o número de barras a serem
   calculadas. 
   Em princípio, este parâmetro pode ser descartado, mas para aqueles que estão no tanque (I80286), você pode
   e sair. 
   Portanto, aqui na primeira chamada o NB permanece o mesmo, e nas chamadas subsequentes locais
   para a última barra, ou seja, 1 ou 2, bem, ou quanto falta contar ** /
   
   if (CB <0) return (-1); else if (NB> Bars-CB) NB = Bars-CB;
   para (SH = 1; SH <NB; SH ​​++) // Digitalize o gráfico de 1 a NB
     {
      para (R = 0, i = SH; i <SH + 10; i ++) {R + = (10 + SH-i) * (Alto [i] -Baixo [i]);} R / = 55;
// ----
      SHMax = Alto [Mais alto (NULL, 0, MODE_HIGH, Per, SH)];
      SHMin = Baixo [Mais baixo (NULL, 0, MODE_LOW, Per, SH)];
      if (Fechar [SH] <SHMin + (SHMax-SHMin) * Otstup / 100 && UD! = SH_SELL)
        {
          // Exibir um alerta
         if (SH == 1 && flagval1 == 0)
           {
            flagval1 = 1;
            flagval2 = 0;
            if (SoundON) Alert ("sinal de COMPRA em Ask =", Ask, "\ n Bid =", Bid, "\ n Time =", TimeToStr (CurTime (), TIME_DATE), "", TimeHour (CurTime ()) , ":", TimeMinute (CurTime ()), "\ n Symbol =", Symbol (), "Period =", Period ());
           }
         BufU [SH] = Baixo [SH] -R * 0,5; UD = SH_SELL;
        }
      if (Fechar [SH]> SHMax- (SHMax-SHMin) * Otstup / 100 && UD! = SH_BUY)
        {
          // Exibir um alerta
         if (SH == 1 && flagval2 == 0)
           {
            flagval2 = 1;
            flagval1 = 0;
            if (SoundON) Alert ("sinal de VENDA em Ask =", Ask, "\ n Bid =", Bid, "\ n Date =", TimeToStr (CurTime (), TIME_DATE), "", TimeHour (CurTime ()) , ":", TimeMinute (CurTime ()), "\ n Symbol =", Symbol (), "Period =", Period ());
           }
         BufD [SH] = Alto [SH] + R * 0,5; UD = SH_BUY;
        }
     }
   return (0);
  }
// + ----------------------------------------------- ------------------- +
 
Patrick Carvalho:
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  2. No question asked, no reply needed.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

  3. Don't post code that will not compile. Not valid tokens: para, Alto[], Baixo[], Mais alto, etc.
 
Patrick Carvalho:
//----
#property indicator_chart_window

......................

......................

   return (0);
  }

// + ----------------------------------------------- ------------------- +

Though not clear enough what you trying to ask - any way you have to know,all silver Trend,shi silver trend,lukas,gold minor,forex off trend indicators are same and renamed including repaints