netarchitech
Well-known member
# TS_BetterVolume_Indicator
# A better volume indicator with color coded histogram plot that shows 4 different colors depending on price action and volume.
# Yellow - Low volume for the size of the bar - Amateurs at work
# White - Climax down
# Blue -Climax up
# Red - Churn - Pros buying at lows or unloading at highs
# Magenta - Climax Churn - Pros taking profits at highs or lows
# Gray - Normal (default) Bar
Colors can be configured in the study customization window:
# A better volume indicator with color coded histogram plot that shows 4 different colors depending on price action and volume.
# Yellow - Low volume for the size of the bar - Amateurs at work
# White - Climax down
# Blue -Climax up
# Red - Churn - Pros buying at lows or unloading at highs
# Magenta - Climax Churn - Pros taking profits at highs or lows
# Gray - Normal (default) Bar
thinkScript Code
Rich (BB code):
#
#Better Volume for Thinkorswim
#
#
#hint: Verbatim translation of the TradeStation code from http://emini-watch.com/free-stuff/volume-indicator/
#==========================================================================
#DECLARATIONS
#==========================================================================
declare on_volume;
declare real_size;
#INPUTS
#==========================================================================
input iShowLowVol = YES;
input iShowClimaxUp = YES;
input iShowClimaxDown = YES;
input iShowChurn = YES;
input iShowClimaxChurn = YES;
input iUseTwoBars = {default "YES", "NO"};
input iLookback = 20;
#VARS
#==========================================================================
def vValue1;
def vValue2;
def vValue3;
def vValue4;
def vValue5;
def vValue6;
def vValue7;
def vValue8;
def vValue9;
def vValue10;
def vValue11;
def vValue12;
def vValue13;
def vValue14;
def vValue15;
def vValue16;
def vValue17;
def vValue18;
def vValue19;
def vValue20;
def vValue21;
def vValue22;
def vCondition1;
def vCondition2;
def vCondition3;
def vCondition4;
def vCondition5;
def vCondition6;
def vCondition7;
def vCondition8;
def vCondition9;
def vCondition10;
def vCondition11;
def vCondition12;
def vCondition13;
def vCondition14;
def vCondition15;
def vCondition16;
def vCondition17;
def vCondition18;
def vCondition19;
def vCondition20;
def vRange;
#LOGIC
#==========================================================================
vRange = high - low;
if close > open and vRange <> 0
then {vValue1 = (vRange/(2*vRange + open - close))*volume;
vValue2 = volume - vValue1;}
else if close < open and vRange <> 0
then {vValue1 = ((vRange + close - open)/(2*vRange + close - open))*volume;
vValue2 = volume - vValue1;}
else if close == open
then {vValue1 = 0.5*volume;
vValue2 = volume - vValue1;}
else {vValue1 = 0;
vValue2 = 0;}
vValue3 = AbsValue(vValue1 + vValue2);
vValue4 = vValue1*vRange;
vValue5 = (vValue1 - vValue2)*vRange;
vValue6 = vValue2*vRange;
vValue7 = (vValue2 - vValue1)*vRange;
if vRange <> 0
then {vValue8 = vValue1/vRange;
vValue9 = (vValue1 - vValue2)/vRange;
vValue10 = vValue2/vRange;
vValue11 = (vValue2 - vValue1)/vRange;
vValue12 = vValue3/vRange;}
else {vValue8 = 0;
vValue9 = 0;
vValue10 = 0;
vValue11 = 0;
vValue12 = 0;}
switch(iUseTwoBars)
{
case "YES":
vValue13 = vValue3 + vValue3[1];
vValue14 = (vValue1 + vValue1[1])*(Highest(high,2) - Lowest(low,2));
vValue15 = (vValue1 + vValue1[1] - vValue2 - vValue2[1])*(Highest(high,2) - Lowest(low,2));
vValue16 = (vValue2 + vValue2[1])*(Highest(high,2) - Lowest(low,2));
vValue17 = (vValue2 + vValue2[1] - vValue1 - vValue1[1])*(Highest(high,2) - Lowest(low,2));
if Highest(high,2) <> Lowest(low,2)
then {vValue18 = (vValue1 + vValue1[1])/(Highest(high,2) - Lowest(low,2));
vValue19 = (vValue1 + vValue1[1] - vValue2 - vValue2[1])/(Highest(high,2) - Lowest(low,2));
vValue20 = (vValue2 + vValue2[1])/(Highest(high,2) - Lowest(low,2));
vValue21 = (vValue2 + vValue2[1] - vValue1 - vValue1[1])/(Highest(high,2) - Lowest(low,2));
vValue22 = vValue13/(Highest(high,2) - Lowest(low,2));}
else {vValue18 = 0;
vValue19 = 0;
vValue20 = 0;
vValue21 = 0;
vValue22 = 0;}
vCondition1 = 0;
vCondition2 = 0;
vCondition3 = 0;
vCondition4 = 0;
vCondition5 = 0;
vCondition6 = 0;
vCondition7 = 0;
vCondition8 = 0;
vCondition9 = 0;
vCondition10 = 0;
vCondition11 = vValue13 == Lowest(vValue13, iLookback);
vCondition12 = vValue14 == Highest(vValue14, iLookback) and close > open and close[1] > open[1];
vCondition13 = vValue15 == Highest(vValue15, iLookback) and close > open and close[1] > open[1];
vCondition14 = vValue16 == Highest(vValue16, iLookback) and close < open and close[1] < open[1];
vCondition15 = vValue17 == Highest(vValue17, iLookback) and close < open and close[1] < open[1];
vCondition16 = vValue18 == Lowest(vValue18, iLookback) and close < open and close[1] < open[1];
vCondition17 = vValue19 == Lowest(vValue19, iLookback) and close < open and close[1] < open[1];
vCondition18 = vValue20 == Lowest(vValue20, iLookback) and close > open and close[1] > open[1];
vCondition19 = vValue21 == Lowest(vValue21, iLookback) and close > open and close[1] > open[1];
vCondition20 = vValue22 == Highest(vValue22, iLookback);
case "NO":
vValue13 = 0;
vValue14 = 0;
vValue15 = 0;
vValue16 = 0;
vValue17 = 0;
vValue18 = 0;
vValue19 = 0;
vValue20 = 0;
vValue21 = 0;
vValue22 = 0;
vCondition1 = vValue3 == Lowest(vValue3, iLookback);
vCondition2 = vValue4 == Highest(vValue4, iLookback) and close > open;
vCondition3 = vValue5 == Highest(vValue5, iLookback) and close > open;
vCondition4 = vValue6 == Highest(vValue6, iLookback) and close < open;
vCondition5 = vValue7 == Highest(vValue7, iLookback) and close < open;
vCondition6 = vValue8 == Lowest(vValue8, iLookback) and close < open;
vCondition7 = vValue9 == Lowest(vValue9, iLookback) and close < open;
vCondition8 = vValue10 == Lowest(vValue10, iLookback) and close > open;
vCondition9 = vValue11 == Lowest(vValue11, iLookback) and close > open;
vCondition10 = vValue12 == Highest(vValue12, iLookback);
vCondition11 = 0;
vCondition12 = 0;
vCondition13 = 0;
vCondition14 = 0;
vCondition15 = 0;
vCondition16 = 0;
vCondition17 = 0;
vCondition18 = 0;
vCondition19 = 0;
vCondition20 = 0;
}
#PLOTS
#==========================================================================
plot pBetterVolume = volume;
#PLOT STYLES & SETTINGS
#==========================================================================
pBetterVolume.DefineColor("LowVol", Color.YELLOW);
pBetterVolume.DefineColor("ClimaxUp", Color.RED);
pBetterVolume.DefineColor("ClimaxDown", Color.WHITE);
pBetterVolume.DefineColor("Churn", Color.BLUE);
pBetterVolume.DefineColor("ClimaxChurn", Color.MAGENTA);
pBetterVolume.DefineColor("Default", Color.CYAN);
pBetterVolume.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
pBetterVolume.AssignValueColor
(
if iShowLowVol and (vCondition1 or vCondition11) then pBetterVolume.Color("LowVol")
else if iShowClimaxUp and (vCondition2 or vCondition3 or vCondition8 or vCondition9 or vCondition12
or vCondition13 or vCondition18 or vCondition19)
then pBetterVolume.Color("ClimaxUp")
else if iShowClimaxDown and (vCondition4 or vCondition5 or vCondition6 or vCondition7 or vCondition14
or vCondition15 or vCondition16 or vCondition17)
then pBetterVolume.Color("ClimaxDown")
else if iShowChurn and (vCondition10 or vCondition20) then pBetterVolume.Color("Churn")
else if iShowClimaxChurn and (vCondition10 or vCondition20)
and (vCondition2 or vCondition3 or vCondition4 or vCondition5 or vCondition6
or vCondition7 or vCondition8 or vCondition9 or vCondition12
or vCondition13 or vCondition14 or vCondition15 or vCondition16
or vCondition17 or vCondition18 or vCondition19)
then pBetterVolume.Color("ClimaxChurn")
else pBetterVolume.Color("Default")
);
AssignPriceColor
(
if iShowLowVol and (vCondition1 or vCondition11) then pBetterVolume.Color("LowVol")
else if iShowClimaxUp and (vCondition2 or vCondition3 or vCondition8 or vCondition9 or vCondition12
or vCondition13 or vCondition18 or vCondition19)
then pBetterVolume.Color("ClimaxUp")
else if iShowClimaxDown and (vCondition4 or vCondition5 or vCondition6 or vCondition7 or vCondition14
or vCondition15 or vCondition16 or vCondition17)
then pBetterVolume.Color("ClimaxDown")
else if iShowChurn and (vCondition10 or vCondition20) then pBetterVolume.Color("Churn")
else if iShowClimaxChurn and (vCondition10 or vCondition20)
and (vCondition2 or vCondition3 or vCondition4 or vCondition5 or vCondition6
or vCondition7 or vCondition8 or vCondition9 or vCondition12
or vCondition13 or vCondition14 or vCondition15 or vCondition16
or vCondition17 or vCondition18 or vCondition19)
then pBetterVolume.Color("ClimaxChurn")
else pBetterVolume.Color("Default")
);
Colors can be configured in the study customization window:
Shareable Link
https://tos.mx/PDkQYF
Code:
Source: https://thinkscripter.com/
Credit: Fil @ analyticsfortraders.com
More Info: https://emini-watch.com/free-stuff/volume-indicator/
Better Volume_v3 by Mobius
Code:
#Hint: BetterVolume_v3 \n Shows volume and dbl average as well as Vol_Buzz \n VolBuzz is current bar volume vs the average volume for a relatively longer period = VolAvgPeriod \n The directional volume is the Net of Buy vs Sell avg vol for N = Length bars \n v3 adds informative labels with dynamic coloring & options in visualization - in V3 we switch to Barry Taylor's algo for directional volume calc \n RedK @ Live . com --- Mayl 2013
declare lower;
#declare zerobase;
input Length = 7;
input VolAvgPeriod = 50;
input Volume_Bias_Based_on = { default "Close_Price" , "Trend" }; ## this makes a difference only in few bars.. it's not used in any calc
input VolPlotMode= { default "Both", "Classic" , "Pressure" };
input ShowLabels = yes;
Input VxNetSmooth = 3;
def VolState;
switch (Volume_Bias_Based_on) {
case Trend:
VolState = if close > close[1] then 1 else if close == close [1] then 0 else -1;
default :
VolState = if close > open then 1 else if close == open then 0 else -1;
}
plot Vol = volume;
Vol.sethiding( VolPlotMode == VolPlotMode.Pressure);
plot VolSlowAvg = Average(volume, VolAvgPeriod);
plot VolFastAvg = WMA(volume, Length);
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.UPTICK);
Vol.DefineColor("Down", Color.DOWNTICK);
Vol.DefineColor("Doji", GetColor(8));
Vol.AssignValueColor(if VolState == 1 then Vol.Color("Up") else if VolState == -1 then Vol.Color("Down") else Vol.Color("Doji"));
VolSlowAvg.SetDefaultColor(color.blue);
VolFastAvg.SetDefaultColor(Color.orange); VolFastAvg.setStyle (curve.SHORT_DASH);
VolFastAvg.SetLineWeight(1);
def VolBuzz = Round((volume / VolSlowAvg * 100), 1);
def FastVRatio = Round((VolFastAvg / VolSlowAvg * 100), 1);
AddLabel(ShowLabels, "Vol_Buzz: " + VolBuzz + "%", if VolBuzz < 80 then Color.dark_orange else if VolBuzz > 120 then Color.GREEN else Color.Yellow) ;
## adding a volume Dx (Directional Index) calc .. similar to Elder's calc, but uses all volume compared to Avg Volume during Fast Length
# in V3, we change to use the algo in BetterVolume study originally developed by Barry Taylor at EminiWatch for TradeStation
# this algo is OK (though i believe not the best) , and signal is better than using the whole volume bar as up or down.
## v3.a - add a PressureCalc option to see either WMA or SUM of directional volume
input VolPressureCalc= { default "WAverage", "Sum" };
def Vx = if VolPressureCalc == VolPressureCalc.SUM then sum(volume,Length) else WMA(volume, Length) ;
def C = close; def O = Open; Def Range = High - low;
Def VolUp = If C > O and Range <> 0 then (Range/(2*Range+O-C))*Volume
else If C < O and Range <> 0 then ((Range+C-O)/(2*Range+C-O))*Volume
else 0.5*Volume;
def VolDn = Volume - VolUp;
def VxPlus = if VolPressureCalc == VolPressureCalc.SUM then sum (VolUp, Length) else WMA (VolUp, Length);
def VxMinus = if VolPressureCalc == VolPressureCalc.SUM then sum (VolDn, Length) else WMA (VolDn, Length);
def VxNetRaw = VXPlus-VXMinus ;
## Smooth with a very short zero-lag to eliminate outliers - Color the result
plot VxNet = 2 * WMA(VxNetRaw, VxNetSmooth) - WMA(WMA(VxNetRaw, VxNetSmooth),VxNetSmooth);
VxNet.DefineColor("PosUp", Color.GREEN);
VxNet.DefineColor("PosDn", Color.DARK_GREEN);
VxNet.DefineColor("NegDn", Color.RED);
VxNet.DefineColor("NegUp", Color.DARK_RED);
VxNet.AssignValueColor(if VxNet >= 0 then if VxNet > VxNet[1] then VxNet.color("PosUp") else VxNet.color("PosDn") else if VxNet < VxNet[1] then VxNet.color("NegDn") else VxNet.color("NegUp"));
VXNet.setlineWeight (3);
VxNet.sethiding(VolPlotMode == VolPlotMode.Classic);
## add volume pressure shade and the labels
def VxRatio = round(100 * VxNetRaw/VX,1);
def VxCloud = if VolPlotMode != VolPlotMode.Classic then VxNet else double.NaN ;
addcloud(VXCloud, 0);
AddLabel(ShowLabels, "FastVol: " + FastVRatio + "%", if FastVRatio > 100 then if VxRatio < 0 then Color.light_red else Color.GREEN else Color.orange) ;
AddLabel (ShowLabels ,"VxPlus: "+ round(VxPlus/VX*100,1)+"%", color.light_green);
AddLabel (ShowLabels , "VxMinus: "+ round(VxMinus/VX*100,1)+"%", color.Light_red);
AddLabel (ShowLabels , "VxNet: " + VxRatio + "%", if between(VxRatio, -10, 10) then color.yellow else if VxRatio >= 10 then color.green else color.dark_orange);
Attachments
Last edited: