HAS indi problem with refresh

 

Hello everyone.

Can someone please correct the attached indicator or point me in the right direction (although I'm not very good at programming)?
When the MT4 is opened, the indicator currently shows the correct value, but then stops redrawing. I need to refresh the chart to show the correct value.
Thank you for your help.

CADCHF


Files:
 
   int limit=rates_total-prev_calculated; 
   if(limit>BarsToUse)limit=BarsToUse+130+HAS_MAPeriod; // 130 extra bars to ensure clean data after smoothing
   limit-=HAS_MAPeriod;
   for(int i=0; i<limit; i++) {

After the initial run limit is rates_total equals prev_calculated, and limit equals negative HAS_MAperiod. So your loops do nothing.

Do your lookbacks correctly #9#14 & #19

.