How add the column of different date

How i the correct the error ref(date(),-1))?

addcolumn(open, date());
addcolumn(ref(open,-1), ref(date(), -1));
addcolumn(ref(open,-2), ref(date(), -2));

Date() returns string not number. You should be using DateTime() instead.

AddColumn( Ref( DateTime(), -1 ), "name of column", formatDateTime );

Recommended reading
http://www.amibroker.com/guide/h_understandafl.html

1 Like

Thank you for your answer. but i want the name of column be date.

this addcolumn(ref(open,-1), ref(datetime(), -1)) is error.

The second argument posted by Tomasz is a string and is suppossed to be a header for that column.

If you want to put custom Text over there, then you need to first get a scalar value from the Array that you are passing to it and Convert it to type String.

DateTimeToStr( LastValue( Ref( DateTime(), -1)) , 1 ) , 1)
so something like this

AddColumn( ref(open,-1), DateTimeToStr( LastValue( Ref( DateTime(), -1 )) , 1);
2 Likes

In Exploration the rows have dates assigned to them, not columns. It makes no sense to have date in column header because it would be just misleading. Besides columns are common to all symbols so the code with "dynamic" column name makes no sense at all as it would be valid for first but not necessarily subsequent symbols.

2 Likes

Thank you very much.:rose:

Yes, you may have achieved your requirement but as mentioned by TJ in above post and by me is that the field is a Header and it should be appropriate or relevant as a header field.