Duplicate: Backtesting (Array subscript out of range)

ty//ALMA
_SECTION_BEGIN("ALMA");
p = ParamField("Price Field");
windowSize = Param("Window Size", 9, 5, 201, 2);
sigma = Param("Sigma", 6, 1, 20);
Offset = Param("Offset", 0.85, 0.05, 1.0, 0.05);

m = floor(Offset * (windowSize - 1));
s = windowSize / sigma;

w = 0;
wSum = 0;

for(i = 1; i < windowSize; i++)
{
     w[i] = exp(-((i-m)*(i-m))/(2*s*s));
     wSum += w[i];
}

for(i = 1; i < windowSize; i++)
{
     w[i] = w[i] / wSum;
}

alma = Null;

for(j = 1; j < BarCount; j++)
{
     alSum = 0;

     if(j < windowSize)
     {
         alma[j] = Null;
     }
     else
     {
         for(i = 1; i < windowSize; i++)
         {
             alSum += p[j - (windowSize - 1 - i)] * w[i];
         }

         alma[j] = alSum;
     }
}

_SECTION_END();

//Moving Average
	MA10 = MA(C, 10);
	MA20 = MA(C, 20);
	MA50 = MA(C, 50);
	MA100 = MA(C, 100);

//Volume
	Highvolume = (Volume * Avg) > 5000000;

//Risk Management
SetOption("InitialEquity", 100000);
SetPositionSize(1, spsPercentOfEquity);
ApplyStop(stopTypeLoss, stopModePercent, Optimize( "max. loss stop level", 10, 5, 15, 1 ), True );

//Execution
Buy = C > alma AND highvolume;
Sell = C < alma;

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);


// PLOT SIZE
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
Plot( Close, "Price", colorBlack, styleCandle );
PlotShapes( shappe or paste code here

It shows alert like theseimage .

@markizta69, this is a very common error and the error message clearly indicates where it happens (when you saw it your windowSize - and consequently the i value used in the iteration - was greater than BarCount-1),

Please, search the forum with "array subscript" to find similar issues and to understand how to avoid it in your code.
(The search immagine is located at the upper right corner).

Re the ALMA, a correct version of that indicator was already posted here.

Follow forum rule and ALWAYS search before creating new threads: https://forum.amibroker.com/search?q=subscript%20out%20of%20range