# Volatility Indicator/Scan based on Extreme Range for ThinkorSwim

#### MoneyMagnet

##### Member
I've been working on a way to assess equities based on the "smoothness" of their price action. Smooth price action gives clearer signals and fewer false signals. This code is based on the concept of Extreme Range, which is similar to True Range, but captures a fuller picture of the maximum price change between each bar and the next; it's looking for the bar-bar choppiness while ignoring any tradeable swings or trends.

The method is to calculate the Extreme Range series, aggressively de-trend it, average it over time, then express it as a percentage of the stock price. By default, it averages over 50 bars and sets a threshold of 3% of stock price. All adjustable, of course.

Code:
``````#-- XRI (Extreme Range Index)
#-- MoneyMagnet (2020)

declare lower;
input NoisePeriod = 3;
input ScorePeriod = 50;
input Threshold = 3;

def XR = CompoundValue(1, if AbsValue(low - XR[1]) > AbsValue(high - XR[1]) then low else high, high);
def Noise = Average(AbsValue(XR - MovingAverage(AverageType.Hull, ohlc4, NoisePeriod)), ScorePeriod);

plot XRI = Noise / ohlc4 * 100;
plot Thresh = Threshold;
plot Zero = 0;
Zero.AssignValueColor(Color.BLACK);

I am using it to find stocks that have lower risk, though they may also have little tradeable price movement. That can be screened for using other tools.

Last edited by a moderator:
so...how do we use it? do educate me, i am kinda lost here

It's intended to provide a way to see how choppy a stock's price action is, relative to the price of the stock. I use it to determine which stocks (lower number, therefore less choppiness) I will be willing to trade. By avoiding the more volatile stocks, I hope to reduce the false signals I get from trading indicators, and cut down the frequency of getting stopped out.

It needs some work, though, as you can see in the image (which I didn't post, by the way, but just magically appeared...) There's a lot of lag when it's set at the default of 50 bars averaging, and I think I can improve the method of quantifying the short term volatility. Stay tuned...

87k+ Posts
310 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?