# Within % of All Time High

Hi, I'm having trouble getting a scan to return stocks within a % of all time high. Thanks

Hi Luke,

Use the HIGHESTHIGH() function set to All Time, and then multiply by the required value, such as this for within 15%:

CLOSE() > (HIGHESTHIGH(RANGE=All Time) * 0.85)

For more examples of using the HIGHESTHIGH and LOWESTLOW functions see this forum post:

https://forum.optuma.com/topic/new-52-week-highs-and-lows/

Hi Darren

If I wanted to scan for those that have closed within a range of the high, ie say between 30% and 60% of a recent high, how would I adjust that? Cant seem to get this to work.

Thanks for your help.

Hi Joe,

To calculate the % from eg a 26 week high you can use the following in a watchlist column, which will give you a value:

//Define lookback period;
H1 = HIGHESTHIGH(BACKTYPE=Weeks, BARS=26, INSIDEBAR=True, INCBAR=True);
//Get closing price;
C1 = CLOSE();
//Calculate ratio;
R1 = 1-(C1/H1);
R1

For a scan you would need to set the parameters for the ratio, so the last line would be R1 > 0.3 and R1 < 0.6 for your 30%/60% example, giving the true/false column here:

That is perfect, thanks Darren!