# Writing basic formula using multi time-frame

#### amirfutures

##### New member
Hello, I'm trying to write the following formula using multi time-frame. Plotting it on a 5 min chart, using 15 min data.

Code:
``````rec AccVol =  (AccVol+volume)/2;
plot MyVol = AccVol;``````

Thanks

Solution
Hello, I'm trying to write the following formula using multi time-frame. Plotting it on a 5 min chart, using 15 min data.

Code:
``````rec AccVol =  (AccVol+volume)/2;
plot MyVol = AccVol;``````

Thanks

try this
Code:
``````def agg = AggregationPeriod.fifteen;
def AccVol =  (AccVol + volume(period = agg)/2;
plot MyVol = AccVol;``````

but i think it will produce 3x the actual volume. on each 5min bar, it will add on the 15 minute volume.
i think your original code should add up the volume, ( if the /2 is removed).

#### halcyonguy

##### Well-known member
VIP
Hello, I'm trying to write the following formula using multi time-frame. Plotting it on a 5 min chart, using 15 min data.

Code:
``````rec AccVol =  (AccVol+volume)/2;
plot MyVol = AccVol;``````

Thanks

try this
Code:
``````def agg = AggregationPeriod.fifteen;
def AccVol =  (AccVol + volume(period = agg)/2;
plot MyVol = AccVol;``````

but i think it will produce 3x the actual volume. on each 5min bar, it will add on the 15 minute volume.
i think your original code should add up the volume, ( if the /2 is removed).