ExtremesArray function is ignoring value with index = 0  [SOLVED]

Questions about MultiCharts and user contributed studies.
jrakovsk
Posts: 5
Joined: 25 Feb 2011

ExtremesArray function is ignoring value with index = 0

Postby jrakovsk » 10 Sep 2014

Hi,
The ExtremesArray, HighestArray a LowestArray functions are ignoring values stored in the field with index = 0. Is it a known bug?

Code: Select all


Inputs: ndays ( NumericSimple ) ;

Variables: ind ( 0 ) , var0 ( false ) , var1 ( false ), prevH ( 0 ), prevL ( 0 ) , DH ( 0 ), DL ( 0 ) ;

Arrays:
HA[ ] ( 0 ),
LA[ ] ( 0 );

if ndays > 1 then begin

var0 = array_setmaxindex ( HA , ndays - 1 ) ;
var1 = array_setmaxindex ( LA , ndays - 1) ;

for ind = 0 to ndays - 1 begin

HA [ ind ] = HighD ( ind + 1 );
LA [ ind ] = LowD ( ind + 1 ) ;
end;

{prevH = highestarray ( HA , ndays - 1 ) ;
prevL = lowestarray ( LA , ndays - 1 ) ; }

value1 = ExtremesArray ( HA, ndays-1 , 1 , prevH , value2 ) ;
value3 = ExtremesArray ( LA, ndays-1 , -1 , prevL , value2 ) ;

print ( " ................ " ) ;
print ( date:10:0 , prevH:10:2 , prevL:10:2 ) ;
print ( " ................ " ) ;
end;

for ind = 0 to ndays - 1 begin

print ( (ind ):6:0 , HA[ind]:10:2 , LA[ind]:10:2) ;

end;
end;

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: ExtremesArray function is ignoring value with index = 0  [SOLVED]

Postby Henry MultiСharts » 10 Sep 2014

Hello jrakovsk,

This is not a bug. This is how the functions are originally designed per EL Functions & Reserved Words Reference:
The value for the Size input parameter should always be a whole number greater than 0 and is typically equal to the number of data elements in the array.

These functions only work with one-dimensional arrays. All array-based referencing begins with array element 1.


Return to “MultiCharts”