MT4 indicator autoscroll

 

Hello,

How do you make an indicator autoscroll? I use this indicator that calculates a moving average angle but I need to refresh it al the time. 

 What do I need to change/add so that it will automatically update on new tics/bars ?

Thanks

Files:
 
  1. You already have it. Your problem is else where. Probably exceeding array size.

  2. fEndMA=iMA(NULL,0,MAPeriod,0,MAMode,Price,i+EndMAShift);
    fStartMA=iMA(NULL,0,MAPeriod,0,MAMode,Price,i+StartMAShift);
    
    Your max look back is StartMaShift (you test End >= Start) so do your loop correctly.
    Your codeLook back handled
       nCountedBars = IndicatorCounted();       
    //---- check for possible errors            
       if(nCountedBars<0)                       
          return(-1);                           
    //---- last counted bar will be recounted
       if(nCountedBars>0) 
          nCountedBars--;
       nLimit = Bars-nCountedBars;
       ShiftDif = StartMAShift-EndMAShift;      
            mFactor = 100*840/Period()/ShiftDif;
       Sym = StringSubstr(Symbol(),3,3);        
                                                
                                                
    //---- main loop                            
       for(i=0; i<nLimit; i++)
    
    Decrement is unnecessary Contradictory information on IndicatorCounted() - MQL4 forum
       nCountedBars = IndicatorCounted();       
    //---- check for possible errors            
       if(nCountedBars<0)                       
          return(-1);                           
    //---- last counted bar will be recounted
    //   if(nCountedBars>0)                  
    //      nCountedBars--;                  
    //   nLimit = Bars-nCountedBars;         
       ShiftDif = StartMAShift-EndMAShift;      
            mFactor = 100*840/Period()/ShiftDif;
       Sym = StringSubstr(Symbol(),3,3);        
                                                
                                                
    //---- main loop                            
       for(i= Bars - 1 - MathMax(nCountedBars, StartMAShift); i>=0; i--)
    
    Get in the habit of counting down. (can't use future values to compute past ones.)
 

Thank you very much it works !

Reason: