# 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[1]+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[1]+volume)/2;
plot MyVol = AccVol;``````

Thanks

try this
Code:
``````def agg = AggregationPeriod.fifteen;
def AccVol =  (AccVol[1] + 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).
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[1]+volume)/2;
plot MyVol = AccVol;``````

Thanks

try this
Code:
``````def agg = AggregationPeriod.fifteen;
def AccVol =  (AccVol[1] + 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).

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