Date in column title

Filter = 1;
AddColumn(Ref(ROC(C,1),-5), "change%5" + Date() ,1.2,IIf(Ref(ROC(C,1),-5)>0, textcolor = colorwhite,colorwhite),IIf(Ref(ROC(C,1),-5)<0,bkgndcolor= colorRed,colorGreen));

Hello all,
I am using the above code to populate a column with the change in price from 5 days ago. It displays as in image below (see last column title). Problem is the date is todays date and I don't know how to reference the date five days ago. I have tried ref(date(),-1) but it gives an error. I have tried using datetime() but the syntax is beyond me. Any thoughts? TIA.
image

Ref() is array function and Date() is string function. So they do not fit together.
Besides for column title you can't insert array. So you have to convert array to number and then to string.

Filter = 1;
//
rc = Ref(ROC(C,1),-5);
//
ref5_dt = Ref(DateTime(), -5);// array
ref5_dt_select = SelectedValue(dt);// number
dt_str = DateTimeFormat("%d/%m/%Y", ref5_dt_select);//string
//
textcolor = IIf(rc>0, colorwhite, colorwhite);
bkgndcolor = IIf(rc<0, colorRed, colorGreen);
AddColumn(rc, "change%5 " + dt_str, 1.2, textcolor, bkgndcolor);

10

3 Likes