It's the code of a signal, when I want to optimize it (Length from 4 to 100), I got the following error: "Array bounds. Wrong index value: 51"
Why do I got this error?Inputs:
MAType ( 0 ),
Length ( 20 ),
ConfirmBars ( 1 );
Variables:
MAValue ( 0 ),
NBars ( 0 );
switch (MAType)
begin
// 0 - SMA - Simple Moving Average
case 0:
MAValue = AverageFC(C, Length);
// 1 - SmMA - Smoothed Moving Average
case 1:
MAValue = SmoothedAverage(C, Length);
// 2 - TMA - Triangular Moving Average
case 2:
MAValue = TriAverage(C, Length);
default:
MAValue = AverageFC(C, Length);
end;
condition1 = C > MAValue;
if condition1 then
NBars = NBars + 1
else
NBars = 0;
condition1 = currentBar > ConfirmBars and NBars = ConfirmBars;
if condition1 then
buy ( "LE-Price-Over-MA" ) next bar at market;
(I have MC 7.2)