How to Scan for Stocks That Hit YTD High on Dec. 31?

As we approach the end of another year, many investors are wondering what stocks have made a YTD high on the last day of the year. This is an important metric to track, as it can help you identify stocks that may be poised for further growth in the coming year.

In this thinkScript episode, I will show you how to write custom thinkScript code to scan for stocks that made a YTD high on December 31st.

Let’s get started!

What is a YTD High?

A “year-to-date” (YTD) high is the highest price that a stock has reached during the current year. It can be helpful to track stocks that have made a YTD high on the last day of the year, as this may be an indicator that these stocks are poised for further growth in the coming year.

How to Scan for YTD High in ThinkOrSwim

The code to scan for stocks that made a YTD high on December 31st is relatively simple. In order to do this, we will use the Highest and Lowest thinkScript functions, which returns the highest price that a stock has reached during the current year.

Here is the custom thinkScript code we use for this scan:

def yearHigh = Highest (high, 253);

def yearLow = Lowest(low, 253);


#if running on Dec. 31

plot signal = high >= yearHigh;


#if running after Dec. 31

#plot signal = if GetYYYYMMDD() == 20211231 and high >= yearHigh then 1 else 0; 

This code will return a “signal” of whether or not a stock has made a YTD high on December 31st. If you’d like to scan for a different date in the future, simply update the year in the second signal condition, which is currently commented out.

How to Scan for YTD Low in ThinkOrSwim

To scan for the opposite, a YTD Low, we simply change the signal output variable to scan for and compare the low price, against the YearlyLow.

def yearHigh = Highest (high, 253);

def yearLow = Lowest(low, 253);


#if running on Dec. 31

plot signal = low <= yearLow; 


#if running after Dec. 31

#plot signal = if GetYYYYMMDD() == 20211231 and low <= yearLow then 1 else 0; 

That’s it!

With this code, you can easily scan for stocks that made a YTD high and low scan, that you can run on the last day of every year.

Why You Should Track Stocks That Have Made a YTD High on the Last Day of the Year?

There are 2 key reasons why you should track stocks that have made a YTD high on the last day of the year.

  1. First, this can be an indicator of which stocks may be poised for further growth in the coming year. Stocks that have reached a YTD high on the last day of the year may be experiencing bullish momentum, and may be worth keeping an eye on as we move into te next year.
  2. Second, tracking stocks that have made a YTD high on the last day of the year can help you identify stocks that are outperforming the market. By identifying stocks that have had the highest growth during the current year, you can gain insights into which stocks may be worth investing in for the coming year.

Hopefully this thinkScript episode has helped you learn how to scan for stocks that have made a YTD high on the last day of the year.