Share Links
Those share links have an expiration date. So I avoid using them for material that is expected to have a long shelf life, such as this Q&A forum. At some point in the future, visitors to this post will find that share link you provided is invalid.
Details
The only reason I understood what you meant by “relative volume” is because I have seen you mention it in numerous other posts. Most who visit this post will not have a clue what “relative volume” means. So in the future, please be sure to use the full name of the study as it appears in Thinkorswim: “RelativeVolumeStDev”.
Intraday ONLY
This chart study is meant to plot only on an intraday time frame. No explanation is given as to how to interpret the various values that are displayed. So for the benefit of our audience I will at least take the time to explain how the values of each chart label are computed.
Extremely Limited Scope
The original study, as well as the modifications you requested have a very limited application. Since values are fixed, not based on a percent of current price/volume data. This chart study does not scale to lower or higher priced stocks. The values and color changes presented here: when plotting a $1 stock will be completely irrelevant when compared to the values plotted for a $1,000 stock. I do not like code that cannot scale across a wide variety of ticker symbols. How will the rest of our viewers understand which stocks this indicator can be applied to?
Explanation of Values
- Daily Avg: 30 period simple moving average of daily volume, excluding today’s daily volume.
- Today Volume: Total volume of the current trading day. (this excludes extended hours trade). No, extended hours trade data cannot be included in this figure.
- Unlabeled Percent Value: The percent of today’s volume (label 2) as compare to the 30 day average volume (label 1)
- Avg 30 Bars: 30 period simple moving average of volume at the current time frame selected for the chart.
- Current Bar Volume (Only Enter at 50k+ volume): The total volume of the current intraday bar. Changes to green when the volume of the bar exceeds 50k.
- RelativeVolumeStDev: Daily value of a built-in study named “RelativeVolumeStDev”. Changes color based on value, as described in the original question.
Here is the updated code:
declare lower;
#Inputs
input show30DayAvg = yes;
input showTodayVolume = yes;
input showPercentOf30DayAvg = yes;
input unusualVolumePercent = 200;
input show30BarAvg = yes;
input showCurrentBar = yes;
#RelativeVolumeStDev Inputs
input length = 60;
input allowNegativeValues = no;
def rawRelVol = (volume(period = "DAY") - Average(volume(period = "DAY"), length)) / StDev(volume(period = "DAY"), length);
def relVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
#Volume Data
def volLast30DayAvg = Average(volume(period = "DAY")[1], 30);
def today = volume(period = "DAY");
def percentOf30Day = Round((today / volLast30DayAvg) * 100, 0);
#def avg30Bars = VolumeAvg(30).VolAvg;
def avg30Bars = Average(volume[1], 30);
def curVolume = volume;
# Labels
AddLabel(show30DayAvg, "Daily Avg: " + Round(volLast30DayAvg, 0), Color.LIGHT_GRAY);
AddLabel(showTodayVolume, "Today Volume: " + today, (if volume > 1000000 then Color.RED else if volume > 100000 then Color.green else Color.LIGHT_GRAY));
AddLabel(showPercentOf30DayAvg, percentOf30Day + "%", (if percentOf30Day >= unusualVolumePercent then Color.GREEN else if percentOf30Day >= 100 then Color.ORANGE else Color.WHITE) );
AddLabel(show30BarAvg, "Avg 30 Bars: " + Round(avg30Bars, 0), Color.LIGHT_GRAY);
AddLabel(showCurrentBar, "Current Bar Volume (Only Enter at 50k+ volume): " + curVolume, (if curVolume >= 50000 then Color.GREEN else Color.red));
AddLabel(yes, Concat("RelativeVolumeStDev: ", relVol), if relVol > 2 then Color.GREEN else if relVol > 1 then Color.YELLOW else Color.GRAY);
Final Notes
There is no way to “fix” the N/A during extended hours. As explained above.
There are no plots with this study. So there is nothing to remove “from the left axis”.
Ok, but your original question was for two conditions with a third color left as implied:
From your post:
If the volumetoday is condition is greater than 1million, show the label as red
If the volumetoday is greater than 100k, show the label as green.
My solution does exactly that. So in order to modify it to these new conditions you will go to the solution I provide and locate this line of code:
AddLabel(showTodayVolume, “Today Volume: ” + today, (if volume > 1000000 then Color.RED else if volume > 100000 then Color.green else Color.LIGHT_GRAY));
And replace it with this line of code:
AddLabel(showTodayVolume, “Today Volume: ” + today, (if volume > 1000000 then Color.RED else if volume > 250000 and volume < 1000000 then Color.green else Color.LIGHT_GRAY));
The red label doesnt seem to be working with stocks over 1 million shares of volume. For example, check out EXPR.
It has 8mil volume at the time of this post but the box is still grey ?
Ah, you know what. That code displays daily volume in that label but the color changes are based on current volume of live intraday bar. That is based on the original source code. Here is how you modify that line to change color based on today’s daily volume:
AddLabel(showTodayVolume, “Today Volume: ” + today, (if today > 1000000 then Color.RED else if today > 250000 and today < 1000000 then Color.green else Color.LIGHT_GRAY));
awesome catch , its perfect