custum indicator slows down the MT4 and the pc with iMaOnArray function

 


Hi everyone .. I created this indicator but I don't understand why the whole Metatrader slows down .. This only happens with the iMaOnArray function ... Can anyone help me ?? Thanks


                
                Ciao a tutti .. Ho creato questo indicatore ma non capisco perché l'intero Metatrader rallenta .. Questo succede solo con la funzione iMaOnArray ... Qualcuno può aiutarmi ?? 
                Grazie 
 
#property link ""
#property indicatore_separate_window
#property pointer_buffers 2

#property indicatore_colore1 Rosso
#property pointer_width1 2

#property indicatore_colore2 Blu
#property pointer_width2 2



// variabili esportate


// variabili locali
double PipValue = 1;
stringa LF = "\ n"; // usalo in blocchi personalizzati o di utilità in cui hai bisogno di feed di riga
int ObjCount = 0; // conta di tutti gli oggetti creati sul grafico, consente la creazione di oggetti con nomi univoci
int current = 0; // la variabile punta alla barra corrente

double Buffer2 [];
double Buffer4 [];


// + ----------------------------------------------- ------------------- +
// | Funzione di inizializzazione dell'indicatore personalizzato |
// + ----------------------------------------------- ------------------- +
int init ()
{
    if (false) ObjectsDeleteAll (); // cancella il grafico
    IndicatorShortName ("Forza TBC direzionale");
    IndicatorDigits (cifre + 1);
    IndicatorBuffers (2);
    
    SetIndexBuffer (0, Buffer2);
    SetIndexStyle (0, DRAW_LINE, STYLE_SOLID);
    
    SetIndexBuffer (1, Buffer4);
    SetIndexStyle (1, DRAW_LINE, STYLE_SOLID);
    
    
    ritorno (0);
}

// + ----------------------------------------------- ------------------- +
// | Funzione di deinizializzazione dell'indicatore personalizzato |
// + ----------------------------------------------- ------------------- +
int deinit ()
{
    if (false) ObjectsDeleteAll ();
    
    
    ritorno (0);
}

// + ----------------------------------------------- ------------------- +
// | Funzione di avvio dell'indicatore personalizzato |
// + ----------------------------------------------- ------------------- +
int start ()
{
    OnEveryTick1 ();
    
    ritorno (0);
}

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

void OnEveryTick1 ()
{
    
    int i;
    int counted_bars = IndicatorCounted ();
    if (counted_bars <0) restituisce;
    if (counted_bars> 0) counted_bars--;
    i = Bar - counted_bars;
    // ciclo di calcolo principale
    while (i> = 0)
    {
        corrente = i;
        ChartLine2 ();
        ChartLine4 ();
        
        io--;
    }
}

void ChartLine2 ()
{
    Buffer2 [current] = iMomentum (NULL, PERIOD_CURRENT, 18, PRICE_CLOSE, corrente);
    
}

void ChartLine4 ()
{
   Buffer4 [current] = iMAOnArray (Buffer2, 0, 17, 0, MODE_EMA, corrente);
    
}
void ChartLine3 ()
   {
   // Buffer4 [current] = iMA (NULL, PERIOD_CURRENT, 17.0, MODE_EMA, PRICE_CLOSE, corrente); 
  Buffer4 [current] = iMAOnArray (Buffer2, 0, 17, 0, MODE_EMA, corrente);
   }