A memory to store the current index


A memory array where the values are stored



A memory to adjust how many of the last value to sum.


Script

$Hus:Index:Memory$=($Hus:Index:Memory$+1)//len($Hus:Array:Memory$),

$Hus:Array:Memory$($Hus:Index:Memory$)=int(rand*100),

trace("New value(",$Hus:Index:Memory$,"):",$Hus:Array:Memory$($Hus:Index:Memory$)),


n=$Hus:Index:Memory$,

x=0,

y=9999,

s=0,

i=0,

v=0,

loop(len($Hus:Array:Memory$))

(

    n=(n+len($Hus:Array:Memory$))//len($Hus:Array:Memory$),

    if(i<$Hus:LastValues:Memory$)

   (

         v+=$Hus:Array:Memory$(n),

    ),

    s+=$Hus:Array:Memory$(n),

    if($Hus:Array:Memory$(n)>x)

    (

         x=$Hus:Array:Memory$(n),

    ),

    if($Hus:Array:Memory$(n)<y)

    (

        y=$Hus:Array:Memory$(n),

    ),

    n--,

    i++,

),

a=int(round(s/len($Hus:Array:Memory$))),

trace("Last",$Hus:LastValues:Memory$,"values:",v," Sum:",s," Avg:",a," Min:",y," Max:",x),