In the interpretation window I want to print the date of the bar that follows say 10 bars after the selected bar. Let's assume I have selected Monday, the third of September 2018. Then Amibroker should print "2018-09-17" (10 trading days later). First I tried:
if (Status("action") == actionCommentary)
{
printf(DateTimeToStr(DateTimeAdd(SelectedValue(DateTime()), 10, inDaily)));
}
However, this simply adds 10 days to the calendar date and hence prints "2018-09-13". Another approch would be to use the bar index:
printf("%.0f", SelectedValue(BarIndex() + 10));
But how to convert a bar index to a date?
Maybe try valuewhen
Amibroker Help - Valuewhen