Date Missing


I have a watchlist column that displays the value of an item of the last trading day of the month.

For June 2024 the script is the following:

Line1 = BARDATE()==STRDATE(DATE=2024-06-28) ;
Line2 = VALUEWHEN(CLOSE(), Line1) ;

The script works fine as it should.

But for the code “BAMLH0A0HYM2EY” there was no value for 06/28/2024!

How can I change the script that when for 06/28/2024 or any last trading day of a month there is no value available, the value of the day before should be used?

I tried the following script:

Line1 = BARDATE()==STRDATE(DATE=2024-06-28) ;
Line2 = VALUEWHEN(CLOSE(), Line1) ;
Line3 = BARDATE()==STRDATE(DATE=2024-06-27) ;
Line4 = VALUEWHEN(CLOSE(), Line3) ;

Line5 = IF(Line2 >= 0, Line2, Line4) ;

The script does not work, because for the code “BAMLH0A0HYM2EY” there was no value for 06/28/2024.

Any suggestion is appreciated.


Hi Thomas,

There are a few ways to do this i can think of. The simplest would be to use a timeframe override for the last monthly close:


This would be a rolling month script, so you always get the previous months final close.

The other option is a more complex script but you can set it to be a static point being returned:

//Set Close
V1 = CLOSE();
//Set Month and Year
V2 = MONTHNUM() == 6 and YEARNUM() == 2024;
//Find where V2 is True
V3 = V2 == 1;
//Find Last Bar of Set Month and Year
V4 = V3 ChangeTo 0;
V5 = V4[-1];
//Close on Last Bar of Selected Month Year

I tried the above script on the ASX All Ords and it worked for the 2 codes that did not have a bar on the 28th. The two scripts produced the same results.


1 Like

Hi Matthew,

Thank you very much for your efforts.

The second script is the one I need.