Arrays vs Loops MT4

 

Hi All,

I am using loops to run a few calculations. For example look at the below, where I am using this to calculate mean over a period of time. I was wondering if I am better of inserting this into an array or is loop a better way? I am running this every one minute. I haven't been able to deploy this, everytime I do, the "shutdown by termination" error. Believe this is due to a 2.5 second time limit.

sum_y=sum_y+iClose("NZDUSD",PERIOD_M1,i);
 

Please show the full code and explain what you are trying to do.

Adding close values like this ? why ? it will grow very fast and possibly go beyond the storage capacity of sum_y.

Reason: