How to obtain any past closing price for all stocks in a watchlist?

Help anyone!! I have tried numerous times with no success to get the closing price of a past date . How can I get the closing prices for example 3/16/20 for the DOW 30 stocks of my watch list into the Analysis Window. I am running Amibroker ver 6.00.2

I am a novice in AFL programming language. Thanks for your assistance.

which_date = "2020-03-16";
dt_array = DateTime();
// Filter only stocks at specified date
Filter = DateTimeDiff(dt_array, _DT(which_date)) == 0; 
// Output Close price
AddColumn(Close, "Close", 1.2);

9


Alternatively you may do with less code by using Analysis tool bar

Filter = 1;
// Output Close price
AddColumn(Close, "Close", 1.2);

9


See here
http://www.amibroker.com/guide/h_exploration.html
http://www.amibroker.com/kb/tag/exploration/
for more about exploration.

image

Sorry, pasting the formula did nothing. Can it be due to the version I am using?

The codes work if you have data.

Set analysis interval to daily interval since you look for date only.
Also the set date has to exist so check in quote editor or chart of symbol whether date exists.

Apply debugging yourself.
Sorry but you can't expect endless hand holding for each and every "baby step".
For basic steps please read AB manual first as well as KB. since it is all there already.

which_date = "2020-03-16";
if ( Status( "actionex" ) != actionExEditVerifyFormula ) 
	if ( StrLen(which_date) == 10 && Interval() != inDaily )
		Error( "Set ANALYSIS interval to DAILY!" );
//
dt_array = DateTime();
// Filter only stocks at specified date
Filter = DateTimeDiff(dt_array, _DT(which_date)) == 0; 
// Output Close price
AddColumn(Close, "Close", 1.2);

To look for datetime use e.g

which_date = "2020-03-16 12:00";