Unable to court-circuit the "start" function

 

Hello, I am frecnh and my english is no perfect and it will be pleasant to ignore it.

I have a problem with the "start" function"; it is run at every tick, yes?

But in my EA algorythm, ther is a function wich is waiting for a new candle and I do not want resarting the sart function at every tick every time, so, this is an example of what I am saying:

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   string sym = Symbol();  // affecte le symbole du chart au string "sym"
   busy = false;           // EA pas encore occupé
   mess = "OK";            // jusqu'ici, tout va bien     
//----
   return(0);
  }

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   info (mess);         // print le contexte de l'EA
   if (busy == true) {
   return;
   }
   
   calcul ();
   while (New_Bar == false)   {
      mess = "attends un nouveau chandelier";
      detectbar ();
    }
    mess = "L\'EA a fini ce qu\'il avait à faire";
    while (true)  {
    Print ("enfermé dans la boucle!");  
    }      
   
//----
   return(0);
  }

//+------------------------------------------------------------------+
//| fonction détectant les nouveaux chandeliers                      |
//+------------------------------------------------------------------+
void detectbar()                                      // Funct. detecting ..
         {                                             // .. a new bar
         static datetime New_Time=0;                  // Time of the current bar
         New_Bar=false;                               // No new bar
         if(New_Time!=Time[0])                        // Compare time
           {
            New_Time=Time[0];                         // Now time is so
            New_Bar=true;                             // A new bar detected
           }
         }
//+------------------------------------------------------------------+
//| calcul des valeurs du tableau                                    |
//+------------------------------------------------------------------+
void  calcul ()   {
   busy = true;      // EA occupé
   mess = "dans la fonction calcul()";
  
   } 
  
  
//+------------------------------------------------------------------+
//| fonction affichant le contexte de l'EA                           |
//+------------------------------------------------------------------+
void  info (string text)  {
   if (busy == true) {
      Print ("L\'EA est occupé et voici le contexte: ",text);
      }  else  {
      Print ("L\'EA n\'est pas occupé mais voici le contxte: ", text);
      }
    }

 
emmett_brown:

Hello, I am frecnh and my english is no perfect and it will be pleasant to ignore it.

I have a problem with the "start" function"; it is run at every tick, yes?

But in my EA algorythm, ther is a function wich is waiting for a new candle and I do not want resarting the sart function at every tick every time, so, this is an example of what I am saying:


So, I use the busy variable to know if the "start" function must be execute or no but it seems to not work, could you help me anybody?
 
  1. Your code will not compile - newBar not defined
  2. detectbar is not called as the first thing in start()