Net Dollar Volume

James2020

New member
Hi, I'm trying to track the net dollar volume of the previous 10 mins. The issue I'm running into is how to code it properly in ThinkScript. Does anyone know where I can find a code for this or how write the proper one?
 
Solution
@James2020 test this and verify that the output is what you want. This is aggregation-sensitive - meaning, it uses the last "x" amount of candles based on your user input. Currently, it is set to use the last 10 bars, so to see the net dollar volume of the last 10 mins you must use a 1 minute chart. Alternatively, you could change the input to "2" and use a 5 min chart.

I didn't include candles where the open is equal to the close. If you want that added to either the buying or selling dollar volume, specify which one you want it added to. Otherwise, it ignores those candles.

Code:
input barsback = 10;
def x = isnan(close[-barsback]);
def dv = close * volume;

addlabel(1,"net dv of past " + barsback + " bars",color.gray);

def bdv...

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

As long you don't use MTF aggregations, it will show the dollar volume traded during each individual price bar, be it the 1 min, 5 min, 10 min, 30 min, 1 hr, etc. charts.

Are you trading the 1 min chart but want to know the total dollar volume of the past 10 mins?
 
As long you don't use MTF aggregations, it will show the dollar volume traded during each individual price bar, be it the 1 min, 5 min, 10 min, 30 min, 1 hr, etc. charts.

Are you trading the 1 min chart but want to know the total dollar volume of the past 10 mins?
So a better way of explaining it may be like this....I would like to take a 10 min period of time and have the code add the dollar volume for the green candles, then add the dollar volume for the red candles, then subtract the red ones from the green ones for that time period. What I don't know is what ThinkScript uses for representing green and red candles in their coding.
 
@James2020 Green candles can be obtained by using def green = close > open; and red candles can be found using def red = close < open;. I'll see what I can do and will get back to you on this.
 
@James2020 test this and verify that the output is what you want. This is aggregation-sensitive - meaning, it uses the last "x" amount of candles based on your user input. Currently, it is set to use the last 10 bars, so to see the net dollar volume of the last 10 mins you must use a 1 minute chart. Alternatively, you could change the input to "2" and use a 5 min chart.

I didn't include candles where the open is equal to the close. If you want that added to either the buying or selling dollar volume, specify which one you want it added to. Otherwise, it ignores those candles.

Code:
input barsback = 10;
def x = isnan(close[-barsback]);
def dv = close * volume;

addlabel(1,"net dv of past " + barsback + " bars",color.gray);

def bdv = if x and close > open then bdv[1] + dv else bdv[1];
addlabel(1,"buying dv = " + bdv,color.green);

def sdv = if x and close < open then sdv[1] + dv else sdv[1];
addlabel(1,"selling dv = " + sdv,color.red);

def net = bdv - sdv;
addlabel(1,"net dv = " + net,color.cyan);
 
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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