Get an array of the closing prices for the past 30 days e.g. on 1st July 2024, I want to get the array of the closing prices for June 1 to June 30.

Then (nothing complicated), just want a simple array operation (nothing to complex) to get maximum closing price, minimum closing price in the array,, mode (most frequently occurring), and calculate the average closing price for the period (is there an average function like Average in Excel) and median?
I want to display these in the Guru Chart commentary window.

What I have done so far

I have seen there is a median function but I dont know how to use it with the array containing the closing price of the specified 30 days.

I have looked here AFL Function Reference (amibroker.com) but have not seen any function that gets an array of closing prices for a specified date for processing. I also did not see a simple average function similar to Average function in Microsoft Excel.

In the link above the min() and max functions usage isnt clear; I am not sure how to use it in this scenario.

NB: I dont want to use the price/ volume distribution formula as it is not necessary. Just want a basic array operaton to get the measures of central tendency specified above.

I currently export to Excel to do this but I want to do it in Amibroker. In Excel, I select the cell range and use median(), mode() and average(), min() and max() and the job is done but I am working on several symbols and exporting to Excel is not ideal.

Hello. Please see:
WriteVal( BeginValue( DateTime() ), formatDateTime );
WriteVal( EndValue( DateTime() ), formatDateTime );
//Moving average
//WriteVal( MA(EndValue( Close ) to BeginValue( Close ))
//WriteVal(HHV(EndValue( Close ) to BeginValue( Close ))

So I want to tie it to whatever period I select on the chart and display in Chat Guru Commentary window all these info using printf statements.

Not sure if the code below will work dynamically in the Formula/ chat guru output window:
YourAverage = MA( Close, 30 );
YourMin = LLV( Close, 30 );
YourMax = HHV( Close, 30 );
YourMedian = Median( Close, 30 );