Buy / Sell Volume RoC For ThinkOrSwim

*8-6-2021 Updated main post to clean up and accurately reflect the current model being used
=====================================================

This is my version of Volume
Volume, I believe is one of the most important indicators, though sometimes just looking at a regular volume chart can still leave one scratching their head as to what it's saying.
Hopefully this helps

It takes into account the buying and selling of the last 5 and or 10 bars along with the current bar

Based on my own secret math formula (Which if you look at the code, it won't be a secret but you may get a headache)

Can't say I'm the best coder and there probably was an easier way to do it...anyhow

I can see some great potential in using this along with some other indicators (Buy The Dip perhaps) /Price action as additional conformation

If anyone has any improvements they would like to make, by all means...

The main code has been updated in post #1 to reflect those changes

ioNJT4F.png


Option to show "Hot Volume" arrows now included

3vCol1i.png



Goodluck

Main indicator without RSI Laguerre

10-13-2021 ===added buy line

Code:
#Red_Green_Multi_Bar Buy_Sell Stats_v2
#Parts derived from Horseriders "Volume Buy Sell Indicator with Hot Percent for ThinkorSwim"
#declare zerobase;
#===08-06-2021 Updated to make it easier to switch inputs.====== Added "Hot Volume" to Multibar
#===10-13-2021===   Added "Buy/Sell Line


declare lower;

#Inputs


input ShowTodayVolumeLabel =  yes;
input UnusualVolumePercentLabel = 200;
input ShowCurrentBarLabel = yes;
input ShowSellVolumePercentLabel = yes;
input ShowHotVolumeArrows = yes;
input ShowVol = no;
input ShowMultiBarVol5 = yes;
input ShowMultiBarVol10 = yes;
input ShowAllMultiBar = yes;
input ShowBuy_SellLine = yes;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def buying = V * (C - L) / (H - L);
def selling = V * (H - C) / (H - L);

# Selling Volume

plot BuyVol = if ShowVol then (buying) else Double.NaN;
BuyVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BuyVol.SetDefaultColor(Color.DARK_GREEN);
BuyVol.HideTitle();
BuyVol.HideBubble();
BuyVol.SetLineWeight(5);

plot SellVol = if ShowVol then selling else Double.NaN;
SellVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
SellVol.SetDefaultColor(Color.DARK_RED);
SellVol.HideTitle();
SellVol.HideBubble();
SellVol.SetLineWeight(5);

# Total Volume

# Note that Selling + Buying Volume = Volume.
plot TV = if ShowVol then volume else Double.NaN;
TV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
TV.SetDefaultColor(Color.DARK_GRAY);
TV.HideTitle();
TV.HideBubble();
TV.SetLineWeight(1);
#Volume Data
def today = volume(period = "DAY");
def avg30Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10] + volume[11] + volume[12] + volume[13] + volume[14] + volume[15] + volume[16] + volume[17] + volume[18] + volume[19] + volume[20] + volume[21] + volume[22] + volume[23] + volume[24] + volume[25] + volume[26] + volume[27] + volume[28] + volume[29] + volume[30]) / 30;
def curVolume = volume;
def percentOf30Bar = Round((curVolume / avg30Bars) * 100, 0);
def SellVolPercent = Round((selling / volume) * 100, 0);


#-------------------------------------------------------------------------


#Buy/sell difference================================
def buy1 = buying + buying[1];
def buy2 = buying + buying[1] + buying[2];
def buy3 = buying + buying[1] + buying[2] + buying[3];
def buy4 = buying + buying[1] + buying[2] + buying[3] + buying[4];
def buy5 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5];
def buy6 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6];
def buy7 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7];
def buy8 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8];
def buy9 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8] + buying[9];
def buy10 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8] + buying[9] + buying[10];

def curbuyvol3 = (buy1 + buy2 + buy3) / 3;
def curbuyVolume5 = (buy1 + buy2 + buy3 + buy4 + buy5) / 5;
def curbuyvol10 = (buy1 + buy2 + buy3 + buy4 + buy5 + buy6 + buy7 + buy8 + buy9 + buy10) / 10;


def sell1 = selling + selling[1];
def sell2 = selling + selling[1] + selling[2];
def sell3 = selling + selling[1] + selling[2] + selling[3];
def sell4 = selling + selling[1] + selling[2] + selling[3] + selling[4];
def sell5 = selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5];
def sell6 = selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5] + selling[6];
def sell7 = selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5] + selling[6] + selling[7];
def sell8 = selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5] + selling[6] + selling[7] + selling[8];
def sell9 = selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5] + selling[6] + selling[7] + selling[8] + selling[9];
def sell10 = selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5] + selling[6] + selling[7] + selling[8] + selling[9] + selling[10];

def cursellvol3 = (sell1 + sell2 + sell3) / 3;
def cursellVolume5 = (sell1 + sell2 + sell3 + sell4 + sell5) / 5;
def cursellvol10 = (sell1 + sell2 + sell3 + sell4 + sell5 + sell6 + sell7 + sell8 + sell9 + sell10) / 10;

def SellBuyDiff3 = (curbuyvol3 - cursellvol3);
def Sellbuydiff5 = (curbuyVolume5 - cursellVolume5);
def Sellbuydiff10 = (curbuyvol10 - cursellvol10);





#MultiBar plots===========================================



plot V5 = if ShowMultiBarVol5 and ShowAllMultiBar and !ShowVol then (Sellbuydiff5) else Double.NaN;
V5.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#V2.SetDefaultColor(Color.DARK_GREEN);
V5.HideTitle();
V5.HideBubble();
V5.SetLineWeight(1);
V5.AssignValueColor(if curbuyVolume5 > cursellVolume5 then CreateColor(33, 145, 72) else if curbuyVolume5 < cursellVolume5  then CreateColor(175, 17, 24) else Color.DARK_GRAY );

plot V10 = if ShowMultiBarVol10 and ShowAllMultiBar and !ShowVol then (Sellbuydiff10) else Double.NaN;
V10.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#V2.SetDefaultColor(Color.DARK_GREEN);
V10.HideTitle();
V10.HideBubble();
V10.SetLineWeight(5);
V10.AssignValueColor(if curbuyvol10 > cursellvol10 then CreateColor(13, 91, 40) else if curbuyvol10 < cursellvol10  then CreateColor(112, 12, 17) else Color.DARK_GRAY );

#addcloud(curbuyVolume5, cursellVolume5, color.DARK_GREEN, color.DARK_RED);

input length = 20;
#plot VolAvg = Average(volume, length);

#VolAvg.SetDefaultColor(GetColor(7));

def BV = SellVolPercent is less than 30;
def SV = SellVolPercent is greater than 70;

def GreatPercent500 = percentOf30Bar > 500;
def GreatPercent250 = percentOf30Bar > 250;


# hiVolume indicator
# source: http://tinboot.blogspot.com
# author: allen everhart


input type = { default SMP, EXP } ;
input length1 = 20 ;
input hotPct = 100.0 ;

def ma =
if type == type.SMP then
SimpleMovingAvg(volume, length)
else
MovAvgExponential(volume, length);

#plot hv =
#if 100 * ((volume / ma) - 1) >= hotPct then

plot hvBuy250 =
if ShowVol and GreatPercent250 and BV and ShowHotVolumeArrows or ShowAllMultiBar and GreatPercent250 and BV and ShowHotVolumeArrows then ma else Double.NaN;
hvBuy250.SetDefaultColor(CreateColor(39, 84, 130));
hvBuy250.SetLineWeight(1) ;
hvBuy250.SetPaintingStrategy( PaintingStrategy.ARROW_UP);

plot hvBuy500 =
if ShowVol and GreatPercent500 and BV and ShowHotVolumeArrows or ShowAllMultiBar and GreatPercent250 and BV and ShowHotVolumeArrows  then ma else Double.NaN;
hvBuy500.SetDefaultColor(CreateColor(29, 24, 120));
hvBuy500.SetLineWeight(2) ;
hvBuy500.SetPaintingStrategy( PaintingStrategy.ARROW_UP);

plot hvSell250 =
if ShowVol and GreatPercent250 and SV and ShowHotVolumeArrows or ShowAllMultiBar and GreatPercent250 and SV and ShowHotVolumeArrows then ma else Double.NaN;
hvSell250.SetDefaultColor(CreateColor(133, 28, 38));
hvSell250.SetLineWeight(1) ;
hvSell250.SetPaintingStrategy( PaintingStrategy.ARROW_DOWN);

plot hvSell500 =
if ShowVol and GreatPercent500 and SV and ShowHotVolumeArrows or ShowAllMultiBar and GreatPercent250 and SV and ShowHotVolumeArrows then ma else Double.NaN;
hvSell500.SetDefaultColor(CreateColor(133, 58, 58));
hvSell500.SetLineWeight(2) ;
hvSell500.SetPaintingStrategy( PaintingStrategy.BOOLEAN_ARROW_DOWN);



#==========================

#def PercentBuy_Sell = if curbuyVolume > cursellVolume then Round((curbuyVolume / cursellVolume))  *100 else round((cursellVolume / curbuyVolume))  *100 ;

#def DiffBuy_Sell = if curbuyVolume5 > cursellVolume5 then Round((curbuyVolume5 - cursellVolume5))  else round((cursellVolume5 - curbuyVolume5));

#def PercentBuy_Sell = if curbuyVolume5 > cursellVolume5 then Round((diffBuy_Sell / cursellVolume5))  *100 else round((diffBuy_Sell / curbuyVolume5))  *100 ;



# Labels================================================================
AddLabel(ShowCurrentBarLabel, "Past Bar: " + curVolume[1], (if percentOf30Bar[1] >= UnusualVolumePercentLabel then Color.DARK_GREEN else if percentOf30Bar[1] >= 100 then CreateColor(110, 75, 110) else Color.DARK_GRAY));

AddLabel(ShowCurrentBarLabel, "Cur Bar: " + curVolume, (if percentOf30Bar >= UnusualVolumePercentLabel then Color.DARK_GREEN else if percentOf30Bar >= 100 then CreateColor(110, 75, 110) else Color.DARK_GRAY));

#AddLabel(ShowSellVolumePercentLabel, "Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 70 then Color.DARK_RED else if SellVolPercent < 30 then Color.DARK_GREEN else Color.DARK_GRAY));


#AddLabel(yes, if curbuyVolume5 > cursellVolume5 then "5-Period Buying" else if curbuyVolume5 < cursellVolume5 then "5 Period Selling" else "", if curbuyVolume5 > cursellVolume5 then Color.DARK_GREEN else if curbuyVolume5 < cursellVolume5 then Color.DARK_RED else Color.DARK_GRAY);

#AddLabel(yes, if curbuyvol10 > cursellvol10 then "10-Period Buying" else if curbuyvol10 < cursellvol10 then "10 Period Selling" else "", if curbuyvol10 > cursellvol10 then Color.DARK_GREEN else if curbuyvol10 < cursellvol10 then Color.DARK_RED else Color.DARK_GRAY);

AddLabel(ShowSellVolumePercentLabel, " Past Sell %: " + SellVolPercent[1], (if SellVolPercent[1] > 70 then CreateColor(117, 42, 44) else if SellVolPercent[1] < 30 then Color.DARK_GREEN else Color.DARK_GRAY));

AddLabel(ShowSellVolumePercentLabel, " Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 70 then CreateColor(117, 42, 44) else if SellVolPercent < 30 then Color.DARK_GREEN else Color.DARK_GRAY));



AddLabel(yes, if BV then " ****-BUYING-**** " else if SV then " ****-SELLING-**** " else " ", if BV then CreateColor(39, 84, 130) else if SV then (CreateColor(122, 10, 12)) else Color.DARK_GRAY);

#AddLabel(yes,  sellbuydiff5 + "");

#addlabel(yes, if curbuyVolume5 > cursellVolume5 and curbuyvol10 > cursellvol10 then "buy" else "");
input price = close;
input length12 = 9;
input displace = 0;
input showBreakoutSignals = no;

def zero = 0;
plot zer0 = zero;
Zer0.setdefaultColor(color.DARK_GRAY);

def Buyline = ExpAverage(sellbuydiff5[-displace], length12) ;

plot BVLine = (if showbuy_SellLine then Buyline else double.NaN);
BVLine.assignValueColor(if buyline > 0 then createColor(63,162,128) else color.DARK_ORANGE);
BVLine.SetLineWeight(3);


#def Buyline = ExpAverage(curbuyVolume5[-displace], length12) ;
#def SellLine = ExpAverage(cursellVolume5[-displace], length12) ;
#plot BVLine = Buyline;
#BVLine.AssignValueColor(if curbuyVolume5 > curbuyVolume5[1] and curbuyVolume5 > cursellVolume5[1] then Color.DARK_GREEN else if curbuyVolume5 < curbuyVolume5[1] and curbuyVolume5[1] < cursellVolume5[1] then Color.LIGHT_RED else Color.DARK_GRAY);
#BVLine.SetLineWeight(4);

#plot SVLine = SellLine;
#SVLine.AssignValueColor(if cursellVolume5 > cursellVolume5[1] and cursellVolume5 > curbuyVolume5[1] then Color.DARK_RED else if cursellVolume5 < cursellVolume5[1] and cursellVolume5 < curbuyVolume5[1] then Color.GREEN else Color.DARK_ORANGE);

#addcloud( buyline,sellline, color.GREEN, color.LIGHT_RED);



*Volume w/ RSI Laguerre FE code.....

Code:
#Red_Green_Multi_Bar Buy_Sell w/FE v1
#Parts derived from Horseriders "Volume Buy Sell Indicator with Hot Percent for ThinkorSwim"
#declare zerobase;
#===08-06-2021 Updated to make it easier to switch inputs.====== Added "Hot Volume" to Multibar
#===10-13-2021===   Added "Buy/Sell Line...Imported Rsi Laguerre
 
#======WITH===========

# RSI-Laguerre Self Adjusting With Fractal Energy Gaussian Price Filter
# Mobius
# V01.12.2016
# Both Fractal Energy and RSI are plotted. RSI in cyan and FE in yellow. Look for trend exhaustion in the FE and a reversal of RSI or Price compression in FE and an RSI reversal.

declare lower;

#Inputs:
input ShowTodayVolumeLabel =  yes;
input UnusualVolumePercentLabel = 200;
input ShowCurrentBarLabel = yes;
input ShowSellVolumePercentLabel = yes;
input ShowHotVolumeArrows = yes;
input ShowVol = no;
input ShowMultiBarVol5 = yes;
input ShowMultiBarVol10 = yes;
input ShowAllMultiBar = yes;
input ShowBuy_SellLine = yes;
input nFE = 8;#hint nFE: length for Fractal Energy calculation.
input AlertOn = yes;
input Glength  = 12;
input betaDev =  6;
input data = close;
input LaguerreOn = yes;
input showTargetLabel = yes;
input showGammaLabel = yes;
input NA = double.NaN;



def w = (2 * Double.Pi / Glength );
def beta = (1 - Cos(w)) / (Power(1.414, 2.0 / betaDev) - 1 );
def alpha = (-beta + Sqrt(beta * beta + 2 * beta));
def Go = Power(alpha, 4) * open +
             4 * (1 – alpha) * Go[1] – 6 * Power( 1 - alpha, 2 ) * Go[2] +
             4 * Power( 1 - alpha, 3 ) * Go[3] - Power( 1 - alpha, 4 ) * Go[4];
def Gh = Power(alpha, 4) * high +
             4 * (1 – alpha) * Gh[1] – 6 * Power( 1 - alpha, 2 ) * Gh[2] +
             4 * Power( 1 - alpha, 3 ) * Gh[3] - Power( 1 - alpha, 4 ) * Gh[4];
def Gl = Power(alpha, 4) * low +
             4 * (1 – alpha) * Gl[1] – 6 * Power( 1 - alpha, 2 ) * Gl[2] +
             4 * Power( 1 - alpha, 3 ) * Gl[3] - Power( 1 - alpha, 4 ) * Gl[4];
def Gc = Power(alpha, 4) * data +
             4 * (1 – alpha) * Gc[1] – 6 * Power( 1 - alpha, 2 ) * Gc[2] +
             4 * Power( 1 - alpha, 3 ) * Gc[3] - Power( 1 - alpha, 4 ) * Gc[4];
# Variables:
def o;
def h;
def l;
def c;
def CU1;
def CU2;
def CU;
def CD1;
def CD2;
def CD;
def L0;
def L1;
def L2;
def L3;
plot RSI;

plot gamma = if LaguerreOn  then Log(Sum((Max(Gh, Gc[1]) - Min(Gl, Gc[1])), nFE) /
        (Highest(gh, nFE) - Lowest(Gl, nFE)))
            / Log(nFE) else na;


L0 = (1 – gamma) * Gc + gamma * L0[1];
L1 = -gamma * L0 + L0[1] + gamma * L1[1];
L2 = -gamma * L1 + L1[1] + gamma * L2[1];
L3 = -gamma * L2 + L2[1] + gamma * L3[1];
if L0 >= L1
then {
    CU1 = L0 - L1;
    CD1 = 0;
} else {
    CD1 = L1 - L0;
    CU1 = 0;
}
if L1 >= L2
then {
    CU2 = CU1 + L1 - L2;
    CD2 = CD1;
} else {
    CD2 = CD1 + L2 - L1;
    CU2 = CU1;
}
if L2 >= L3
then {
    CU = CU2 + L2 - L3;
    CD = CD2;
} else {
    CU = CU2;
    CD = CD2 + L3 - L2;
}


# Calculations
o = (Go + Gc[1]) / 2;
h = Max(Gh, Gc[1]);
l = Min(Gl, Gc[1]);
c = (o + h + l + Gc) / 4;

RSI = if LaguerreOn then if CU + CD <> 0 then CU / (CU + CD) else 0 else na;
RSI.SetDefaultColor(Color.Cyan);

def FEh = if isNaN(c) then double.nan else .65; #.618

def FEl = if isNaN(c) then double.nan else .382;

def gammaCons = gamma > feh;
def gammaExh = gamma <  fel;

gamma.SetDefaultColor(color.DARK_GRAY);
gamma.SetLineWeight(2);
gamma.SetpaintingStrategy(paintingStrategy.BOOLEAN_POINTS);
gamma.assignValueColor(if gammacons then color.DARK_ORANGE else if gammaexh then createColor(72,84,111) else color.BLACK);

#Alert(AlertOn and RSI crosses below .9, "", Alert.BAR, Sound.Bell);
#Alert(AlertOn and RSI crosses above .1, "", Alert.BAR, Sound.Bell);

# End Code RSI_Laguerre Self Adjusting with Fractal Energy



def rsigreen = RSI > RSI[1] and RSI[1] > RSI [2] and rsi > .20;
def rsired = RSI < RSI[1] and RSI[1] < RSI [2] and rsi < .80;

RSI.DefineColor("Up", CreateColor( 0,  220, 0));
RSI.DefineColor("Down",  Color.DARK_RED);
RSI.SetLineWeight(4);
RSI.AssignValueColor(if rsigreen  then CreateColor(13, 91, 40) else if rsi > .80 and !rsigreen then CreateColor(33, 145, 72) else if rsired  then CreateColor(112, 12, 17) else if rsi < .20 and !rsired then CreateColor(175, 17, 24) else color.BLACK);


def O_V = open;
def H_V = high;
def C_V = close;
def L_V = low;
def V = volume;
def buying = V * (C_V - L_V) / (H_V - L_V);
def selling = V * (H_V - C_V) / (H_V - L_V);

# Selling Volume

plot BuyVol = if ShowVol then (buying) else Double.NaN;
BuyVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BuyVol.SetDefaultColor(Color.DARK_GREEN);
BuyVol.HideTitle();
BuyVol.HideBubble();
BuyVol.SetLineWeight(5);

plot SellVol = if ShowVol then selling else Double.NaN;
SellVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
SellVol.SetDefaultColor(Color.DARK_RED);
SellVol.HideTitle();
SellVol.HideBubble();
SellVol.SetLineWeight(5);

# Total Volume

# Note that Selling + Buying Volume = Volume.
plot TV = if ShowVol then volume else Double.NaN;
TV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
TV.SetDefaultColor(Color.DARK_GRAY);
TV.HideTitle();
TV.HideBubble();
TV.SetLineWeight(1);
#Volume Data
def today = volume(period = "DAY");
def avg30Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10] + volume[11] + volume[12] + volume[13] + volume[14] + volume[15] + volume[16] + volume[17] + volume[18] + volume[19] + volume[20] + volume[21] + volume[22] + volume[23] + volume[24] + volume[25] + volume[26] + volume[27] + volume[28] + volume[29] + volume[30]) / 30;
def curVolume = volume;
def percentOf30Bar = Round((curVolume / avg30Bars) * 100, 0);
def SellVolPercent = Round((selling / volume) * 100, 0);


#-------------------------------------------------------------------------


#Buy/sell difference================================
def buy1 = buying + buying[1];
def buy2 = buying + buying[1] + buying[2];
def buy3 = buying + buying[1] + buying[2] + buying[3];
def buy4 = buying + buying[1] + buying[2] + buying[3] + buying[4];
def buy5 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5];
def buy6 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6];
def buy7 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7];
def buy8 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8];
def buy9 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8] + buying[9];
def buy10 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8] + buying[9] + buying[10];

def curbuyvol3 = (buy1 + buy2 + buy3) / 3;
def curbuyVolume5 = (buy1 + buy2 + buy3 + buy4 + buy5) / 5;
def curbuyvol10 = (buy1 + buy2 + buy3 + buy4 + buy5 + buy6 + buy7 + buy8 + buy9 + buy10) / 10;


def sell1 = selling + selling[1];
def sell2 = selling + selling[1] + selling[2];
def sell3 = selling + selling[1] + selling[2] + selling[3];
def sell4 = selling + selling[1] + selling[2] + selling[3] + selling[4];
def sell5 = selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5];
def sell6 = selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5] + selling[6];
def sell7 = selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5] + selling[6] + selling[7];
def sell8 = selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5] + selling[6] + selling[7] + selling[8];
def sell9 = selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5] + selling[6] + selling[7] + selling[8] + selling[9];
def sell10 = selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5] + selling[6] + selling[7] + selling[8] + selling[9] + selling[10];

def cursellvol3 = (sell1 + sell2 + sell3) / 3;
def cursellVolume5 = (sell1 + sell2 + sell3 + sell4 + sell5) / 5;
def cursellvol10 = (sell1 + sell2 + sell3 + sell4 + sell5 + sell6 + sell7 + sell8 + sell9 + sell10) / 10;

def SellBuyDiff3 = (curbuyvol3 - cursellvol3);
def Sellbuydiff5 = (curbuyVolume5 - cursellVolume5);
def Sellbuydiff10 = (curbuyvol10 - cursellvol10);

#MultiBar plots===========================================
plot V5 = if ShowMultiBarVol5 and ShowAllMultiBar and !ShowVol then (Sellbuydiff5) else Double.NaN;
V5.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#V2.SetDefaultColor(Color.DARK_GREEN);
V5.HideTitle();
V5.HideBubble();
V5.SetLineWeight(1);
V5.AssignValueColor(if curbuyVolume5 > cursellVolume5 then CreateColor(33, 145, 72) else if curbuyVolume5 < cursellVolume5  then CreateColor(175, 17, 24) else Color.DARK_GRAY );

plot V10 = if ShowMultiBarVol10 and ShowAllMultiBar and !ShowVol then (Sellbuydiff10) else Double.NaN;
V10.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#V2.SetDefaultColor(Color.DARK_GREEN);
V10.HideTitle();
V10.HideBubble();
V10.SetLineWeight(5);
V10.AssignValueColor(if curbuyvol10 > cursellvol10 then CreateColor(13, 91, 40) else if curbuyvol10 < cursellvol10  then CreateColor(112, 12, 17) else Color.DARK_GRAY );

#addcloud(curbuyVolume5, cursellVolume5, color.DARK_GREEN, color.DARK_RED);

input length = 20;
#plot VolAvg = Average(volume, length);
#VolAvg.SetDefaultColor(GetColor(7));
def BV = SellVolPercent is less than 30;
def SV = SellVolPercent is greater than 70;

def GreatPercent500 = percentOf30Bar > 500;
def GreatPercent250 = percentOf30Bar > 250;


# hiVolume indicator
# source: http://tinboot.blogspot.com
# author: allen everhart


input type = { default SMP, EXP } ;
input length1 = 20 ;
input hotPct = 100.0 ;

def ma =
if type == type.SMP then
SimpleMovingAvg(volume, length)
else
MovAvgExponential(volume, length);

#plot hv =
#if 100 * ((volume / ma) - 1) >= hotPct then

plot hvBuy250 =
if ShowVol and GreatPercent250 and BV and ShowHotVolumeArrows or ShowAllMultiBar and GreatPercent250 and BV and ShowHotVolumeArrows then ma else Double.NaN;
hvBuy250.SetDefaultColor(CreateColor(39, 84, 130));
hvBuy250.SetLineWeight(1) ;
hvBuy250.SetPaintingStrategy( PaintingStrategy.ARROW_UP);

plot hvBuy500 =
if ShowVol and GreatPercent500 and BV and ShowHotVolumeArrows or ShowAllMultiBar and GreatPercent250 and BV and ShowHotVolumeArrows  then ma else Double.NaN;
hvBuy500.SetDefaultColor(CreateColor(29, 24, 120));
hvBuy500.SetLineWeight(2) ;
hvBuy500.SetPaintingStrategy( PaintingStrategy.ARROW_UP);

plot hvSell250 =
if ShowVol and GreatPercent250 and SV and ShowHotVolumeArrows or ShowAllMultiBar and GreatPercent250 and SV and ShowHotVolumeArrows then ma else Double.NaN;
hvSell250.SetDefaultColor(CreateColor(133, 28, 38));
hvSell250.SetLineWeight(1) ;
hvSell250.SetPaintingStrategy( PaintingStrategy.ARROW_DOWN);

plot hvSell500 =
if ShowVol and GreatPercent500 and SV and ShowHotVolumeArrows or ShowAllMultiBar and GreatPercent250 and SV and ShowHotVolumeArrows then ma else Double.NaN;
hvSell500.SetDefaultColor(CreateColor(133, 58, 58));
hvSell500.SetLineWeight(2) ;
hvSell500.SetPaintingStrategy( PaintingStrategy.BOOLEAN_ARROW_DOWN);



#==========================


input price = close;
input length12 = 9;
input displace = 0;
input showBreakoutSignals = no;



def Buyline = ExpAverage(sellbuydiff5[-displace], length12) ;

plot BVLine = (if showbuy_SellLine then Buyline else double.NaN);
BVLine.assignValueColor(if buyline > 0 then createColor(63,162,128) else color.DARK_ORANGE);
BVLine.SetLineWeight(3);

def BuylineUp = Buyline > buyline[1] ;
def BuylineDown = Buyline < buyline[1] ;

def BuylineDir  = if buylineup then 1 else if buylineDown then 2 else 0;

def alertCountBL = if buylineDir[1] == 0 and buylineDir == 1 then 1 else if buylineDir == 1 then alertCountBL[1] + 1 else 0;
plot buylineCnt = alertCountBL;





#AddChartBubble(FE_Consolidation, gamma,  "C", COLOR.WHITE);
#AddChartBubble(FE_Exhaustion, gamma,  "E", COLOR.WHITE);


#def PercentBuy_Sell = if curbuyVolume > cursellVolume then Round((curbuyVolume / cursellVolume))  *100 else round((cursellVolume / curbuyVolume))  *100 ;

#def DiffBuy_Sell = if curbuyVolume5 > cursellVolume5 then Round((curbuyVolume5 - cursellVolume5))  else round((cursellVolume5 - curbuyVolume5));

#def PercentBuy_Sell = if curbuyVolume5 > cursellVolume5 then Round((diffBuy_Sell / cursellVolume5))  *100 else round((diffBuy_Sell / curbuyVolume5))  *100 ;



# Labels================================================================
AddLabel(ShowCurrentBarLabel, "Past Bar: " + curVolume[1], (if percentOf30Bar[1] >= UnusualVolumePercentLabel then Color.DARK_GREEN else if percentOf30Bar[1] >= 100 then CreateColor(110, 75, 110) else Color.DARK_GRAY));

AddLabel(ShowCurrentBarLabel, "Cur Bar: " + curVolume, (if percentOf30Bar >= UnusualVolumePercentLabel then Color.DARK_GREEN else if percentOf30Bar >= 100 then CreateColor(110, 75, 110) else Color.DARK_GRAY));

AddLabel(ShowSellVolumePercentLabel, " Past Sell %: " + SellVolPercent[1], (if SellVolPercent[1] > 70 then CreateColor(175, 17, 24) else if SellVolPercent[1] < 30 then Color.DARK_GREEN else Color.DARK_GRAY));

AddLabel(ShowSellVolumePercentLabel, " Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 70 then CreateColor(175, 17, 24) else if SellVolPercent < 30 then CreateColor(33, 145, 72) else Color.DARK_GRAY));

AddLabel(yes, if BV then " ****-BUYING-**** " else if SV then " ****-SELLING-**** " else " ", if BV then CreateColor(39, 84, 130) else if SV then CreateColor(175, 17, 24) else Color.DARK_GRAY);


def alertCount = if gammacons[1] == 0 and gammacons == 1 then 1 else if gammacons == 1 then alertCount[1] + 1 else 0;
plot gammadots = alertCount;

def alertCount1 = if gammaexh[1] == 0 and gammaexh == 1 then 1 else if gammaexh == 1 then alertCount1[1] + 1 else 0;
plot gammadots1 = alertCount1;

addlabel(yes, if buylineUp then buylineCnt + alertCount1 +  " Bar(s)" + " BL Trend" else if buylinedown then buylineCnt + alertcount1 + " Bar(s)" + " BL Trend" else "", if buylineUp then CreateColor(33, 145, 72) else if buylineDown then CreateColor(175, 17, 24) else color.DARK_GRAY );



addlabel(showgammaLabel, if gammacons then "Consolidating  " +  gammadots +  " Bar(s)"  else if gammaexh then "Exhausted " + gammadots1 + " Bar(s)" else "", if gammaCons then color.DARK_ORANGE else if gammaexh then createColor(76,100,129) else color.DARK_GRAY );



#AddLabel(ShowSellVolumePercentLabel, "Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 70 then Color.DARK_RED else if SellVolPercent < 30 then Color.DARK_GREEN else Color.DARK_GRAY));

#AddLabel(yes, if curbuyVolume5 > cursellVolume5 then "5-Period Buying" else if curbuyVolume5 < cursellVolume5 then "5 Period Selling" else "", if curbuyVolume5 > cursellVolume5 then Color.DARK_GREEN else if curbuyVolume5 < cursellVolume5 then Color.DARK_RED else Color.DARK_GRAY);

#AddLabel(yes, if curbuyvol10 > cursellvol10 then "10-Period Buying" else if curbuyvol10 < cursellvol10 then "10 Period Selling" else "", if curbuyvol10 > cursellvol10 then Color.DARK_GREEN else if curbuyvol10 < cursellvol10 then Color.DARK_RED else Color.DARK_GRAY);

#AddLabel(yes,  sellbuydiff5 + "");

#addlabel(yes, if curbuyVolume5 > cursellVolume5 and curbuyvol10 > cursellvol10 then "buy" else "");




Watchlist Column with BuyLine & Lag....Had to remove the 10 bar Volume bar to make it work but I'm seeing if everything else is lined up, that is as well

Code:
#Red_Green_Multi_Bar Buy_Sell w/FE v1
#Parts derived from Horseriders "Volume Buy Sell Indicator with Hot Percent for ThinkorSwim"
#declare zerobase;
#===08-06-2021 Updated to make it easier to switch inputs.====== Added "Hot Volume" to Multibar
#===10-13-2021===   Added "Buy/Sell Line...Imported Rsi Laguerre
 
#======WITH===========

# RSI-Laguerre Self Adjusting With Fractal Energy Gaussian Price Filter
# Mobius
# V01.12.2016
# Both Fractal Energy and RSI are plotted. RSI in cyan and FE in yellow. Look for trend exhaustion in the FE and a reversal of RSI or Price compression in FE and an RSI reversal.

declare lower;

#Inputs:


input nFE = 8;#hint nFE: length for Fractal Energy calculation.

input Glength  = 12;
input betaDev =  6;
input data = close;
input LaguerreOn = yes;

input NA = double.NaN;



def w = (2 * Double.Pi / Glength );
def beta = (1 - Cos(w)) / (Power(1.414, 2.0 / betaDev) - 1 );
def alpha = (-beta + Sqrt(beta * beta + 2 * beta));
def Go = Power(alpha, 4) * open +
             4 * (1 – alpha) * Go[1] – 6 * Power( 1 - alpha, 2 ) * Go[2] +
             4 * Power( 1 - alpha, 3 ) * Go[3] - Power( 1 - alpha, 4 ) * Go[4];
def Gh = Power(alpha, 4) * high +
             4 * (1 – alpha) * Gh[1] – 6 * Power( 1 - alpha, 2 ) * Gh[2] +
             4 * Power( 1 - alpha, 3 ) * Gh[3] - Power( 1 - alpha, 4 ) * Gh[4];
def Gl = Power(alpha, 4) * low +
             4 * (1 – alpha) * Gl[1] – 6 * Power( 1 - alpha, 2 ) * Gl[2] +
             4 * Power( 1 - alpha, 3 ) * Gl[3] - Power( 1 - alpha, 4 ) * Gl[4];
def Gc = Power(alpha, 4) * data +
             4 * (1 – alpha) * Gc[1] – 6 * Power( 1 - alpha, 2 ) * Gc[2] +
             4 * Power( 1 - alpha, 3 ) * Gc[3] - Power( 1 - alpha, 4 ) * Gc[4];
# Variables:
def o;
def h;
def l;
def c;
def CU1;
def CU2;
def CU;
def CD1;
def CD2;
def CD;
def L0;
def L1;
def L2;
def L3;
def RSI;

def gamma = if LaguerreOn  then Log(Sum((Max(Gh, Gc[1]) - Min(Gl, Gc[1])), nFE) /
        (Highest(gh, nFE) - Lowest(Gl, nFE)))
            / Log(nFE) else na;


L0 = (1 – gamma) * Gc + gamma * L0[1];
L1 = -gamma * L0 + L0[1] + gamma * L1[1];
L2 = -gamma * L1 + L1[1] + gamma * L2[1];
L3 = -gamma * L2 + L2[1] + gamma * L3[1];
if L0 >= L1
then {
    CU1 = L0 - L1;
    CD1 = 0;
} else {
    CD1 = L1 - L0;
    CU1 = 0;
}
if L1 >= L2
then {
    CU2 = CU1 + L1 - L2;
    CD2 = CD1;
} else {
    CD2 = CD1 + L2 - L1;
    CU2 = CU1;
}
if L2 >= L3
then {
    CU = CU2 + L2 - L3;
    CD = CD2;
} else {
    CU = CU2;
    CD = CD2 + L3 - L2;
}


# Calculations
o = (Go + Gc[1]) / 2;
h = Max(Gh, Gc[1]);
l = Min(Gl, Gc[1]);
c = (o + h + l + Gc) / 4;

RSI = if  CU + CD <> 0 then CU / (CU + CD) else 0 ;


#Alert(AlertOn and RSI crosses below .9, "", Alert.BAR, Sound.Bell);
#Alert(AlertOn and RSI crosses above .1, "", Alert.BAR, Sound.Bell);

# End Code RSI_Laguerre Self Adjusting with Fractal Energy



def rsigreen = RSI > RSI[1] and RSI[1] > RSI [2] and rsi > .20;
def rsired = RSI < RSI[1] and RSI[1] < RSI [2] and rsi < .80 ;
def rsiGreen2 = rsi > .80 and !rsigreen;
def rsiRed2 = rsi < .20 and !rsired;



def O_V = open;
def H_V = high;
def C_V = close;
def L_V = low;
def V = volume;
def buying = V * (C_V - L_V) / (H_V - L_V);
def selling = V * (H_V - C_V) / (H_V - L_V);

# Selling Volume


#Volume Data

def curVolume = volume;




#-------------------------------------------------------------------------


#Buy/sell difference================================
def buy1 = buying + buying[1];
def buy2 = buying + buying[1] + buying[2];
def buy3 = buying + buying[1] + buying[2] + buying[3];
def buy4 = buying + buying[1] + buying[2] + buying[3] + buying[4];
def buy5 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5];



def curbuyVolume5 = (buy1 + buy2 + buy3 + buy4 + buy5) / 5;



def sell1 = selling + selling[1];
def sell2 = selling + selling[1] + selling[2];
def sell3 = selling + selling[1] + selling[2] + selling[3];
def sell4 = selling + selling[1] + selling[2] + selling[3] + selling[4];
def sell5 = selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5];



def cursellVolume5 = (sell1 + sell2 + sell3 + sell4 + sell5) / 5;



def Sellbuydiff5 = (curbuyVolume5 - cursellVolume5);


#MultiBar plots===========================================

input price = close;
input length12 = 9;
input displace = 0;
input showBreakoutSignals = no;

def zer0 = 0;

def Buyline = ExpAverage(sellbuydiff5[-displace], length12) ;
def BuylineUp = Buyline > buyline[1] ;
def BuylineDown = Buyline < buyline[1] ;

def BuylineDir  = if buylineup then 1 else if buylineDown then 2 else 0;

def alertCount = if buylineDir[1] == 0 and buylineDir == 1 then 1 else if buylineDir == 1 then alertCount[1] + 1 else 0;
plot buylineCnt = alertCount;




def lv = sellbuydiff5 > 0  and Buyline > zer0 and rsigreen or sellbuydiff5 > 0  and Buyline > zer0 and rsigreen2;
def SV = sellbuydiff5 < 0 and Buyline < zer0 and rsired or sellbuydiff5 < 0 and Buyline < zer0 and rsired2;



addlabel(yes, if lv then "Long " + buylineCnt + " (" + buylineDir + ")" else if SV then "Short " + buylineCnt + " (" + buylineDir + ")" else  "", if lv then CreateColor(33, 145, 72) else if sv then CreateColor(175, 17, 24) else color.BLACK);

#assignBackgroundColor(if lv then CreateColor(33, 145, 72) else if sv then color.DARK_RED else color.BLACK);
 
Last edited:

D_Tramp

New member
VIP
This is my version of Volume RoC, except it's showing the roc of buy vs selling vol.

Based on my own secret math formula (Which if you look at the code, it won't be a secret but you may get a headache)

Can't say I'm the best coder and there probably was an easier way to do it...anyhow

I can see some great potential in using this along with some other indicators (Buy The Dip perhaps) /Price action as additional conformation

If anyone has any improvements they would like to make, by all means...

You can show b/s vol based on 5, 10 days or both or just elect to plot vol or vol roc

I have a WL code based on an older code, Ill be updating at some point.

I'll look into adding mtf labels as well

Here are a few Chart examples and as you'll see just because Sell vol is increasing doesn't mean the stock is NOT going to continue to rise

Here's a chart that reflects such

038GtZZ.png


And some other Charts...

With 10day

nCbYzfh.png



5 day
OQBbPQ1.png


How it looked with OnDemand
P1ZeImb.png


Another chart
4p5yT16.png



Intraday?
ORU8P2K.png


7d6iLWA.png


As Always, Don't depend on just 1 thing as I've seen charts where it didn't work

Goodluck

Oh and here's the code

Code updated 8/2

Code:
#Red_2_Green Volume Rate of Change 8/1/2021
#Parts derived from Horseriders "Volume Buy Sell Indicator with Hot Percent for ThinkorSwim"

input length2 = 60;
input numDev = 2.0;
input allowNegativeValues = no;

def rawRelVol = (volume - Average(volume, length2)) / StDev(volume, length2);
def RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
def StDevLevel = numDev;

#RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#RelVol.SetLineWeight(3);
#RelVol.DefineColor("Bullish", GetColor(6));
#RelVol.DefineColor("Bearish", color.DARK_RED);
#RelVol.DefineColor("Neutral", GetColor(7));
#RelVol.SetDefaultColor( Color.CURRENT);
#RelVol.SetLineWeight(1) ;
#RelVol.SetPaintingStrategy( PaintingStrategy.ARROW_UP);

#plot RelVol1 =
#if close >= open and RelVol > numDev then high else Double.NaN;
#RelVol1.SetDefaultColor(Color.LIGHT_GREEN);
#RelVol1.SetLineWeight(2) ;
#RelVol1.SetPaintingStrategy( PaintingStrategy.ARROW_UP);

#plot RelVol2 =
#if close < open and RelVol > numDev then low else Double.NaN;
#RelVol2.SetDefaultColor( Color.DARK_ORANGE);
#RelVol2.SetLineWeight(2) ;
#RelVol2.SetPaintingStrategy( PaintingStrategy.ARROW_DOWN);


AddLabel(yes, if close >= open and RelVol > numDev then "RVOL - " + RelVol else if close < open and RelVol > numDev then "RVOL - " + RelVol else "RVOL - " + RelVol, if close >= open and RelVol > numDev then Color.DARK_GREEN else if close < open and RelVol > numDev then Color.DARK_RED else Color.DARK_GRAY );

#===================



declare lower;

#Inputs

input Show30DayAvgLabel = yes;
input ShowTodayVolumeLabel =  yes;
input ShowPercentOf30DayAvgLabel = yes;
input UnusualVolumePercentLabel = 200;
input Show30BarAvgLabel = yes;
input ShowCurrentBarLabel = yes;
input ShowPercentOf30BarAvgLabel = yes;
input ShowSellVolumePercentLabel = yes;

input Show5day = yes;
input Show10day = yes;
input ShowAllBuy_Sell = Yes;

input show5barVolRoC = no;
input show10barVolRoC = no;
Input ShowBuySellAvg = no;
input ShowVol = no;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def buying = V * (C - L) / (H - L);
def selling = V * (H - C) / (H - L);

# Selling Volume

plot BuyVol = if showVol then (buying) else double.NaN;
BuyVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BuyVol.SetDefaultColor(Color.DARK_GREEN);
BuyVol.HideTitle();
BuyVol.HideBubble();
BuyVol.SetLineWeight(5);

plot SellVol = if showVol then selling else double.NaN;
SellVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
SellVol.SetDefaultColor(Color.DARK_RED);
SellVol.HideTitle();
SellVol.HideBubble();
SellVol.SetLineWeight(5);

# Total Volume

# Note that Selling + Buying Volume = Volume.
plot TV = if showvol then volume else double.NaN;
TV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
TV.SetDefaultColor(Color.DARK_GRAY);
TV.HideTitle();
TV.HideBubble();
TV.SetLineWeight(1);



#Volume Data

def volLast30DayAvg = (volume(period = "DAY")[1] + volume(period = "DAY")[2] + volume(period = "DAY")[3] + volume(period = "DAY")[4] + volume(period = "DAY")[5] + volume(period = "DAY")[6] + volume(period = "DAY")[7] + volume(period = "DAY")[8] + volume(period = "DAY")[9] + volume(period = "DAY")[10] + volume(period = "DAY")[11] + volume(period = "DAY")[12] + volume(period = "DAY")[13] + volume(period = "DAY")[14] + volume(period = "DAY")[15] + volume(period = "DAY")[16] + volume(period = "DAY")[17] + volume(period = "DAY")[18] + volume(period = "DAY")[19] + volume(period = "DAY")[20] + volume(period = "DAY")[21] + volume(period = "DAY")[22] + volume(period = "DAY")[23] + volume(period = "DAY")[24] + volume(period = "DAY")[25] + volume(period = "DAY")[26] + volume(period = "DAY")[27] + volume(period = "DAY")[28] + volume(period = "DAY")[29] + volume(period = "DAY")[30]) / 30;
def today = volume(period = "DAY");
def percentOf30Day = Round((today / volLast30DayAvg) * 100, 0);
def avg30Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10] + volume[11] + volume[12] + volume[13] + volume[14] + volume[15] + volume[16] + volume[17] + volume[18] + volume[19] + volume[20] + volume[21] + volume[22] + volume[23] + volume[24] + volume[25] + volume[26] + volume[27] + volume[28] + volume[29] + volume[30]) / 30;
def curVolume = volume;
def percentOf30Bar = Round((curVolume / avg30Bars) * 100, 0);
def SellVolPercent = Round((selling / volume) * 100, 0);


#-------------------------------------------------------------------------


#Buy/sell difference================================
def curbuyVolume = (buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5]) ;
def cursellVolume = (selling + selling[1] + selling[2] + selling[3] + selling[4] + selling[5]);
def Sellbuydiff = cursellVolume - curbuyVolume;


def DBRoCA = (buying - buying[1]) / buying[1];

#10 bar RoC
def B1 = (buying - buying[1]) / buying[1];
def B2 = (buying - buying[2]) / buying[2];
def B3 = (buying - buying[3]) / buying[3];
def B4 = (buying - buying[4]) / buying[4];
def B5 = (buying - buying[5]) / buying[5];
def B6 = (buying - buying[6]) / buying[6];
def B7 = (buying - buying[7]) / buying[7];
def B8 = (buying - buying[8]) / buying[8];
def B9 = (buying - buying[9]) / buying[9];
def B10 = (buying - buying[10]) / buying[10];
def buying5A = (B1 + B2 + B3 + B4 + B5) / 5;
def Buying10A = (B1 + B2 + B3 + B4 + B5 + B6 + B7 + B8 + B9 + B10) / 10;



def B2A = (buying[1] - buying[2]) / buying[2];
def B3A = (buying[1] - buying[3]) / buying[3];
def B4A = (buying[1] - buying[4]) / buying[4];
def B5A = (buying[1] - buying[5]) / buying[5];
def B6A = (buying[1] - buying[6]) / buying[6];
def B7A = (buying[1] - buying[7]) / buying[7];
def B8A = (buying[1] - buying[8]) / buying[8];
def B9A = (buying[1] - buying[9]) / buying[9];
def B10A = (buying[1] - buying[10]) / buying[10];
def buying5B = (B2A + B3A + B4A + B5A) / 4;
def Buying10B = (B2A + B3A + B4A + B5A + B6A + B7A + B8A + B9A + B10A) / 9;


def B3B = (buying[2] - buying[3]) / buying[3];
def B4B = (buying[2] - buying[4]) / buying[4];
def B5B = (buying[2] - buying[5]) / buying[5];
def B6B = (buying[2] - buying[6]) / buying[6];
def B7B = (buying[2] - buying[7]) / buying[7];
def B8B = (buying[2] - buying[8]) / buying[8];
def B9B = (buying[2] - buying[9]) / buying[9];
def B10B = (buying[2] - buying[10]) / buying[10];
def buying5C = (B3B + B4B + B5B) / 3;
def Buying10C = (B3B + B4B + B5B + B6B + B7B + B8B + B9B + B10B) / 8;

def B4C = (buying[3] - buying[4]) / buying[4];
def B5C = (buying[3] - buying[5]) / buying[5];
def B6C = (buying[3] - buying[6]) / buying[6];
def B7C = (buying[3] - buying[7]) / buying[7];
def B8C = (buying[3] - buying[8]) / buying[8];
def B9C = (buying[3] - buying[9]) / buying[9];
def B10C = (buying[3] - buying[10]) / buying[10];
def buying5D = (B4C + B5C) / 2;
def Buying10D = (B4C + B5C + B6C + B7C + B8C + B9C + B10C) / 7;

def B5D = (buying[4] - buying[5]) / buying[5];
def B6D = (buying[4] - buying[6]) / buying[6];
def B7D = (buying[4] - buying[7]) / buying[7];
def B8D = (buying[4] - buying[8]) / buying[8];
def B9D = (buying[4] - buying[9]) / buying[9];
def B10D = (buying[4] - buying[10]) / buying[10];
def buying5E = (B5D) / 1;
def Buying10E = (B5D + B6D + B7D + B8D + B9D + B10D) / 6;

def B6E = (buying[5] - buying[6]) / buying[6];
def B7E = (buying[5] - buying[7]) / buying[7];
def B8E = (buying[5] - buying[8]) / buying[8];
def B9E = (buying[5] - buying[9]) / buying[9];
def B10E = (buying[5] - buying[10]) / buying[10];
def Buying10F = (B6E + B7E + B8E + B9E + B10E) / 5;

def B7F = (buying[6] - buying[7]) / buying[7];
def B8F = (buying[6] - buying[8]) / buying[8];
def B9F = (buying[6] - buying[9]) / buying[9];
def B10F = (buying[6] - buying[10]) / buying[10];
def Buying10G = (B7F + B8F + B9F + B10F) / 4;

def B8G = (buying[7] - buying[8]) / buying[8];
def B9G = (buying[7] - buying[9]) / buying[9];
def B10G = (buying[7] - buying[10]) / buying[10];
def Buying10H = (B8G + B9G + B10G) / 3;

def B9H = (buying[8] - buying[9]) / buying[9];
def B10H = (buying[8] - buying[10]) / buying[10];
def Buying10I = (B9H + B10H) / 2;

def B10I = (buying[9] - buying[10]) / buying[10];
def Buying10J = (B9H + B10H) / 2;



def FiveBuyTot = average(Buying5A + Buying5b + Buying5c + Buying5d + Buying5e);

def TenBuyTot = average(Buying10A + Buying10B + Buying10C + Buying10D + Buying10E + Buying10F + Buying10G + Buying10H + Buying10I + Buying10J );

#========SELLING RoC=======================

def S1 = (Selling - Selling[1]) / selling[1];
def S2 = (Selling - Selling[2]) / selling[2];
def S3 = (Selling - Selling[3]) / selling[3];
def S4 = (Selling - Selling[4]) / selling[4];
def S5 = (Selling - Selling[5]) / selling[5];
def S6 = (Selling - Selling[6]) / selling[6];
def S7 = (SELLING - selling[7]) / selling[7];
def S8 = (selling - selling[8]) / selling[8];
def S9 = (selling - selling[9]) / selling[9];
def S10 = (selling - selling[10]) / selling[10];
def Selling5A = (S1+S2+S3+S4+S5) / 5;
def Selling10A = (S1+S2+S3+S4+S5+S6+S7+S8+S9+S10) / 10;


def S1A = (Selling[1] - Selling[2]) / selling[2];
def S2A = (Selling[1] - Selling[3]) / selling[3];
def S3A = (Selling[1] - Selling[4]) / selling[4];
def S4A = (Selling[1] - Selling[5]) / selling[5];
def S5A = (Selling[1] - Selling[6]) / selling[6];
def S6A = (Selling[1] - Selling[7]) / Selling[7];
def S7A = (Selling[1] - selling[8]) / Selling[8];
def S8A = (Selling[1] - selling[9]) / Selling[9];
def S9A = (Selling[1] - Selling[10]) / Selling[10];
def Selling5B = (S1A+S2A+S3A+S4A) / 4;
def Selling10B = (S1A+S2A+S3A+S4A+S5A+S6A+S7A+S8A+S9A) / 9;


def S1B = (Selling[2] - Selling[3]) / selling[3];
def S2B = (Selling[2] - Selling[4]) / selling[4];
def S3B = (Selling[2] - Selling[5]) / selling[5];
def S4B = (Selling[2] - Selling[6]) / selling[6];
def S5B = (Selling[2] - Selling[7]) / Selling[7];
def S6B = (Selling[2] - Selling[8]) / Selling[8];
def S7B = (Selling[2] - Selling[9]) / Selling[9];
def S8B = (Selling[2] - Selling[10]) / Selling[10];
def Selling5C = (S1B+S2B+S3B) / 3;
def Selling10C = (S1B+S2B+S3B+S4B+S5B+S6B+S7B+S8B) / 8;

def S1C = (Selling[3] - Selling[4]) / selling[4];
def S2C = (Selling[3] - Selling[5]) / selling[5];
def S3C = (Selling[3] - Selling[6]) / selling[6];
def S4C = (Selling[3] - Selling[7]) / Selling[7];
def S5C = (Selling[3] - Selling[8]) / Selling[8];
def S6C = (Selling[3] - Selling[9]) / Selling[9];
def S7C = (Selling[3] - Selling[10]) / Selling[10];
def Selling5D = (S1C+S2C) / 2;
def Selling10D = (S1C+S2C+S3C+S4C+S5C+S6C+S7C) / 7;

def S1D = (Selling[4] - Selling[5]) / selling[5];
def S2D = (Selling[4] - Selling[6]) / selling[6];
def S3D = (Selling[4] - Selling[7]) / Selling[7];
def S4D = (Selling[4] - Selling[8]) / Selling[8];
def S5D = (Selling[4] - Selling[9]) / Selling[9];
def S6D = (Selling[4] - Selling[10]) / Selling[10];
def Selling5E = (S1D) / 1;
def Selling10E = (S1+S2D+S3D+S4D+S5D+S6D) / 6;


def S1E = (Selling[5] - Selling[6]) / selling[6];
def S2E = (Selling[5] - Selling[7]) / Selling[7];
def S3E = (Selling[5] - Selling[8]) / Selling[8];
def S4E = (Selling[5] - Selling[9]) / Selling[9];
def S5E = (Selling[5] - Selling[10]) / Selling[10];
def Selling10F = (S1E+S2E+S3E+S4E+S5E) / 5 ;


def S1F = (Selling[6] - Selling[7]) / Selling[7];
def S2F = (Selling[6] - Selling[8]) / Selling[8];
def S3F = (Selling[6] - Selling[9]) / Selling[9];
def S4F = (Selling[6] - Selling[10]) / Selling[10];
def Selling10G = (S1F+S2F+S3F+S4F) / 4;


def S1G = (Selling[7] - Selling[8]) / Selling[8];
def S2G = (Selling[7] - Selling[9]) / Selling[9];
def S3G = (Selling[7] - Selling[10]) / Selling[10];
def Selling10H = (S1G+S2G+S3G) / 3;


def S1H = (Selling[8] - Selling[9]) / Selling[9];
def S2H = (Selling[8] - Selling[10]) / Selling[10];
def Selling10I = (S1H+S2H) / 2;


def S1I = (Selling[9] - Selling[10]) / Selling[10];
def Selling10J = (S1I) / 1;




def FiveSellTot = average(Selling5A + Selling5b + Selling5c + Selling5d + Selling5e);

def TenSellTot = average(Selling10A + Selling10b + Selling10c + Selling10d + Selling10e + Selling10f + Selling10g + Selling10h + Selling10I + Selling10j);

#Volume RoC

#Volume RoC

def VRoCA = (v - v[1]) / v[1];
def VRoCB = (V - V[2]) / V[2];
def VRoCC = (V - V[3]) / V[3];
def VRoCD = (V - V[4]) / V[4];
def VRoCE = (V - V[5]) / V[5];
def VRoCF = (V - V[6]) / V[6];
def VRoCG = (V - V[7]) / V[7];
def VRoCH = (V - V[8]) / V[8];
def VRoCI = (V - V[9]) / V[9];
def VRoCJ = (V - V[10]) / V[10];


def VRoC1A = (V[1] - V[2]) / V[2];
def VRoC1B = (V[1] - V[3]) / V[3];
def VRoC1C = (V[1] - V[4]) / V[4];
def VRoC1D = (V[1] - V[5]) / V[5];
def VRoC1E = (V[1] - V[6]) / V[6];
def VRoC1F = (V[1] - V[7]) / V[7];
def VRoC1G = (V[1] - V[8]) / V[8];
def VRoC1H = (V[1] - V[9]) / V[9];
def VRoC1I = (V[1] - V[10]) / V[10];


def VRoC2A = (V[2] - V[3]) / V[3];
def VRoC2B = (V[2] - V[4]) / V[4];
def VRoC2C = (V[2] - V[5]) / V[5];
def VRoC2D = (V[2] - V[6]) / V[6];
def VRoC2E = (V[2] - V[7]) / V[7];
def VRoC2F = (V[2] - V[8]) / V[8];
def VRoC2G = (V[2] - V[9]) / V[9];
def VRoC2H = (V[2] - V[10]) / V[10];




def VRoC3A = (V[3] - V[4]) / V[4];
def VRoC3B = (V[3] - V[5]) / V[5];
def VRoC3C = (V[3] - V[6]) / V[6];
def VRoC3D = (V[3] - V[7]) / V[7];
def VRoC3E = (V[3] - V[8]) / V[8];
def VRoC3F = (V[3] - V[9]) / V[9];
def VRoC3G = (V[3] - V[10]) / V[10];

def VRoC4A = (V[4] - V[5]) / V[5];
def VRoC4B = (V[4] - V[6]) / V[6];
def VRoC4C = (V[4] - V[7]) / V[7];
def VRoC4D = (V[4] - V[8]) / V[8];
def VRoC4E = (V[4] - V[9]) / V[9];
def VRoC4F = (V[4] - V[10]) / V[10];

def VRoC5A = (V[5] - V[6]) / V[6];
def VRoC5B = (V[5] - V[7]) / V[7];
def VRoC5C = (V[5] - V[8]) / V[8];
def VRoC5D = (V[5] - V[9]) / V[9];
def VRoC5E = (V[5] - V[10]) / V[10];

def VRoC6A = (V[6] - V[7]) / V[7];
def VRoC6B = (V[6] - V[8]) / V[8];
def VRoC6C = (V[6] - V[9]) / V[9];
def VRoC6D = (V[6] - V[10]) / V[10];

def VRoC7A = (V[7] - V[8]) / V[8];
def VRoC7B = (V[7] - V[9]) / V[9];
def VRoC7C = (V[7] - V[10]) / V[10];

def VRoC8A = (V[8] - V[9]) / V[9];
def VRoC8B = (V[8] - V[10]) / V[10];

def VRoC9A = (V[9] - V[10]) / V[10];

def VRoCTotal_10D = average(VroCA + VroCB + VrocC + VroCD + VrocE + VroCF + VroCG + VrocH + Vroci + Vrocj + VRoC1A + VRoC1B + VRoC1C + VRoC1D + VRoC1E + VRoC1F + VRoC1G + VRoC1H + VRoC1I + VRoC2A + VRoC2B + VRoC2C + VRoC2D + VRoC2E + VRoC2F + VRoC2G + VRoC2H + VRoC3A + VRoC3B + VRoC3C + VRoC3D + VRoC3E + VRoC3F + VRoC3G + VROC4A + VROC4B + VROC4C + VROC4D + VROC4E + VROC4F + VROC5A + VROC5B + VROC5C + VROC5D + VROC5E + VROC6A + VROC6B + VROC6C + VROC6D + VROC7A + VROC7B + VROC7C + Vroc8A + VroC8B + Vroc9A) / 55;

def VRoCTotal_5D = average(VroCA + VroCB + VrocC + VroCD + VrocE + VRoC1A + VRoC1B + VRoC1C + VRoC1D + VRoC2A + VRoC2B + VRoC2C  + VRoC3A + VRoC3B  + VROC4A ) / 15;

def FiveBuyUp = FiveBuyTot >= FiveBuyTot[1];
def FiveBuyDown = FiveBuyTot < FiveBuyTot[1];

def FiveSellUp = FiveSellTot >= FiveSellTot[1];
def FiveSellDown = FiveSellTot < FiveSellTot[1];

def TenBuyUp = TenBuyTot >= TenbuyTot[1];
def TenBuyDown = TenBuyTot < TenbuyTot[1];

def TenSellUp = TenSellTot >= TenSellTot[1];
def TenSellDown = TenSellTot < TenSellTot[1];

def BuyBarChange = Buying - Buying[1] ;
def SellBarChange = Selling - Selling[1] ;




plot FiveB = if show5day then (fiveBuyTot) else double.NaN;
FiveB.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
FiveB.SetDefaultColor(createcolor(9,65,133));
FiveB.HideTitle();
FiveB.HideBubble();
FiveB.SetLineWeight(1);
#FiveB.assignValueColor(if FiveBuyUp then createColor(9,65,133) else createColor(15,102,209));


plot FiveS = if show5day then (FiveSellTot) else double.NaN;
FiveS.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
FiveS.SetDefaultColor(createColor(145,105,84));
FiveS.HideTitle();
FiveS.HideBubble();
FiveS.SetLineWeight(1);
#FiveS.assignValueColor(if FiveSellUp then createColor(145,105,84) else createColor(186,134,108));

plot Ten10B = if show10day and ShowAllBuy_Sell then (tenBuyTot) else double.NaN;
Ten10B.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
Ten10B.SetDefaultColor(createColor(0,97,48));
Ten10B.HideTitle();
Ten10B.HideBubble();
#Ten10B.SetLineWeight(1);
#Ten10B.assignValueColor(if TenBuyUp then createColor(0,97,48) else createColor(0,145,73));

plot Ten10S = if show10day then (TenSelltot) else double.NaN;
Ten10S.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
Ten10S.SetDefaultColor(createColor(112,0,26));
Ten10S.HideTitle();
Ten10S.HideBubble();
Ten10S.SetLineWeight(1);
#Ten10S.assignValueColor(if TenSellUp then createColor(112,0,26) else createColor(176,0,41));


plot VFive = if show5barVolRoC then VroCTotal_5D else double.NaN;
Vfive.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
Vfive.SetDefaultColor(ColoR.DARK_GRAY);
Vfive.HideTitle();
Vfive.HideBubble();
Vfive.SetLineWeight(1);







input length = 20;
#plot VolAvg = Average(volume, length);

plot BVolAvg = if showBuySellAvg then average(Buying, length)else double.NaN;
plot SVolAvg = if ShowBuySellAvg then average(Selling, length)else double.NaN;

BVolAvg.setdefaultColor(color.DARK_GREEN);
SVolAvg.setdefaultColor(Color.DARK_RED);

#VolAvg.SetDefaultColor(GetColor(7));

def BV = SellVolPercent is less than 30;
def SV = SellVolPercent is greater than 70;

def GreatPercent500 = percentOf30Bar > 500;
def GreatPercent250 = percentOf30Bar > 250;


# hiVolume indicator
# source: http://tinboot.blogspot.com
# author: allen everhart


input type = { default SMP, EXP } ;
input length1 = 20 ;
input hotPct = 100.0 ;

def ma =
if type == type.SMP then
SimpleMovingAvg(volume, length)
else
MovAvgExponential(volume, length);

#plot hv =
#if 100 * ((volume / ma) - 1) >= hotPct then

plot hvBuy250 =
if ShowVol and GreatPercent250 and BV then ma else Double.NaN;
hvBuy250.SetDefaultColor( Color.WHITE);
hvBuy250.SetLineWeight(1) ;
hvBuy250.SetPaintingStrategy( PaintingStrategy.ARROW_UP);

plot hvBuy500 =
if ShowVol and GreatPercent500 and BV then ma else Double.NaN;
hvBuy500.SetDefaultColor( Color.BLACK);
hvBuy500.SetLineWeight(5) ;
hvBuy500.SetPaintingStrategy( PaintingStrategy.ARROW_UP);

plot hvSell250 =
if ShowVol and GreatPercent250 and SV then ma else Double.NaN;
hvSell250.SetDefaultColor( Color.WHITE);
hvSell250.SetLineWeight(1) ;
hvSell250.SetPaintingStrategy( PaintingStrategy.ARROW_DOWN);

plot hvSell500 =
if ShowVol and GreatPercent500 and SV then ma else Double.NaN;
hvSell500.SetDefaultColor( Color.BLACK);
hvSell500.SetLineWeight(5) ;
hvSell500.SetPaintingStrategy( PaintingStrategy.BOOLEAN_ARROW_DOWN);



#==========================

#def PercentBuy_Sell = if curbuyVolume > cursellVolume then Round((curbuyVolume / cursellVolume))  *100 else round((cursellVolume / curbuyVolume))  *100 ;

def DiffBuy_Sell = if curbuyVolume > cursellVolume then Round((curbuyVolume - cursellVolume))  else round((cursellVolume - curbuyVolume));

def PercentBuy_Sell = if curbuyVolume > cursellVolume then Round((diffBuy_Sell / cursellVolume))  *100 else round((diffBuy_Sell / curbuyVolume))  *100 ;



# Labels

AddLabel(ShowCurrentBarLabel, "Cur Bar: " + curVolume, (if percentOf30Bar >= UnusualVolumePercentLabel then Color.DARK_GREEN else if percentOf30Bar >= 100 then CreateColor(110, 75, 110) else Color.DARK_GRAY));
AddLabel(Show30BarAvgLabel, "Avg 30 Bars: " + Round(avg30Bars, 0), CreateColor(69,47,69));


AddLabel(ShowSellVolumePercentLabel, "Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 70 then Color.DARK_RED else if SellVolPercent < 30 then Color.DARK_GREEN else Color.DARK_GRAY));

#AddLabel(curbuyVolume, "Recent Buying: " + curbuyVolume, CreateColor(39, 84, 130));
#AddLabel(cursellVolume, "Recent Selling: " + cursellVolume, CreateColor(39, 84, 130));

#AddLabel(CSPercentChng, "Selling % RoC: " + (CsPercentChng), CreateColor(85,15,58));


AddLabel(yes, if curbuyVolume > cursellVolume then "Multi-Period Buying" else if curbuyVolume < cursellVolume then "Multi Period Selling" else "", if curbuyVolume > cursellVolume then Color.DARK_GREEN else if curbuyVolume < cursellVolume then Color.DARK_RED else Color.DARK_GRAY);

AddLabel(ShowCurrentBarLabel, "Buy-Sell Diff:   " + diffBuy_Sell, (if curbuyVolume < cursellVolume then Color.DARK_RED else if curbuyVolume > cursellVolume then Color.DARK_GREEN else Color.DARK_GRAY));

#AddLabel(ShowCurrentBar, "%: " + percentBuy_Sell, (if curbuyVolume < cursellVolume then Color.RED else if curbuyVolume > cursellVolume then Color.DARK_GREEN else Color.DARK_GRAY));

#AddLabel(ShowPercentOf30DayAvg, percentOf30Day + "%", (if percentOf30Day >= UnusualVolumePercent then Color.DARK_gREEN else if percentOf30Day >= 100 then createColor(53,44,87) else Color.DARK_GRAY) );

#AddLabel(ShowPercentOf30BarAvg, PercentOf30Bar + "%", (if PercentOf30Bar >= UnusualVolumePercent then Color.DARK_GREEN else if PercentOf30Bar >= 100 then CreateColor(110,75,110) else Color.DARK_GRAY) );


AddLabel(TenBuyTot, " 10-bar Buy % :   " + (TenBuyTot),if TenBuyUp then createColor(0,115,67) else createColor(20,163,87));
AddLabel((TenSelltot), " 10-bar sell % :  " + (TenSelltot), if TenSellUp then createColor(138,0,21) else createColor(196,0,29));

AddLabel((FiveBuyTot), "  5-bar Buy % :   " + (FiveBuyTot),if FiveBuyUp then createColor(0,115,67) else createColor(20,163,87));
AddLabel((FiveSellTot), "  5-bar sell % :  " + (FiveSellTot),if FiveSellUp then createColor(138,0,21) else createColor(196,0,29));

addlabel(BuyBarChange, "Prev Buy Diff   " + (BuyBarChange), if Buying > Buying[1] then createColor(0,105,42) else if Buying < Buying[1] then createColor(0,156,62) else color.DARK_GRAY);

addlabel(SellBarChange, "Prev Sell Diff   " + (SellBarChange), if Selling > Selling[1] then createColor(125,4,26) else if Selling < Selling[1] then createColor(168,5,35) else color.DARK_GRAY);
Hi!
Great Work!!!
Is there tradingview version?
 
Code updated in post #1


This newer version just takes into account the Buying and selling over the previous 5 and 10 bars. I think you'll find much more representative of what is actually occurring

Employ it along with other strategies


2UUHtcN.png
 
Last edited:

amu

New member
VIP
Here's a few more charts

RSI shows overbought but Buy Roc is still good, though tapering off

A way to interpret this is Not that people aren't buying but the rate of buying is decreasing. Price can still continue to rise and vice versa






dkaMCB6.png



Another overbought signal coupled with an increase in sell roc
7IlyYV3.png


ib2HSep.png
Hi ,
Can you help to understand how to use this indicator ? or how you use this indicator . may be along with other indicators but like to understand overall how you decide when to buy and when to sell underlying security .
 
Code Updated, cleaned up a bit, removed some irrelevant info...imo..

Stripped down the buying RoC part. The main part, The Multi bar buy/sell is what you want to use for the most part.

Now based on a 10 bar and 5 bar.

Works on mobile as well


nPlEmpW.png
 
Last edited:
Hi ,
Can you help to understand how to use this indicator ? or how you use this indicator . may be along with other indicators but like to understand overall how you decide when to buy and when to sell underlying security .

Hi, each bar represents the buying or selling pressure over 5/10 bars, with more weight given to the most recent bars

As you can see here on AXP, You don't want to be long atm, as its undergoing lots of selling pressure shown by the red bars down.

Use it along side other info i.e price action, support resistance, MA's, etc



fHqL8Si.png
 
Last edited:

mansor

Active member
Here is how I plan on using this.

I'm looking for a big difference between Buying and selling and then look for the possible setup.


I have 2 WL columns running, one with 5day buying and one with selling


bmY7iXb.png
how do you use same script to generate two different results? what time period aggregation are you using this script on?
 

Splinter

Member
VIP
This indicator is a great add to my charts, I appreciate the work you've done! I tried it out today just as a simple volume indicator on my tick chart and it worked really well!
I have a couple of questions I was hoping you could help with.

1. What's the difference between the single and multi bar approach? When I have 'multibar' set, I'm seeing bars within bars of varying colors both above and below the zero line.

2. There's a label for "Show Sell Volume Percent" for current bar, is there a buy label?

3. What does hvBuy250/hvSell250 etc mean and where do the arrows show?

I appreciate your help. I just want to be able to use this indicator to its fullest potential.
Thanks!
 
how do you use same script to generate two different results? what time period aggregation are you using this script on?
I have since abandoned that WL setup, since I'm now just looking at the default settings of the indicator.

I do have a WL that tells me about any new "Greens" or "Reds"
 
Last edited:
This indicator is a great add to my charts, I appreciate the work you've done! I tried it out today just as a simple volume indicator on my tick chart and it worked really well!
I have a couple of questions I was hoping you could help with.

1. What's the difference between the single and multi bar approach? When I have 'multibar' set, I'm seeing bars within bars of varying colors both above and below the zero line.

2. There's a label for "Show Sell Volume Percent" for current bar, is there a buy label?

3. What does hvBuy250/hvSell250 etc mean and where do the arrows show?

I appreciate your help. I just want to be able to use this indicator to its fullest potential.
Thanks!

Thank you,

1. The narrower bars represent bars based on 5 bars, wider bars represent 10 bars.
so at times the 5 bar may be red or green while the 10 bar may still be above/below 0

2. There is not a Buy label but there is a label for "Buying" or " Selling"
Buying is based on sell volume is < 30% of the total vol
Selling > 70% would trigger a "Selling" label Code updated to reflect that

3. There's an option to show the actual volume. (you have to turn off "Multibar")(You can turn on the volume and it will show it combined with the other part of the indicator)...I need to look into that)

The 250/500 would represent when the vol is either "Buying" or "Selling" and it's 250% greater than the 30 bar average and when you have the volume on, you'll see arrows as shown in this image

Note, don't be confused by the "Selling" label.....That was from today, while the SC is showing the arrow from awhile ago :p

pC6A2UR.png
 
Last edited:

mansor

Active member
I have since abandoned that that WL setup, since I'm now just looking at the default settings of the indicator.

I do have a WL that tells me about any new "Greens" or "Reds"
"I do have a WL that tells me about any new "Greens" or "Reds"" could kindly advise me where I can find it
 
"I do have a WL that tells me about any new "Greens" or "Reds"" could kindly advise me where I can find it
Here's the code for the WL

May trigger a new "5", "10" bar or both

Depending on overall chart will determine if I actually act on any of those signals. Not all signals are a valid buy. still need to consider the overall condition of the chart as they are not to be viewed as Buy/Sell "Triggers"

GL

Code:
#Red_Green_Multi_Bar Buy_Sell Stats
#Parts derived from Horseriders "Volume Buy Sell Indicator with Hot Percent for ThinkorSwim"
#declare zerobase;

declare lower;

#Inputs


input ShowTodayVolumeLabel =  yes;
input UnusualVolumePercentLabel = 200;
input ShowCurrentBarLabel = yes;
input ShowSellVolumePercentLabel = yes;

input Show5day = yes;
input Show10day = yes;
input ShowAllBuy_Sell = no;

input show5barVolRoC = no;
input show10barVolRoC = no;
Input ShowBuySellAvg = no;
input ShowVol = no;
input ShowMultiBarVol5 = yes;
input ShowMultiBarVol8 = yes;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def buying = V * (C - L) / (H - L);
def selling = V * (H - C) / (H - L);

# Selling Volume




#-------------------------------------------------------------------------


#Buy/sell difference================================
def buy1 = buying + buying[1];
def buy2 = buying + buying[1] + buying[2];
def buy3 = buying + buying[1] + buying[2] + buying[3];
def buy4 = buying + buying[1] + buying[2] + buying[3] + buying[4];
def buy5 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5];
def buy6 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6];
def buy7 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7];
def buy8 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8];
def buy9 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8] + buying[9];
def buy10 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8] + buying[9] + buying[10];

def curbuyVolume5 = (buy1 + buy2 + buy3 + buy4 + buy5) / 5;
def curbuyvol10 = (buy1 + buy2 + buy3 + buy4 + buy5 + buy6 + buy7 + buy8 + buy9 + buy10) / 10;

def sell1 = Selling + Selling[1];
def sell2 = Selling + Selling[1] + Selling[2];
def sell3 = Selling + Selling[1] + Selling[2] + Selling[3];
def sell4 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4];
def sell5 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5];
def sell6 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5] + selling[6];
def sell7 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5] + selling[6] +selling[7];
def sell8 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5]+ selling[6] +selling[7] + selling[8];
def sell9 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5]+ selling[6] +selling[7] + selling[8] + selling[9];
def sell10 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5]+ selling[6] +selling[7] + selling[8] + selling[9] + selling[10];

def cursellVolume5 = (sell1 + sell2 + sell3 + sell4 + sell5) / 5;
def cursellvol10 = (sell1 + sell2 + sell3 + sell4 + sell5 + sell6 + sell7 + sell8 + sell9 + sell10) / 10;

def Sellbuydiff5 = (curbuyVolume5 - cursellVolume5);
def Sellbuydiff10 = (curbuyvol10 - cursellvol10);

def NewLong = curbuyVolume5 crosses above cursellVolume5 within 1 bar or curbuyvol10 crosses above cursellvol10 within 1 bar;
def NewShort = curbuyVolume5 crosses below cursellVolume5 within 1 bar or curbuyvol10 crosses below cursellvol10 within 1 bar;

#================================================================================

plot V5 = if showMultiBarVol5 then (sellbuydiff5) else double.NaN;
V5.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#V2.SetDefaultColor(Color.DARK_GREEN);
V5.HideTitle();
V5.HideBubble();
V5.SetLineWeight(1);
V5.assignValueColor(if curbuyVolume5 > cursellVolume5 then createColor(33,145,72) else if curbuyVolume5 < cursellVolume5  then createColor(175,17,24) else color.DARK_GRAY );

plot V8 = if showMultiBarVol8 then (sellbuydiff10) else double.NaN;
V8.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#V2.SetDefaultColor(Color.DARK_GREEN);
V8.HideTitle();
V8.HideBubble();
V8.SetLineWeight(5);
V8.assignValueColor(if curbuyvol10 > cursellvol10 then createColor(13,91,40) else if curbuyvol10 < cursellvol10  then createColor(112,12,17) else color.DARK_GRAY );

#addcloud(curbuyVolume5, cursellVolume5, color.DARK_GREEN, color.DARK_RED);

AddLabel (yes, if newLong then "N_L" else if newShort then "N_S" else " ");
 assignBackgroundColor(if newLong THEN createColor(14,63,39) else if newShort THEN createColor(112,22,26) else createColor(28,28,31));
 
Last edited:
And Here's a upper Chart code showing some of the labels and arrows plotted when vol is 250/500% greater than 30 bar avg

As you can see here on PTON today a quick scalp at open but the better trade was obviously short

v5I2rtC.png


and the daily ( 2 min not showing all labels currently)
l7XDuwU.png




Code for upper Chart Level volume info with Hot Percent arrows

Code:
#derived from Horseriders "Volume Buy Sell Indicator with Hot Percent for ThinkorSwim"
#Upper Chart Volume stats with Hot Percent arrows

#declare zerobase;

#input length2 = 60;
#input numDev = 2.0;
#input allowNegativeValues = no;

#def rawRelVol = (volume - Average(volume, length2)) / StDev(volume, length2);
#def RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
#def StDevLevel = numDev;

#RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#RelVol.SetLineWeight(3);
#RelVol.DefineColor("Bullish", GetColor(6));
#RelVol.DefineColor("Bearish", color.DARK_RED);
#RelVol.DefineColor("Neutral", GetColor(7));
#RelVol.SetDefaultColor( Color.CURRENT);
#RelVol.SetLineWeight(1) ;
#RelVol.SetPaintingStrategy( PaintingStrategy.ARROW_UP);

#plot RelVol1 =
#if close >= open and RelVol > numDev then high else Double.NaN;
#RelVol1.SetDefaultColor(Color.LIGHT_GREEN);
#RelVol1.SetLineWeight(2) ;
#RelVol1.SetPaintingStrategy( PaintingStrategy.ARROW_UP);

#plot RelVol2 =
#if close < open and RelVol > numDev then low else Double.NaN;
#RelVol2.SetDefaultColor( Color.DARK_ORANGE);
#RelVol2.SetLineWeight(2) ;
#RelVol2.SetPaintingStrategy( PaintingStrategy.ARROW_DOWN);


#AddLabel(yes, if close >= open and RelVol > numDev then "RVOL - " + RelVol else if close < open and RelVol > numDev then "RVOL - " + RelVol else "RVOL - " + RelVol, if close >= open and RelVol > numDev then Color.DARK_GREEN else if close < open and RelVol > numDev then Color.DARK_RED else Color.DARK_GRAY );


# End Study

#===================
#Inputs

input Show30DayAvg = yes;
input ShowTodayVolume =  yes;
input ShowPercentOf30DayAvg = yes;
input UnusualVolumePercent = 200;
input Show30BarAvg = yes;
input ShowCurrentBar = yes;
input ShowPercentOf30BarAvg = yes;
input ShowSellVolumePercent = yes;


def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def buying = V * (C - L) / (H - L);
def selling = V * (H - C) / (H - L);

# Selling Volume

def BuyVol = buying;


def SellVol = selling;


# Total Volume

# Note that Selling + Buying Volume = Volume.
def TV =  volume;
#Volume Data


def today = volume(period = "DAY");

def avg30Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10] + volume[11] + volume[12] + volume[13] + volume[14] + volume[15] + volume[16] + volume[17] + volume[18] + volume[19] + volume[20] + volume[21] + volume[22] + volume[23] + volume[24] + volume[25] + volume[26] + volume[27] + volume[28] + volume[29] + volume[30]) / 30;
def curVolume = volume;
def percentOf30Bar = Round((curVolume / avg30Bars) * 100, 0);
def SellVolPercent = Round((selling / volume) * 100, 0);

#Buy/sell difference================================
def buy1 = buying + buying[1];
def buy2 = buying + buying[1] + buying[2];
def buy3 = buying + buying[1] + buying[2] + buying[3];
def buy4 = buying + buying[1] + buying[2] + buying[3] + buying[4];
def buy5 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5];
def buy6 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6];
def buy7 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7];
def buy8 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8];
def buy9 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8] + buying[9];
def buy10 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8] + buying[9] + buying[10];

def curbuyVolume5 = (buy1 + buy2 + buy3 + buy4 + buy5) / 5;
def curbuyvol10 = (buy1 + buy2 + buy3 + buy4 + buy5 + buy6 + buy7 + buy8 + buy9 + buy10) / 10;


def sell1 = Selling + Selling[1];
def sell2 = Selling + Selling[1] + Selling[2];
def sell3 = Selling + Selling[1] + Selling[2] + Selling[3];
def sell4 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4];
def sell5 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5];
def sell6 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5] + selling[6];
def sell7 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5] + selling[6] +selling[7];
def sell8 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5]+ selling[6] +selling[7] + selling[8];
def sell9 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5]+ selling[6] +selling[7] + selling[8] + selling[9];
def sell10 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5]+ selling[6] +selling[7] + selling[8] + selling[9] + selling[10];

def cursellVolume5 = (sell1 + sell2 + sell3 + sell4 + sell5) / 5;
def cursellvol10 = (sell1 + sell2 + sell3 + sell4 + sell5 + sell6 + sell7 + sell8 + sell9 + sell10) / 10;

def Sellbuydiff5 = (curbuyVolume5 - cursellVolume5);
def Sellbuydiff10 = (curbuyvol10 - cursellvol10);

# Labels

#AddLabel(ShowTodayVolume, "Today: " + today, (if percentOf30Day >= UnusualVolumePercent then Color.DARK_GREEN else if percentOf30Day >= 100 then Color.DARK_GREEN else Color.DARK_GRAY));

AddLabel(ShowCurrentBar, "Cur Bar: " + curVolume, (if percentOf30Bar >= UnusualVolumePercent then Color.DARK_GREEN else if percentOf30Bar >= 100 then CreateColor(110, 75, 110) else Color.DARK_GRAY));




#AddLabel(Show30DayAvg, "Avg 30 Days: " + Round(volLast30DayAvg, 0), Color.DARK_GRAY);





#AddLabel(cursellVolume12, "Past Sell: " + cursellVolume12, createColor(207,11,8));
#AddLabel(cursellVolume6, "Recent Sell: " + cursellVolume6, createColor(207,11,8));
#AddLabel(curbuyVolume12, "Past BUY: " + curbuyVolume12, CreateColor(39,84,130));
#AddLabel(curbuyVolume6, "Recent BUY: " + curbuyVolume6, CreateColor(39,84,130));
#AddLabel(totalSell, "Total Sell: "  + TotalSell, createColor(207,11,8));
#Addlabel (totalBuy, "Total BUY: " + totalBuy, CreateColor(39,84,130));






input length = 20;
def VolAvg = Average(volume, length);

#VolAvg.SetDefaultColor(GetColor(7));

def BV = SellVolPercent is less than 30;
def SV = SellVolPercent is greater than 70;

def GreatPercent500 = percentOf30Bar > 500;
def GreatPercent250 = percentOf30Bar > 250;


# hiVolume indicator
# source: http://tinboot.blogspot.com
# author: allen everhart


input type = { default SMP, EXP } ;
input length1 = 20 ;
input hotPct = 100.0 ;

def ma =
if type == type.SMP then
SimpleMovingAvg(volume, length)
else
MovAvgExponential(volume, length);

#plot hv =
#if 100 * ((volume / ma) - 1) >= hotPct then

plot hvBuy250 =
if GreatPercent250 and BV then low else Double.NaN;
hvBuy250.SetDefaultColor(CreateColor(39, 84, 130));
hvBuy250.SetLineWeight(1) ;
hvBuy250.SetPaintingStrategy( PaintingStrategy.ARROW_UP);


plot hvBuy500 =
if GreatPercent500 and BV then low else Double.NaN;
hvBuy500.SetDefaultColor( CreateColor(29, 24, 120));
hvBuy500.SetLineWeight(3) ;
hvBuy500.SetPaintingStrategy( PaintingStrategy.ARROW_UP);



plot hvSell250 =
if GreatPercent250 and SV then high else Double.NaN;
hvSell250.SetDefaultColor(CreateColor(133, 28, 38));
hvSell250.SetLineWeight(1) ;
hvSell250.SetPaintingStrategy( PaintingStrategy.ARROW_DOWN);

plot hvSell500 =
if GreatPercent500 and SV then high else Double.NaN;
hvSell500.SetDefaultColor(CreateColor(133, 58, 58));
hvSell500.SetLineWeight(3) ;
hvSell500.SetPaintingStrategy( PaintingStrategy.BOOLEAN_ARROW_DOWN);





#AddLabel(yes, if curbuyVolume12 > curbuyVolume6 then "Buying Decreasing" else if curbuyVolume12 < curbuyVolume6 then "Buying Increasing" else "", if curbuyVolume12 > curbuyVolume6 then CreateColor(117,42,44) else if  curbuyVolume12 < curbuyVolume6 then Color.DARK_GREEN else Color.DARK_GRAY);

#AddLabel(yes, if cursellVolume12 > cursellVolume6 then "Selling Decreasing" else if cursellVolume12 < cursellVolume6 then "selling Increasing" else "", if cursellVolume12 > cursellVolume6 then Color.DARK_GREEN else if  cursellVolume12 < cursellVolume6 then (createColor(117,42,44)) else Color.DARK_GRAY);

#AddLabel(ShowCurrentBar , "Buy / Sell Diff " + Sellbuydiff, if cursellVolume6 + cursellVolume12 > curbuyVolume6 + curbuyVolume12 then CreateColor(207, 11, 8) else if cursellVolume6 + cursellVolume12 < curbuyVolume6 + curbuyVolume12 then CreateColor(39, 84, 130) else Color.DARK_GRAY);


#AddLabel(showcurrentBar, "Buy Change %: " + percentbuy, (if curbuyVolume12 > curbuyVolume6 then Color.RED else if curbuyVolume12 < curbuyVolume6 then Color.DARK_GREEN else Color.DARK_GRAY));


#AddLabel(showcurrentBar, "Sell Change %: " + percentsell, (if cursellVolume12 > cursellVolume6 then Color.RED else if cursellVolume12 < cursellVolume6 then Color.DARK_GREEN else Color.DARK_GRAY));

#AddLabel(ShowPercentOf30DayAvg, percentOf30Day + "%", (if percentOf30Day >= UnusualVolumePercent then Color.DARK_gREEN else if percentOf30Day >= 100 then createColor(53,44,87) else Color.DARK_GRAY) );

#AddLabel(Show30BarAvg, "Avg 30 Bars: " + Round(avg30Bars, 0), CreateColor(69,47,69));

#AddLabel(ShowPercentOf30BarAvg, PercentOf30Bar + "%", (if PercentOf30Bar >= UnusualVolumePercent then Color.DARK_GREEN else if PercentOf30Bar >= 100 then CreateColor(110,75,110) else Color.DARK_GRAY) );

AddLabel(yes, if BV then "****-BUYING-****" else if SV then "****-SELLING-****" else " ", if BV then CreateColor(39, 84, 130) else if SV then (createColor(122,10,12)) else Color.DARK_GRAY);

AddLabel(ShowSellVolumePercent, "Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 70 then CreateColor(117,42,44) else if SellVolPercent < 30 then Color.DARK_GREEN else Color.DARK_GRAY));

AddLabel(yes, if curbuyVolume5 > cursellVolume5 then "5-Period Buying" else if curbuyVolume5 < cursellVolume5 then "5 Period Selling" else "", if curbuyVolume5 > cursellVolume5 then Color.DARK_GREEN else if curbuyVolume5 < cursellVolume5 then Color.DARK_RED else Color.DARK_GRAY);

AddLabel(yes, if curbuyvol10 > cursellvol10 then "10-Period Buying" else if curbuyvol10 < cursellvol10 then "10 Period Selling" else "", if curbuyvol10 > cursellvol10 then Color.DARK_GREEN else if curbuyvol10 < cursellvol10 then Color.DARK_RED else Color.DARK_GRAY);
 

Splinter

Member
VIP
And Here's a upper Chart code showing some of the labels and arrows plotted when vol is 250/500% greater than 30 bar avg

As you can see here on PTON today a quick scalp at open but the better trade was obviously short

v5I2rtC.png


and the daily ( 2 min not showing all labels currently)
l7XDuwU.png




Code for upper Chart Level volume info with Hot Percent arrows

Code:
#derived from Horseriders "Volume Buy Sell Indicator with Hot Percent for ThinkorSwim"
#Upper Chart Volume stats with Hot Percent arrows

#declare zerobase;

#input length2 = 60;
#input numDev = 2.0;
#input allowNegativeValues = no;

#def rawRelVol = (volume - Average(volume, length2)) / StDev(volume, length2);
#def RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
#def StDevLevel = numDev;

#RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#RelVol.SetLineWeight(3);
#RelVol.DefineColor("Bullish", GetColor(6));
#RelVol.DefineColor("Bearish", color.DARK_RED);
#RelVol.DefineColor("Neutral", GetColor(7));
#RelVol.SetDefaultColor( Color.CURRENT);
#RelVol.SetLineWeight(1) ;
#RelVol.SetPaintingStrategy( PaintingStrategy.ARROW_UP);

#plot RelVol1 =
#if close >= open and RelVol > numDev then high else Double.NaN;
#RelVol1.SetDefaultColor(Color.LIGHT_GREEN);
#RelVol1.SetLineWeight(2) ;
#RelVol1.SetPaintingStrategy( PaintingStrategy.ARROW_UP);

#plot RelVol2 =
#if close < open and RelVol > numDev then low else Double.NaN;
#RelVol2.SetDefaultColor( Color.DARK_ORANGE);
#RelVol2.SetLineWeight(2) ;
#RelVol2.SetPaintingStrategy( PaintingStrategy.ARROW_DOWN);


#AddLabel(yes, if close >= open and RelVol > numDev then "RVOL - " + RelVol else if close < open and RelVol > numDev then "RVOL - " + RelVol else "RVOL - " + RelVol, if close >= open and RelVol > numDev then Color.DARK_GREEN else if close < open and RelVol > numDev then Color.DARK_RED else Color.DARK_GRAY );


# End Study

#===================
#Inputs

input Show30DayAvg = yes;
input ShowTodayVolume =  yes;
input ShowPercentOf30DayAvg = yes;
input UnusualVolumePercent = 200;
input Show30BarAvg = yes;
input ShowCurrentBar = yes;
input ShowPercentOf30BarAvg = yes;
input ShowSellVolumePercent = yes;


def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def buying = V * (C - L) / (H - L);
def selling = V * (H - C) / (H - L);

# Selling Volume

def BuyVol = buying;


def SellVol = selling;


# Total Volume

# Note that Selling + Buying Volume = Volume.
def TV =  volume;
#Volume Data


def today = volume(period = "DAY");

def avg30Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10] + volume[11] + volume[12] + volume[13] + volume[14] + volume[15] + volume[16] + volume[17] + volume[18] + volume[19] + volume[20] + volume[21] + volume[22] + volume[23] + volume[24] + volume[25] + volume[26] + volume[27] + volume[28] + volume[29] + volume[30]) / 30;
def curVolume = volume;
def percentOf30Bar = Round((curVolume / avg30Bars) * 100, 0);
def SellVolPercent = Round((selling / volume) * 100, 0);

#Buy/sell difference================================
def buy1 = buying + buying[1];
def buy2 = buying + buying[1] + buying[2];
def buy3 = buying + buying[1] + buying[2] + buying[3];
def buy4 = buying + buying[1] + buying[2] + buying[3] + buying[4];
def buy5 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5];
def buy6 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6];
def buy7 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7];
def buy8 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8];
def buy9 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8] + buying[9];
def buy10 = buying + buying[1] + buying[2] + buying[3] + buying[4] + buying[5] + buying[6] + buying[7] + buying[8] + buying[9] + buying[10];

def curbuyVolume5 = (buy1 + buy2 + buy3 + buy4 + buy5) / 5;
def curbuyvol10 = (buy1 + buy2 + buy3 + buy4 + buy5 + buy6 + buy7 + buy8 + buy9 + buy10) / 10;


def sell1 = Selling + Selling[1];
def sell2 = Selling + Selling[1] + Selling[2];
def sell3 = Selling + Selling[1] + Selling[2] + Selling[3];
def sell4 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4];
def sell5 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5];
def sell6 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5] + selling[6];
def sell7 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5] + selling[6] +selling[7];
def sell8 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5]+ selling[6] +selling[7] + selling[8];
def sell9 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5]+ selling[6] +selling[7] + selling[8] + selling[9];
def sell10 = Selling + Selling[1] + Selling[2] + Selling[3] + Selling[4] + Selling[5]+ selling[6] +selling[7] + selling[8] + selling[9] + selling[10];

def cursellVolume5 = (sell1 + sell2 + sell3 + sell4 + sell5) / 5;
def cursellvol10 = (sell1 + sell2 + sell3 + sell4 + sell5 + sell6 + sell7 + sell8 + sell9 + sell10) / 10;

def Sellbuydiff5 = (curbuyVolume5 - cursellVolume5);
def Sellbuydiff10 = (curbuyvol10 - cursellvol10);

# Labels

#AddLabel(ShowTodayVolume, "Today: " + today, (if percentOf30Day >= UnusualVolumePercent then Color.DARK_GREEN else if percentOf30Day >= 100 then Color.DARK_GREEN else Color.DARK_GRAY));

AddLabel(ShowCurrentBar, "Cur Bar: " + curVolume, (if percentOf30Bar >= UnusualVolumePercent then Color.DARK_GREEN else if percentOf30Bar >= 100 then CreateColor(110, 75, 110) else Color.DARK_GRAY));




#AddLabel(Show30DayAvg, "Avg 30 Days: " + Round(volLast30DayAvg, 0), Color.DARK_GRAY);





#AddLabel(cursellVolume12, "Past Sell: " + cursellVolume12, createColor(207,11,8));
#AddLabel(cursellVolume6, "Recent Sell: " + cursellVolume6, createColor(207,11,8));
#AddLabel(curbuyVolume12, "Past BUY: " + curbuyVolume12, CreateColor(39,84,130));
#AddLabel(curbuyVolume6, "Recent BUY: " + curbuyVolume6, CreateColor(39,84,130));
#AddLabel(totalSell, "Total Sell: "  + TotalSell, createColor(207,11,8));
#Addlabel (totalBuy, "Total BUY: " + totalBuy, CreateColor(39,84,130));






input length = 20;
def VolAvg = Average(volume, length);

#VolAvg.SetDefaultColor(GetColor(7));

def BV = SellVolPercent is less than 30;
def SV = SellVolPercent is greater than 70;

def GreatPercent500 = percentOf30Bar > 500;
def GreatPercent250 = percentOf30Bar > 250;


# hiVolume indicator
# source: http://tinboot.blogspot.com
# author: allen everhart


input type = { default SMP, EXP } ;
input length1 = 20 ;
input hotPct = 100.0 ;

def ma =
if type == type.SMP then
SimpleMovingAvg(volume, length)
else
MovAvgExponential(volume, length);

#plot hv =
#if 100 * ((volume / ma) - 1) >= hotPct then

plot hvBuy250 =
if GreatPercent250 and BV then low else Double.NaN;
hvBuy250.SetDefaultColor(CreateColor(39, 84, 130));
hvBuy250.SetLineWeight(1) ;
hvBuy250.SetPaintingStrategy( PaintingStrategy.ARROW_UP);


plot hvBuy500 =
if GreatPercent500 and BV then low else Double.NaN;
hvBuy500.SetDefaultColor( CreateColor(29, 24, 120));
hvBuy500.SetLineWeight(3) ;
hvBuy500.SetPaintingStrategy( PaintingStrategy.ARROW_UP);



plot hvSell250 =
if GreatPercent250 and SV then high else Double.NaN;
hvSell250.SetDefaultColor(CreateColor(133, 28, 38));
hvSell250.SetLineWeight(1) ;
hvSell250.SetPaintingStrategy( PaintingStrategy.ARROW_DOWN);

plot hvSell500 =
if GreatPercent500 and SV then high else Double.NaN;
hvSell500.SetDefaultColor(CreateColor(133, 58, 58));
hvSell500.SetLineWeight(3) ;
hvSell500.SetPaintingStrategy( PaintingStrategy.BOOLEAN_ARROW_DOWN);





#AddLabel(yes, if curbuyVolume12 > curbuyVolume6 then "Buying Decreasing" else if curbuyVolume12 < curbuyVolume6 then "Buying Increasing" else "", if curbuyVolume12 > curbuyVolume6 then CreateColor(117,42,44) else if  curbuyVolume12 < curbuyVolume6 then Color.DARK_GREEN else Color.DARK_GRAY);

#AddLabel(yes, if cursellVolume12 > cursellVolume6 then "Selling Decreasing" else if cursellVolume12 < cursellVolume6 then "selling Increasing" else "", if cursellVolume12 > cursellVolume6 then Color.DARK_GREEN else if  cursellVolume12 < cursellVolume6 then (createColor(117,42,44)) else Color.DARK_GRAY);

#AddLabel(ShowCurrentBar , "Buy / Sell Diff " + Sellbuydiff, if cursellVolume6 + cursellVolume12 > curbuyVolume6 + curbuyVolume12 then CreateColor(207, 11, 8) else if cursellVolume6 + cursellVolume12 < curbuyVolume6 + curbuyVolume12 then CreateColor(39, 84, 130) else Color.DARK_GRAY);


#AddLabel(showcurrentBar, "Buy Change %: " + percentbuy, (if curbuyVolume12 > curbuyVolume6 then Color.RED else if curbuyVolume12 < curbuyVolume6 then Color.DARK_GREEN else Color.DARK_GRAY));


#AddLabel(showcurrentBar, "Sell Change %: " + percentsell, (if cursellVolume12 > cursellVolume6 then Color.RED else if cursellVolume12 < cursellVolume6 then Color.DARK_GREEN else Color.DARK_GRAY));

#AddLabel(ShowPercentOf30DayAvg, percentOf30Day + "%", (if percentOf30Day >= UnusualVolumePercent then Color.DARK_gREEN else if percentOf30Day >= 100 then createColor(53,44,87) else Color.DARK_GRAY) );

#AddLabel(Show30BarAvg, "Avg 30 Bars: " + Round(avg30Bars, 0), CreateColor(69,47,69));

#AddLabel(ShowPercentOf30BarAvg, PercentOf30Bar + "%", (if PercentOf30Bar >= UnusualVolumePercent then Color.DARK_GREEN else if PercentOf30Bar >= 100 then CreateColor(110,75,110) else Color.DARK_GRAY) );

AddLabel(yes, if BV then "****-BUYING-****" else if SV then "****-SELLING-****" else " ", if BV then CreateColor(39, 84, 130) else if SV then (createColor(122,10,12)) else Color.DARK_GRAY);

AddLabel(ShowSellVolumePercent, "Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 70 then CreateColor(117,42,44) else if SellVolPercent < 30 then Color.DARK_GREEN else Color.DARK_GRAY));

AddLabel(yes, if curbuyVolume5 > cursellVolume5 then "5-Period Buying" else if curbuyVolume5 < cursellVolume5 then "5 Period Selling" else "", if curbuyVolume5 > cursellVolume5 then Color.DARK_GREEN else if curbuyVolume5 < cursellVolume5 then Color.DARK_RED else Color.DARK_GRAY);

AddLabel(yes, if curbuyvol10 > cursellvol10 then "10-Period Buying" else if curbuyvol10 < cursellvol10 then "10 Period Selling" else "", if curbuyvol10 > cursellvol10 then Color.DARK_GREEN else if curbuyvol10 < cursellvol10 then Color.DARK_RED else Color.DARK_GRAY);
Very cool! I am having an issue with the arrows showing up in the price action. I'm using a tick chart, does that make a difference?
 

Similar threads

Top