Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Please advise why I can't get the line shown on volume graph?!I think I fixed it. While at it tried to fold Pre-Market, 1H Market and Post-Market volumes added to the labels, must work Equity, if not with futures.
Code:# Box Volume Stats # Version 1.2 # Created by: Enigma # Created: 05/18/17 # Modified by: Surya Kiran C ## Included rVolume label and Changed length as input. ## Additionally Pre-Market, 1Hr Volume, AfterHour Volume labels are added. declare on_volume; input length = 30; input ShowDayAvg = yes; input ShowTodayVolume = yes; input ShowPercentOfDayAvg = yes; input UnusualVolumePercent = 200; input ShowBarAvg = yes; input ShowCurrentBar = yes; input PreMktVol = yes; input RTH1HrVol = yes; input PostMktVol = yes; def VolDayAvg = (fold index = 1 to length + 1 with Avg = 0 do (Avg + volume(period = "DAY")[index])) / length; def AvgBars = (fold index2 = 1 to length + 1 with Bar = 0 do (Bar + volume[index2])) / length; def Today = volume(period = "DAY"); def PercentOfDayAvg = Round((Today / VolDayAvg) * 100, 0); def CurVol = volume; def offset = 1; def ADV = Average(volume, length)[offset]; def rVol = volume / ADV; # Labels #if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if 1HrRTHVol then 1 else 0, AddLabel(ShowDayAvg, length + "Day Avg: " + Round(VolDayAvg, 0) + " ", Color.LIGHT_GRAY); AddLabel(ShowTodayVolume, "Today: " + Today + " ", (if PercentOfDayAvg >= UnusualVolumePercent then Color.GREEN else if PercentOfDayAvg >= 100 then Color.ORANGE else Color.LIGHT_GRAY)); AddLabel(ShowPercentOfDayAvg, PercentOfDayAvg + "%", (if PercentOfDayAvg >= UnusualVolumePercent then Color.GREEN else if PercentOfDayAvg >= 100 then Color.ORANGE else Color.WHITE) ); AddLabel(ShowBarAvg, "Avg" + length + "Bars: " + Round(AvgBars, 0) + " ", Color.LIGHT_GRAY); AddLabel(ShowCurrentBar, "Cur Bar: " + CurVol + " ", (if CurVol >= AvgBars then Color.GREEN else Color.ORANGE)); AddLabel(yes, "rVol :" + Round(rVol, 2)); #AddLabel(yes, "ADV :" + ADV); #AddLabel(yes, asPercent(rVol)); # remove "#" infront of Addlabels to select prefer choice #AssignPriceColor(if rVol >= 1 then color.dark_red else if rVol <=.5 then Color.black else color.Gray); #Pre, 1Hr RTH, AfterHours Volumes. ##if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if PreMktVol then 1 else 0 input PrestartTime = 0400; input PreendTime = 0929; def PreMkt = SecondsFromTime(PrestartTime) >= 0 and SecondsTillTime(PreendTime) >= 0; def PreVolMins = if PreMkt and !PreMkt[1] then volume else if PreMkt then PreVolMins[1] + volume else PreVolMins[1]; AddLabel(if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if PreMktVol then 1 else 0, "PreMktVol = " + PreVolMins + " ", Color.YELLOW); # End Volume PreMarket input RTH1HrstartTime = 0930; input RTH1HrendTime = 1029; def RTH1Hr = SecondsFromTime(RTH1HrstartTime) >= 0 and SecondsTillTime(RTH1HrendTime) >= 0; def RTH1HrMins = if RTH1Hr and !RTH1Hr[1] then volume else if RTH1Hr then RTH1HrMins[1] + volume else RTH1HrMins[1]; AddLabel(if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if RTH1HrVol then 1 else 0, "RTH1HrVol = " + RTH1HrMins + " ", Color.YELLOW); #End Volume RTH First 60 Mins input PoststartTime = 1600; input PostendTime = 1959; def PostMkt = SecondsFromTime(PoststartTime) >= 0 and SecondsTillTime(PostendTime) >= 0; def PostVolMins = if PostMkt and !PostMkt[1] then volume else if PostMkt then PostVolMins[1] + volume else PostVolMins[1]; AddLabel(if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if PostMktVol then 1 else 0, "PostMktVol = " + PostVolMins + " ", Color.YELLOW); # End Volume PostMarket
yeah i'm looking at it trying to figure it out@jngy2k did you see the thread i posted for you??
Yes, just like the volume metrics in the watchlist columns. I can only find labels for either pre market only or open to close.@Alex Total volume of today's session?
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.