ATR Percentage

An ATR on one security can not be compared with another. The only way we can compare the volatility of different securities is to calculate the percentage of the ATR compared to the price of the security. This script represents that ATR ratio as a percentage.

a1 = ATR(); a1/CLOSE() * 100

Hey Mathew, any way to then take the ATR % and build historical range bars based on that?

For instance I would like to use Range bars set at a trailing x days ATR% . Is there a way to do this (price charts would be built backwards from today)?

As example I would like the SPY Range bars instead of being a set 2.5%, instead be a dynamic range based on that day’s trailing 10 day ATR %. So this would be the input into the “Range Value” on the Range Charts. Or very well could just be the ATR $ itself and the “Range Value - Price” could be used.

Is this possible through scripting?

Thank you,


Hi Chad,

I can’t see that using today’s ATR values and working back would work. The ATR today is going to be much bigger and it would render earlier values to be really really small. There is no way for us to build a bar from three different values. It would require a bit of work to add that in.

What you could do is use three plots of the above script but for the other two change the “Close()” to the “high()” and “low()” (do this in a Show View). Then what you would have is a line for the high price as a percentage of ATR for that day, and also the close line and the low line.

You can read about multiple plots here

The scripts you would use would be

Plot1 = ATR()/HIGH() * 100;
Plot2 = ATR()/CLOSE() * 100;
Plot3 = ATR()/LOW() * 100;

Then you just need to set the line styles as per that KB.

Hope that helps


You may need to play with the order of this - I just realised that the high would be smaller than the low -but that could still be the information you need to know.

Translated by Google:
Suppose I create a watchlist of the SP500 and use the following code:
(ATR(BARS=14, MULT=1.00) / CLOSE() ) > #value : 0.05
then a list neatly rolls out with true/false. 
But now I want to replace the value 0.05 with the value of the ATR percentage by the ATR value calculated from the SP500 index.
In the example above I always have to calculate that value 0.05 and then enter it.
How can I indicate in the formula that the value (0.05 in the example above) should be calculated from the SP500 index, 
so that I can enter that in the formula:

(ATR(BARS=14, MULT=1.00) / CLOSE() ) > (ATR calculated from the SP500 index that day) 
so that the value is recalculated every day and does not have to be entered manually.

I hope that comes across what I want to ask.

Hi Jan,

You can use the GETDATA() function to call a value from a specific code (SPX in this case) to compare other values against.

For your example of the ATR you could do something like this:

//Get SPX Data
//ATR Value from SPX
V2 = ATR(V1, BARS=14) ;
V3 = V2 / V1 ;
//ATR Value from Chart
V4 = (ATR(BARS=14, MULT=1.00) / CLOSE());
//Is Chart ATR higher than SPX ATR
V4 > V3

Here’s an example of how the above would look on a Watchlist and chart:

I’ve attached an example workbook for you to reference. Let me know if you have any questions.

ATRScriptExample.owb (224 KB)

Thanks, that’s what I was looking for.