Using an events to tigger the start() function

 
Hi All

Is it possible to use an event to trigger the start() function of an indicator? I am trying to set up an indicator that only paints on the bars shown in the window
i.e. A MA offset by -7. A normal indicator shows the future value and it is only at bar 0 that the trading appearance of the indicator is shown. I'm looking to use the following script but I need to somehow trigger it when the bars in the window are moved. The other option is to run a loop consistently checking if the window has moved but as this is an indicator I can't use the Sleep() function. Any suggestions on a loop that may work?
int start()
  {
   int    i,j;
   int limit=Bars-IndicatorCounted();
    
// Clear Buffer
   for(i=limit; i>=0; i--)
      {
      MABuf[i] = 0;
      }
//-- Main Loop
   for(i=limit; i>=FirstVisibleBar()-BarsPerWindow(); i--)
      {
      MABuf[i-MAOffSet] = iMA(NULL,0,MALength,0,MODE_EMA,PRICE_TYPICAL,i);
      }
   return(0);
  }