 # 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);

def YesterdayVol = volume(period = AggregationPeriod.DAY);

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:

#### lucky

##### New member
VIP
def CurrentVol = volume;
plot scan;
scan = CurrentVol >5* ((sum(CurrentVol , CurrentVol , CurrentVol , CurrentVol ))/4);

#### lucky

##### New member
VIP
This is how it look in excel

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

#### lucky

##### New member
VIP
def CurrentVol = Volume ;
def a = Volume ;
def b = Volume ;
def c = Volume ;
def d = Volume ;
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

#### Len20

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

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

VIP
Thanks Len20