Download MetaTrader 5
To add comments, please log in or register
Have you discovered something really important? Write an article and receive 200 USD!
Alfred Deller
40
Alfred Deller 2015.01.05 08:25 

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:
whroeder1
13597
whroeder1 2015.01.05 16:36  
  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.)
Alfred Deller
40
Alfred Deller 2015.01.06 11:09  

Thank you very much it works !

/
To add comments, please log in or register