Hello, a simple problem here, if you are an expert you will find this problem within seconds…my indicator always gets error “Array out of range” when trying to test it. I just dont know why…

```
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_plots 3
#property indicator_type1 DRAW_LINE
#property indicator_color1 C'127,191,127'
#property indicator_style1 STYLE_SOLID
#property indicator_label1 "Negative Deviation"
#property indicator_type2 DRAW_LINE
#property indicator_color2 C'191,127,127'
#property indicator_style2 STYLE_SOLID
#property indicator_label2 "Positive Deviation"
#property indicator_type3 DRAW_LINE
#property indicator_color3 C'191,127,127'
#property indicator_style3 STYLE_SOLID
#property indicator_label3 "Spread"
#property indicator_width3 2
#define DATA_LIMIT 200
#include <MovingAverages.mqh>
double spreadLine[];
double upperDeviation[];
double lowerDeviation[];
void OnInit()
{
SetIndexBuffer(0,spreadLine,INDICATOR_CALCULATIONS);
SetIndexBuffer(1,upperDeviation,INDICATOR_CALCULATIONS);
SetIndexBuffer(2,lowerDeviation,INDICATOR_CALCULATIONS);
// hATR=iATR(NULL,ATRtimeframe,ATRper);
}
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime& time[],
const double& open[],
const double& high[],
const double& low[],
const double& close[],
const long& tick_volume[],
const long& volume[],
const int& spread[])
{
double closePricesEURUSD[];
double closePricesGBPUSD[];
double logEURUSD[];
double logGBPUSD[];
//--- check for rates total
if(rates_total<DATA_LIMIT)
return(0); // not enough bars for calculation
CopyClose(NULL,timeFrame,0,rates_total-100,closePricesEURUSD);
CopyClose(currency2,timeFrame,0,rates_total-100,closePricesGBPUSD);
for(int j=0; j<rates_total-100; j++)
{
double sum_Xi=0.0;
double sum_Yi=0.0;
double sum_Xi_squared=0.0;
double sum_Yi_squared=0.0;
double sumOfProductXiYi=0.0;
for(int i=j; i<j+100; i++)
{
logEURUSD[i]=log(closePricesEURUSD[i]); // HERE IT SAYS OUT OF ARRAY
logGBPUSD[i]=log(closePricesGBPUSD[i]);
sum_Xi = sum_Xi + logEURUSD[i];
sum_Yi = sum_Yi + logGBPUSD[i];
sum_Xi_squared = sum_Xi_squared + logEURUSD[i]*logEURUSD[i];
sum_Yi_squared = sum_Yi_squared + logGBPUSD[i]*logGBPUSD[i];
sumOfProductXiYi = sumOfProductXiYi + logEURUSD[i]*logGBPUSD[i];
}
return (rates_total);
}
```

tried everything from resizing array, setasseries, change beginning condition of “for” loop to j=1, and also trying to give the array a constant size when defining it. Help is appreciated!