% Below ATH

Does anyone know the correct script to get the "percent below all-time high" for an issue. I am using the following but noticing the data is not correct.

(HIGHESTHIGH(RANGE=All Time)-close(0))/close()

Hi Steven,

You don’t need to do the calculation manually, there is a function that does it automatically called Range from Extremes RFE()

An example script for % from All Time high would be:


On a show view the result would look like this:


Show View using the above script has a value of 12.07% from AAPLs all time high.

What about that black line at the ATH.


Can't we plot a code on the chart that says ATH - the date & then also list the % that the share has until it reaches the ATH?


This way the chart can dynamically update. Without having a show view tab below chart ... ?

You don’t need to script it, you can use the Range from Extremes tool itself to plot the ATH / ATL on the chart, and the date will appear when you hover over the line for each…


You can see more information on the tool here:



Note if you want to display as % in a watchlist divide by 100 and change the column type to Percentage:

RFE(BACKTYPE=All Time)/100

Also you can colour-code the cells based on values by right-clicking on the column title and going to Custom Labels, so within 5% of ATH set to green:


Also, Darren gave me this code for 52 week drawdown. It has worked well for me. I do like the RFE as I was trying to find the distance above recent highs, and that may work well. Thanks.

//1 year Drawdown 
C1 = CLOSE(); 
ch1 = ((c1-h1) / h1)*100; 
p1 = IF(ch1 < 0, ch1, 0); 
//plots avg drawdown over the 1 year 
plot1 = p1; 
plot1.Plotstyle = Shaded; 
//calculate 1 year MA 
plot2 = LAST(MA(p1, BARS=260, CALC=Close)); 
plot2.Color = Blue; 
//get max 52 wk drawdown 
plot3 = LAST(LOWESTLOW(p1, BACKTYPE=Years, BARS=1)); 
plot3.Color = Red;