How many new 1 year high an individual security has made during the year 2023

Hi there,

I am trying to check the number of new 1 year high for an individual security has made during the 2023 with the following script:

H1 = HIGH() > HIGHESTHIGH(BACKTYPE=Weeks, BARS=52, INCBAR=True);
ACC(H1, RANGE=Range, RANGESTART=2023-01-01, RANGEEND=2023-12-31)

However, the result returns is always 0. Is there a mistake in my script ? If so, how to modify it in order to make it work?

Thanks

Yan

Hi Yan,

The high cannot be higher then the highest high, it has to be equal to. Also, the ACC() function doesn’t allow for a date range so we need to use the ACCSINCESIGNAL() function with the signal being when the year changes:

//Get new highs;
H1 = HIGH() >= HIGHESTHIGH(BACKTYPE=Weeks, BARS=52, INCBAR=True);
//Change in year;
Y1=YEARNUM() IsUp;
//Count new highs in each year;
ACCSINCESIGNAL(H1, Y1)

So for SPX there were 26 52 week highs in 2023, and 15 so far this year:

3 Likes

Hi Darren,

Thanks for the reply.

My intention is to use this function in the watchlist to see how many new 1 year high was made during a specific year.

The difficulty here is how to output that 26 for the year 2023, I don’t have a clue for using which script here to make that happen.

Please let me know if there is any.

Thanks

Hi Yan,

You would need to make sure the Watchlist Date Range was set to Everything first. Then you can add additional lines to Darrens script example to find the value for specific dates.

In this example I’ve set it up to show me the value on the last trading day of 2023:

//Get new highs;
H1 = HIGH() >= HIGHESTHIGH(BACKTYPE=Weeks, BARS=52, INCBAR=True);
//Change in year;
Y1=YEARNUM() IsUp;
//Count new highs in each year;
V1 = ACCSINCESIGNAL(H1, Y1);
//Specific Year 2023
V2 = BARDATE() ;
V3 = STRDATE(DATE=2023-12-29) ;
V4 = V2 == V3;
VALUEWHEN(V1,V4)

You can adjust V3 to any date you are wanting to view the scripts results for.

2 Likes

Hi Matthew,

Thanks for your help.

Your solution to use the last day of each year to create the script work perfectly. The function valuewhen is exact the thing that I am looking for in the past several days.

I found a small anomalie when I try to get the result for the year 2018.

In fact if I use STRDATE(DATE=2018-12-31) the result returns will be 0 for any security. When I modify the date to 2018-12-28, then the script works again.

I don’t know why it happens like this, since my object of learning the market internals is met, so you guys can check this out whenever you want.

Thanks again for the help from everyone.

Have a good day.

Hi everyone,

I want to clearify that the script works perfectly, the reason that I have difficulty in getting the value for the year 2018 is that the 12-31-2018 was not a trading day in Chinese equites market.

I am very sorry and I will be more careful next time to check everything first.

Thanks for the help from everybody and have a good day.

1 Like

For all time closing highs change the first line to this:

H1 = CLOSE() >= HIGHESTHIGH(CLOSE(), INCBAR=True, RANGE=All History);
1 Like