top of page

Understanding and Using the Day High Checker Tool in PineScript

Code Block in Pinescript

indicator("Day High Checker", overlay = true, shorttitle = "DHC")

// Inputs for 7 stocks
s1 = input(title="Stock 1", defval="AAPL")
s2 = input(title="Stock 2", defval="MSFT")
s3 = input(title="Stock 3", defval="AMZN")
s4 = input(title="Stock 4", defval="GOOGL")
s5 = input(title="Stock 5", defval="FB")
s6 = input(title="Stock 6", defval="NFLX")
s7 = input(title="Stock 7", defval="TSLA")

// Function to compare high prices
compareHighs(symbol) =>
    prevHigh =, "D", high[1])
    todayHigh =, "D", high)
    todayHigh > prevHigh ? symbol : ""

// Checking each stock
s1_check = compareHighs(s1)
s2_check = compareHighs(s2)
s3_check = compareHighs(s3)
s4_check = compareHighs(s4)
s5_check = compareHighs(s5)
s6_check = compareHighs(s6)
s7_check = compareHighs(s7)

// Plotting labels
labelYPos = high + 10 // adjust this value as needed

if (s1_check != ""), labelYPos, text=s1_check,
labelYPos := labelYPos + 10 // adjust this value as needed
if (s2_check != ""), labelYPos, text=s2_check,
labelYPos := labelYPos + 10
if (s3_check != ""), labelYPos, text=s3_check,
labelYPos := labelYPos + 10
if (s4_check != ""), labelYPos, text=s4_check,
labelYPos := labelYPos + 10
if (s5_check != ""), labelYPos, text=s5_check,
labelYPos := labelYPos + 10
if (s6_check != ""), labelYPos, text=s6_check,
labelYPos := labelYPos + 10
if (s7_check != ""), labelYPos, text=s7_check,

The Day High Checker is a custom indicator built using PineScript, the scripting language unique to the TradingView platform. It's designed to identify stocks that are hitting new highs compared to the previous day, offering an efficient way to monitor bullish activity across multiple securities.

The Day High Checker accepts input for seven different stocks, which can be specified manually in the script. The stock tickers are entered as the default values for seven input fields, identified as `s1` through `s7`. This allows users to monitor a custom set of stocks according to their specific investment or trading strategies.

The core functionality of this tool is defined by a function called `compareHighs`. It takes a stock symbol as input, uses TradingView's `` function to fetch the previous day's high and the current day's high for the given stock, and returns the stock symbol if the current day's high is greater than the previous day's high.

The `compareHighs` function is run for each of the seven stocks, and the results are stored in the variables `s1_check` through `s7_check`. These variables will contain the stock symbol if the stock has hit a new high, or an empty string otherwise.

The script then plots labels for each stock that has hit a new high using the `` function. These labels, appearing on the chart, contain the stock symbol and are color-coded for easy identification. To ensure the labels don't overlap, each label's vertical position is set slightly lower than the previous one, resulting in a neatly organized list of stocks on your chart.

To use this script, simply replace the default stock symbols with the ones you're interested in, add the script to your TradingView chart, and you will be notified directly on the chart when a stock from your list hits a new high for the day.

In conclusion, the Day High Checker in PineScript is an effective tool for active traders and investors looking to track potential breakout stocks that are setting new daily highs. This script illustrates the power of Pine Script to provide custom solutions for technical trading strategies.

Limitations of the code

1. Limited Stocks: The current implementation only allows tracking of 7 stocks at a time. If a trader wants to monitor more stocks, they would have to manually modify the script to add more input fields and checks. This could become tedious and inefficient for tracking a large portfolio.

4. No Alerts: This script doesn't support TradingView alerts out of the box. If users want to be alerted when a stock's high exceeds the previous day's high, they'd need to add that functionality to the script. This limitation could mean missing out on potential trading opportunities due to not being notified in real-time.

5. One Timeframe: The script only compares the high of the current day with the previous day's high, based on the daily timeframe. It doesn't support other timeframes without modification. This lack of flexibility can be restrictive for traders who use different timeframes for their analysis, as trends can look different depending on the timeframe.

Example application of Pinescript

pinescript day high checker image

This is how the implementation looks on the charts.

Hope this is useful!

7 views0 comments


bottom of page