difference between the 1st minute and total volume.

westonsloan

New member
Plus
I am starting a new thread as my previous was unclear.
I am looking for assistance in creating labels.
The labels use, as part of their calculation, the running difference between the 1st minute volume of the trading day and the total of daily volume.

My final goal is two labels.

One that reads:
As of 9:31am:
1min volume (@9:31) * premarket volume/yesterday's daily volume

And another that states:
Currently:
(current daily volume - 1min volume) * premarket volume/yesterday's daily volume

Thank you for your consideration.


FYI, premarket volume is defined as the volume between: 4-9:30am
 
Last edited by a moderator:
I am starting a new thread as my previous was unclear.
I am looking for assistance in creating labels.
The labels use, as part of their calculation, the running difference between the 1st minute volume of the trading day and the total of daily volume.

My final goal is two labels.

One that reads:
As of 9:31am:
1min volume (@9:31) * premarket volume/yesterday's daily volume

And another that states:
Currently:
(current volume - 1min volume) * premarket volume/yesterday's daily volume

Thank you for your consideration.


FYI, premarket volume is defined as the volume between: 4-9:30am

sorry, still unclear,

"the running difference between the 1st minute volume of the trading day and the total of daily volume."

running difference, infers something is changing.
"between the 1st minute" infers to use just the 1st minute...
"total volume used from yesterday, does not change...
what is changing?


"1min volume (@9:31) * premarket volume/yesterday's daily volume"

what happens at minute 2?
0 ? add minute 1 to minute 2? just minute 2? keep minute 1?

------------------------------

take a look at this and see if it is close to what you are looking for


Code:
#vol_comp_firstbar

#https://usethinkscript.com/threads/difference-between-the-1st-minute-and-total-volume.19897/
#difference between the 1st minute and total volume.

#One that reads:
#As of 9:31am:
#1min volume (@9:31) * premarket volume/yesterday's daily volume

#And another that states:
#Currently:
#(current volume - 1min volume) * premarket volume/yesterday's daily volume

declare upper;

def v = volume;
def prestart = 0400;
def start = 0930;
def end = 1600;
def pre = if SecondsFromTime(prestart) >= 0 and SecondsTillTime(start) > 0 then 1 else 0;
def daytime = if SecondsFromTime(start) >= 0 and SecondsTillTime(end) > 0 then 1 else 0;

def startbar = (SecondsFromTime(start) == 0);
def endbar = (SecondsFromTime(end) == 0);

def d = GetDay();
def istoday = d == GetLastDay();


def vol_yest = if istoday then vol_yest[1]
 else if daytime and !daytime[1] then v
 else if daytime then v + vol_yest[1]
 else vol_yest[1];

def vol_pre = if pre and !pre[1] then v
 else if pre then v + vol_pre[1]
 else vol_pre[1];

def vol_bar1 = if (SecondsFromTime(0931) == 0) then v else vol_bar1[1];


#1min volume (@9:31) * premarket volume/yesterday's daily volume
def vol_ratio1 = vol_bar1 * vol_pre / vol_yest;
AddLabel(1, "  ", Color.BLACK);
AddLabel(1, "volume ratio1:  " + vol_ratio1, Color.YELLOW);

#(current volume - 1min volume) * premarket volume/yesterday's daily volume
def vol_ratio2 = (v - vol_bar1) * vol_pre / vol_yest;
AddLabel(1, "  ", Color.BLACK);
AddLabel(1, "volume ratio2:  " + vol_ratio2, Color.YELLOW);
AddLabel(1, "  ", Color.BLACK);

input test1 = no;
AddChartBubble(test1, low,
 v + "  vol\n" +
 vol_bar1 + "  1st\n" +
 vol_pre + "  pre\n" +
 vol_yest + "  yest\n" 
, Color.YELLOW, no);
#
 
Code:
declare lower;
def Pre =
    SecondsFromTime(0400) >= 0
    and SecondsTillTime(0930) > 0;
def Reg =
    SecondsFromTime(0930) >= 0
    and SecondsTillTime(1600) > 0;
def NewReg =
    (Reg and !Reg[1])
    or (Reg and GetDay() != GetDay()[1]);
def RegVol =
    if NewReg then Volume
    else if Reg then RegVol[1] + Volume
    else RegVol[1];
def YesterRegVol =
    if NewReg then RegVol[1]
    else YesterRegVol[1];
def NewPre =
    Pre and !Pre[1];
def PreCheck =
    if NewReg then 1
    else if NewPre then 2
    else PreCheck[1];
def NoPre =
    newReg and PreCheck[1] == 1;
def PreVol =
    if NoPre then 0
    else if NewPre then Volume
    else if Pre then PreVol[1] + Volume
    else PreVol[1];
def FirstMin =
    if NewReg then Volume
    else FIrstMin[1];
def LAB1 =
    FirstMin * PreVol / RegVol;
def LAB2 =
    (RegVol - FirstMin) * (PreVol / YesterRegVol);
addlabel(yes," " + LAB1 + " ",createColor(0,0,50));
addlabel(yes," " + LAB2 + " ",createColor(0,0,50));
addlabel(!Reg," Market Closed ",createColor(20,0,0));


#debug
plot a = regvol;
plot b = YesterRegVol;
b.setpaintingStrategy(12);
plot c = PreVol;
plot d = firstmin;
addverticalLine(newPre,"Pre",color.blue);
addlabel(!PreVol," No Pre-Market Volume ",createColor(20,0,0));
addverticalLine(
    newReg or NoPre,
    if NoPRe then "No Pre" else "Reg",
    if noPRe then color.dark_Red else color.black
);
 
sorry, still unclear,

"the running difference between the 1st minute volume of the trading day and the total of daily volume."

running difference, infers something is changing.
"between the 1st minute" infers to use just the 1st minute...
"total volume used from yesterday, does not change...
what is changing?


"1min volume (@9:31) * premarket volume/yesterday's daily volume"

what happens at minute 2?
0 ? add minute 1 to minute 2? just minute 2? keep minute 1?

------------------------------

take a look at this and see if it is close to what you are looking for


Code:
#vol_comp_firstbar

#https://usethinkscript.com/threads/difference-between-the-1st-minute-and-total-volume.19897/
#difference between the 1st minute and total volume.

#One that reads:
#As of 9:31am:
#1min volume (@9:31) * premarket volume/yesterday's daily volume

#And another that states:
#Currently:
#(current volume - 1min volume) * premarket volume/yesterday's daily volume

declare upper;

def v = volume;
def prestart = 0400;
def start = 0930;
def end = 1600;
def pre = if SecondsFromTime(prestart) >= 0 and SecondsTillTime(start) > 0 then 1 else 0;
def daytime = if SecondsFromTime(start) >= 0 and SecondsTillTime(end) > 0 then 1 else 0;

def startbar = (SecondsFromTime(start) == 0);
def endbar = (SecondsFromTime(end) == 0);

def d = GetDay();
def istoday = d == GetLastDay();


def vol_yest = if istoday then vol_yest[1]
 else if daytime and !daytime[1] then v
 else if daytime then v + vol_yest[1]
 else vol_yest[1];

def vol_pre = if pre and !pre[1] then v
 else if pre then v + vol_pre[1]
 else vol_pre[1];

def vol_bar1 = if (SecondsFromTime(0931) == 0) then v else vol_bar1[1];


#1min volume (@9:31) * premarket volume/yesterday's daily volume
def vol_ratio1 = vol_bar1 * vol_pre / vol_yest;
AddLabel(1, "  ", Color.BLACK);
AddLabel(1, "volume ratio1:  " + vol_ratio1, Color.YELLOW);

#(current volume - 1min volume) * premarket volume/yesterday's daily volume
def vol_ratio2 = (v - vol_bar1) * vol_pre / vol_yest;
AddLabel(1, "  ", Color.BLACK);
AddLabel(1, "volume ratio2:  " + vol_ratio2, Color.YELLOW);
AddLabel(1, "  ", Color.BLACK);

input test1 = no;
AddChartBubble(test1, low,
 v + "  vol\n" +
 vol_bar1 + "  1st\n" +
 vol_pre + "  pre\n" +
 vol_yest + "  yest\n"
, Color.YELLOW, no);
#
Much appreciated. I will analyze how this code performs at market open tomorrow. I am grateful for a response. And I am laughing with humility in this coffee shop that my previous thread had to be removed for being so all over the place... yet, the team behind usethinkscript is still helping me. That goes a long way and I completed understand why y'all did that. I will be more concise with future posts. The value here is incredible.

Of course I used an AI chatbot to help me out with the code -- in my brain are two tiny ants clashing cymbals together when it comes to writing code from scratch (even though I've been working in tech for 6 years now -- I must stand on the shoulders of giants to get to where I need to go XD @useThinkScript

Thank you! @halcyonguy
 
Code:
declare lower;
def Pre =
    SecondsFromTime(0400) >= 0
    and SecondsTillTime(0930) > 0;
def Reg =
    SecondsFromTime(0930) >= 0
    and SecondsTillTime(1600) > 0;
def NewReg =
    (Reg and !Reg[1])
    or (Reg and GetDay() != GetDay()[1]);
def RegVol =
    if NewReg then Volume
    else if Reg then RegVol[1] + Volume
    else RegVol[1];
def YesterRegVol =
    if NewReg then RegVol[1]
    else YesterRegVol[1];
def NewPre =
    Pre and !Pre[1];
def PreCheck =
    if NewReg then 1
    else if NewPre then 2
    else PreCheck[1];
def NoPre =
    newReg and PreCheck[1] == 1;
def PreVol =
    if NoPre then 0
    else if NewPre then Volume
    else if Pre then PreVol[1] + Volume
    else PreVol[1];
def FirstMin =
    if NewReg then Volume
    else FIrstMin[1];
def LAB1 =
    FirstMin * PreVol / RegVol;
def LAB2 =
    (RegVol - FirstMin) * (PreVol / YesterRegVol);
addlabel(yes," " + LAB1 + " ",createColor(0,0,50));
addlabel(yes," " + LAB2 + " ",createColor(0,0,50));
addlabel(!Reg," Market Closed ",createColor(20,0,0));


#debug
plot a = regvol;
plot b = YesterRegVol;
b.setpaintingStrategy(12);
plot c = PreVol;
plot d = firstmin;
addverticalLine(newPre,"Pre",color.blue);
addlabel(!PreVol," No Pre-Market Volume ",createColor(20,0,0));
addverticalLine(
    newReg or NoPre,
    if NoPRe then "No Pre" else "Reg",
    if noPRe then color.dark_Red else color.black
);
I'll also try this one out at market open tomorrow -- and see the results of that in my scanner -- much appreciated that I got a response on this! @Joshua
 

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
472 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