Virtual Volume aka Volume Forecast For ThinkOrSwim

@Thanhly This is the only thing I could find.

Rich (BB code):
#hint: Virtual Volume   
# Mr.Script 
#Explanation - Virtual Volume analyzes up to the second volume and displays the anticipated volume quantity for the day.
•    Example  - 6.5 hours in a trading day or 390 minutes or 23,400 seconds.  If I check the volume for a stock and we are 33 minutes or 1980 seconds into the trading day and volume is 537,500. The formula would be (23,400 x 537,500) / 1980 = 6,352,272.727 Virtual Volume.

declare hide_on_daily;
declare on_volume;

input OpenTime = 0930;
input closeTime = 1600;
input length = 10;
input averageType = AverageType.EXPONENTIAL;
assert(Opentime < 1200, "Open Time must be less than 1200");
assert(closetime > 1200, "close Time must be greater than 1200");

def volumeavg = MovingAverage(averageType, volume(period = aggregationPeriod.DAY), length);

def hoursa = floor(closetime/100); 
def hoursb = floor(opentime/100);
def hoursc = absValue(12 - hoursb) + hoursa - 12;
def hoursd = hoursc * 60 * 60;
def mina = ((closetime - ((floor(closetime/100)) * 100)) * 60);
def minb = ((opentime - ((floor(opentime/100)) * 100)) * 60);

def secondsperday = absValue(hoursd - (minb - mina));

def secondsPassed = secondsFromTime(OpenTime);

def a = if secondsPassed >= 0 and secondspassed <= (closetime * 60 * 60) then secondspassed else 0;

rec b = CompoundValue(1, if IsNaN(a) then b[1] else a, a);
def day = getDay();
def month = getMonth();
def year = getYear();
def lastDay = getLastDay();
def lastmonth = getLastMonth();
def lastyear = getLastYear();
def isToday = if(day == lastDay and month == lastmonth and year == lastyear, 1, 0);

def d = if istoday then b else double.nan;

def h = if secondsPassed >= 0 and secondspassed <= (closetime * 60 * 60) and close == close(period = aggregationPeriod.DAY) then secondspassed else 0;

def vol = if istoday then volume else 0;

rec index = compoundValue(1, index[1] + vol, 0);
plot "Cumulative Volume" = if secondsPassed >= 0 and secondsFromTime(closetime) <= 0 and istoday then index else double.nan;

def j = "cumulative volume";

def k = highestall(j);

def l = if j == k then secondspassed else double.nan;

def m = highestall(l);

def n = (secondsperday * k) / m;

addLabel(yes, concat("Virtual Volume: ", round(n, 0)), if (n > volumeavg) then Color.GREEN else color.RED);

addLabel(yes, concat(concat(length, " Day's"), concat(" Volume Avg: ", round(volumeavg, 0))),  if (n < volumeavg) then Color.GREEN else color.RED);

# end study code ---
 
Last edited:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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