# Custom average volume script help

#### lucky

##### New member
VIP
I need some help. I’m trying to find the average volume of the last 4 days. Then look at today volume to be 5 times the average.

Example:

Volume (02-11-20 + 02-12-20 + 02-13-20 + 02-14-20) divide by 4 =Average

Today Volume ( 02-18-20) = 5 times the average.

Volume( 5,000, 6000, 7000, 8000) divide by 4 = 6,500

Today Volume is 32,500

32,500 / 6,500 = 5 times

Here’s my script

def YesterdayVolAvg = Average(volume(period = AggregationPeriod.DAY), 4)[0];

def YesterdayVol = volume(period = AggregationPeriod.DAY)[0];

plot Scan = YesterdayVol > YesterdayVolAvg * 5;

def a = volume 1 day ago

def b = volume 2 day ago

def c = volume 3 day ago

def d = volume 4 day ago

def e = ( a+b+c+d) / 4

def f = today volume

plot scan = f > e*5

I appreciate any help. Thank you

Thanks for all the help

Last edited:
def CurrentVol = volume;
plot scan;
scan = CurrentVol >5* ((sum(CurrentVol [1], CurrentVol [2], CurrentVol [3], CurrentVol [4]))/4);

This is how it look in excel

=SUM((HP2*5)/((HP3+HP4+HP5+HP6)/4))

def CurrentVol = Volume [0];
def a = Volume [1];
def b = Volume [2];
def c = Volume [3];
def d = Volume [4];
def e = a+b;
def f = c+d;
def g = e+f;
def h = g/4;
def j = h*5;

plot Scan = CurrentVol>j;

I think this is correct.

Can I go back 1 day ago and check?

Can I go back 2 day ago and check?

etc
I appreciate any help. Thank you

Thanks for all the help

Here you go. This should work. Just set the scan to daily aggregation

Code:
``````def FourDaysVolAvg = Average(volume[1], 4);
def TodayVol = volume;
plot Scan = TodayVol > FourDaysVolAvg * 5;``````

Thanks Len20

87k+ Posts
406 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?