Daily Sum of what, Volume...???
#Todays_Volume_Label
#Created 2020-09-09 by rad14733
#
input showTodaysVolumeLabel = yes;
def todaysVolume = volume(period = "DAY");
AddLabel(showTodaysVolumeLabel, "Todays Volume: " + todaysVolume, Color.WHITE);
declare lower;
input LookBack = 20;
def nMinutes = GetAggregationPeriod() / 60000;
def nBars = RoundUp(390 / nMinutes, 0);
def pvSum = fold idx = 1 to LookBack + 1 with a=0 do a + GetValue(volume, idx * nBars, LookBack * nBars);
def pvAvg = pvSum / LookBack;
def VolPct = (volume / pvAvg) * 100;
plot avgLine = 100;
avgLine.SetDefaultColor(Color.GRAY);
avgLine.SetStyle(Curve.LONG_DASH);
def lastUp = if IsNaN(lastUp[1]) then 0 else if (close > open) then VolPct else lastUp[1];
def lastDn = if IsNaN(lastDn[1]) then 0 else if (close < open) then VolPct else lastDn[1];
plot Vol = VolPct;
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.DefineColor("Bullish", Color.CYAN);
Vol.DefineColor("Bullish Smaller", CreateColor(0, 128, 128));
Vol.DefineColor("Bearish", Color.MAGENTA);
Vol.DefineColor("Bearish Smaller", CreateColor(128, 0, 128));
Vol.AssignValueColor(if (close > open) and (VolPct > lastUp[1]) then Vol.Color("bullish" ) else if close > open then Vol.Color("bullish smaller" ) else if close < open and VolPct > lastDn[1] then Vol.Color("bearish" ) else Vol.Color("bearish smaller" ));
Vol.SetLineWeight(3);
Not at my station with ToS, but perhaps something like this:@mashume you may be able to tell me if this is possible as well. Thank you!
def pvSum =
if SecondsFromTime(0930) >= 0 then
fold idx = 1 to LookBack + 1
with a=0
do a + GetValue(volume, idx * nBars, LookBack * nBars)
else
0;
Thanks for the help! I think this is going down the correct path.Not at my station with ToS, but perhaps something like this:
Code:def pvSum = if SecondsFromTime(0930) >= 0 then fold idx = 1 to LookBack + 1 with a=0 do a + GetValue(volume, idx * nBars, LookBack * nBars) else 0;
You don't, of course, need that much whitespace... it just makes it easier for me to think in a text editor.
-mashume
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
G | Calculate sum of formula values based on multiple aggregations and display this sum as label on daily chart? | Questions | 10 | |
R | Daily Volume Profile | Questions | 1 | |
B | Daily 20sma Watchlist | Questions | 1 | |
T | 20% Daily Move Scan | Questions | 0 | |
D | Daily High and/or Low = Open | Questions | 3 |
Start a new thread and receive assistance from our community.
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.
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.