Volume without considering outliers?

kkrac

New member
I want to search for stocks that have, in average, 1 million volume in the 50 periods or so. But I'm not interested in outliers (eg: average volume is of 50k and one day volume is of 45 million, I don't want to factor in that day with 45million volume in my search.)

What would be the best/right way to do this?
 
I want to search for stocks that have, in average, 1 million volume in the 50 periods or so. But I'm not interested in outliers (eg: average volume is of 50k and one day volume is of 45 million, I don't want to factor in that day with 45million volume in my search.)

What would be the best/right way to do this?

not sure which way to read your description...
what to do with spikes?
1. a volume spike removes the stock from scan result list
2. a volume spike is not included in the volume average formula.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I want to search for stocks that have, in average, 1 million volume in the 50 periods or so. But I'm not interested in outliers (eg: average volume is of 50k and one day volume is of 45 million, I don't want to factor in that day with 45million volume in my search.)

What would be the best/right way to do this?


kkrac,

I've created a script that removes both the highest volume and the lowest volume used to calculate the average volume. Instead of the sum of the latest 50 volumes divided by 50, it is the sum of the middle 48 volumes of those 50 divided by 48.

Interestingly, when a 50 period moving average is used there's not much difference from the original average line, even for GameStop in the chart below where volume showed really big spikes. I changed it from 50 periods to a 10-period average volume and then there were more obvious differences between the normal average and the average without highest and lowest volumes (2nd chart).

In the charts below, the top histogram shows the normal volume average and the bottom one shows the average with high and low excluded.

kkrac-50volumeavg-pic-4-1-23.png



with a 10 period average:

kkrac-10volumeavg-pic-4-1-23.png



Code:
# VolumeAvg_NoOutliers
# Question from kkrac  4-1-23

declare lower;
declare zerobase;

input length = 50;

def Largest = Highest(volume, length);
def Smallest = Lowest(volume, length);

def Total1 = Sum(volume, length);
def Total2 = Total1 - Largest - Smallest;

plot Vol = volume;
plot AvgNoOutliers = Total2 / (length - 2);

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetDefaultColor(Color.RED);
Vol.SetLineWeight(3);

AvgNoOutliers.SetDefaultColor(Color.BLUE);
AvgNoOutliers.SetLineWeight(2);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
241 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top