Given a specific future date, how to plot a verticle line

I have a specific future date and need to plot a verticle line on the right margin of the chart. Can someone give me a hint what is the easist way to do this? I have seen discussions on how to draw a verticle line in the chart, but having difficulty to draw it for a future bar because DataNum does not work for future date.

Any help or pointer is appreciated.

The only way to do that is to use low-level GFX You would need to calculate "X" coordinate yourself, in pixels. Trouble is that you don't really know what the future will be therefore you must assume what trading days will be. The easiest approach can be assuming that you got a session every working day, but that is not always true.

I think I am quite ok working with the assumption that we have trading day for each future working day. Is there a similar function as DateNum but allow me to specify the last date? This way, I can use plot with shift to draw the line easily. Caluclating X-coordinate myself is a big no-no to me.

Currently, I can draw verticle line on the right margin manually. So internally, the system must have a way :slight_smile:


Please read basics of AFL.

dn = DateNum();
last_dn = LastValue(dn);
dt = DateTime();
last_dt = LastValue(dt);


Thanks for trying to answer my post. Sorry that I did not express myselff clearly. I know about these two functions: DateNum() and LastValue(). I have been using them a lot. The problem with DateNum() is that it does not take any parameter. It assumes the last date is today. If there is a similar function as DateNum() but allows me to specify the last date (such as a future date), then the generated dn array will be very useful and I can search for bar location using Lookup() giving a specific date. This will facilitate me to draw verticle line with the plot function for future date with the shift parameter.

Hope I explain myself clearly.

You don't need that (DateNum() argument). Also DateNum() is bound to array size (since it is array function). You can not exceed array.

For what you want to do you may use DateTimeDiff() function.


1 Like

Great suggestion!
Thank you very much...

can I ask you to share the code for your image?
This is excactly what i need but i don´t understand principle of DateTimeDiff.