Volume Buy Sell Pressure with Hot Percent for ThinkorSwim

@horserider This is one of the greatest indicator I use. May I know if it's possible to plot this as Volume profile showing buy and sell volumes ?
Not sure you understand what a volume profile is. It shows the amount of volume that traded hands at a specific price. You can't designate buying or selling volume with that because they're all buying and selling. This indicator is only able to differentiate the two because its using location of the close in relation to the highest and lowest price within a specified time.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not sure you understand what a volume profile is. It shows the amount of volume that traded hands at a specific price. You can't designate buying or selling volume with that because they're all buying and selling. This indicator is only able to differentiate the two because its using location of the close in relation to the highest and lowest price within a specified time.
I am looking for something like this https://i0.wp.com/ninjatrader.com/blog/wp-content/uploads/2020/11/VPIntro1.png?resize=768,460&ssl=1
 
Used the Horserider Volume indicator code and made a 30 bar volume average % watchlist column... not entirely sure it will be useful but time will tell.

http://tos.mx/u3K4CTM

0corfvE.png


Code:
#Volume Buy Sell Pressure with Hot Percent for ThinkorSwim
# Show total volume in gray.  Buying volume in green.  Sell Volume in red.
# Volume average is gray line.
# Specified percent over average volume is cyan triangles.
# Horserider 12/30/2019 derived from some already existing studies.


declare lower;

#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

Plot SellVol = selling;
SellVol.setPaintingStrategy(PaintingStrategy.Histogram);
SellVol.SetDefaultColor(Color.Red);
SellVol.HideTitle();
SellVol.HideBubble();
SellVol.SetLineWeight(1);

# Total Volume

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

TV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
TV.SetDefaultColor(Color.GRAY);
#TV.HideTitle();
#TV.HideBubble();
TV.SetLineWeight(1);

Plot BuyVol = buying;
BuyVol.setPaintingStrategy(PaintingStrategy.Histogram);
BuyVol.SetDefaultColor(Color.Green);
BuyVol.HideTitle();
BuyVol.HideBubble();
BuyVol.SetLineWeight(5);

#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);

# Labels



#AddLabel(Show30BarAvg, "30 Bar: " + Round(avg30Bars, 0), Color.white);

#AddLabel(ShowCurrentBar, "Cur Bar: " + curVolume, (if percentOf30Bar >= UnusualVolumePercent then Color.GREEN else if PercentOf30Bar >= 100 then Color.ORANGE else Color.LIGHT_GRAY));

#AddLabel(ShowPercentOf30BarAvg, PercentOf30Bar + "%", (if PercentOf30Bar >= UnusualVolumePercent then Color.GREEN else if PercentOf30Bar >= 100 then Color.Light_Green else Color.WHITE) );

assignBackgroundColor(if PercentOf30Bar >= UnusualVolumePercent then color.GREEN else if  PercentOf30Bar >= 100 then color.RED else color.white);
AddLabel(ShowPercentOf30BarAvg, PercentOf30Bar + "%",Color.Black);
#AddLabel(buying >= selling, ""+BuyVolPercent, color.black);
#AddLabel(ShowSellVolumePercent, "Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 51 then Color.RED else if SellVolPercent < 49 then Color.GREEN else Color.ORANGE));

#input length = 21;
#input length2 = 21;

#plot VolAvg = Average(volume, length);
#plot VolAvg1= Average(volume, length2);

#VolAvg.SetDefaultColor(GetColor(1));
#VolAvg1.SetDefaultColor(GetColor(3));


#def crossover = if (VolAvg2 crosses below VolAvg4) then 1 else 0;
#def crossunder = if (VolAvg2 crosses above VolAvg4) and (volume<volavg) then 1 else 0;
#AddVerticalLine(if crossover ==1 then 1 else 0,"",color.cyan);
#AddVerticalLine(if crossunder ==1 then 1 else 0);


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


#input type = { default SMP, EXP } ;
#input length_HV = 20 ;
#input HotPct = 100.0 ;


#def MA =
#if type == type.SMP then
#SimpleMovingAvg(volume, length_HV)
#else
#MovAvgExponential(volume, length_HV);

#plot HV =
##ma
#else
#Double.NaN;

#hv.SetDefaultColor( Color.CYAN);
#hv.SetLineWeight(1) ;
#hv.SetPaintingStrategy( PaintingStrategy.TRIANGLES);
 
PTwbFRZ.png


Y2lxxl7.png


https://tos.mx/WJZDjWz

Code:
# HORSERIDER VOLUME V3 - @HODL
# Volume Buy Sell Pressure with Hot Percent for ThinkorSwim
# Show total volume in gray.  Buying volume in green.  Sell Volume in red.
# Volume average is gray line.
# Specified percent over average volume is cyan triangles.
# Horserider 12/30/2019 derived from some already existing studies.
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © sudoMode
#indicator(title = 'Pressure Gauge', shorttitle = 'Equilibrium', overlay = false)
# Converted and mod by Sam4Cok@Samer800    - 05/2023

declare lower;

#Inputs
input ControlPercent = 20; #hint above or below this value colors label
input ControlAvgPercent = 10;
input lengthVolAvgLabel = 30;
input lengthAvgXBarsControl = 30; #hint shows who is in control over X bars
input HotPct = 150.0; #hint total volume of bar greater than hotpct = cyan triangle
input ShowTodayVolume =  yes;
input ShowBarVolume = yes;
input ShowBuySellPercent = yes;
input ShowBuySellPercentAvgXBars = yes;
input ShowCurrentBarControl = yes;   
input ShowControlAvgXBars = yes;
input type = { default SMP, EXP } ;
#Definitions
def lengthVolAvgPlot = 21;
def tradeDaytimeOnly = yes; #hint tradeDaytimeOnly: (IntraDay Only) Only perform trades during hours stated
def OpenTime = 0930; #hint OpenTime: Opening time of market
def CloseTime = 1600; #hint CloseTime: Closing time of market
def length_HV = 20 ;
def Begin = SecondsFromTime(OpenTime);
def End = SecondsTillTime(CloseTime);
def isIntraDay = if GetAggregationPeriod() > 14400000 or GetAggregationPeriod() == 0 then 0 else 1;
def MarketOpen = if !tradeDaytimeOnly or !isIntraDay then 1 else if tradeDaytimeOnly and isIntraDay and Begin > 0 and End > 0 then 1 else 0;
def na = Double.NaN;
#Horserider Volume
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);
Plot SellVol = selling;
SellVol.setPaintingStrategy(PaintingStrategy.Histogram);
SellVol.SetDefaultColor(Color.Red);
SellVol.HideTitle();
SellVol.HideBubble();
SellVol.SetLineWeight(1);
plot TV =  volume;
TV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
TV.SetDefaultColor(Color.GRAY);
TV.SetLineWeight(1);
Plot BuyVol = buying;
BuyVol.setPaintingStrategy(PaintingStrategy.Histogram);
BuyVol.SetDefaultColor(Color.Green);
BuyVol.HideTitle();
BuyVol.HideBubble();
BuyVol.SetLineWeight(5);
Script F {
Input Length = 30;
def data = volume(period = "DAY");
def data1 =
    fold a = 1
    to Length + 1
    with K = 0
    do K + data[a];
def Vol30day_Average = data1 / length;
plot Vol = Vol30day_Average;
}
Script G {
Input Length = 30;
def data = volume;
def data1 =
    fold a = 1
    to Length + 1
    with k = 0
    do k + data[a];
def Vol30Bars_Average = data1 / length;
plot Vol2 = Vol30Bars_Average;
}
def AvgVolume30_Day = F(lengthVolAvgLabel);
def AvgVolume30_Bars = G(lengthVolAvgLabel);
def today = volume(period = "DAY");
def curVolume = volume;
def diffFromAvg = today - AvgVolume30_Day;
def diffFromAvgBars = curVolume - AvgVolume30_Bars;
def percentDiffdays = Round((diffFromAvg / AvgVolume30_Day) * 100, 0);
def percentOf30Bar = Round((curVolume / AvgVolume30_Bars) * 100, 0);
def SellVolPercent = Round((Selling / Volume) * 100, 0);
def buyVolPercent = Round((Buying / Volume) * 100, 0);
def percentDiffBars = Round((diffFromAvgBars / AvgVolume30_Bars) * 100, 0);
def BarsBias = if (percentDiffBars <> ControlPercent) and (curVolume > AvgVolume30_Bars) then 1 else if (percentDiffBars <> ControlPercent) and (curVolume < AvgVolume30_Bars) then -1 else 0;
def DaysBias = if (percentDiffdays <> ControlPercent) and (today > AvgVolume30_Day) then 1 else if (percentDiffdays <> ControlPercent) and (curVolume < AvgVolume30_Day) then -1 else 0;
def percentdiff = (sellvolpercent - buyvolpercent);
def percentdiffAbs = absvalue(sellvolpercent - buyvolpercent);
def SellingAvgBars = average(selling,lengthAvgXBarsControl);
def BuyingAvgBars = average(buying,lengthAvgXBarsControl);
def sellavgpercent = (round(AvgVolume30_Bars,0) - Round(SellingAvgBars,0))/Round(AvgVolume30_Bars,0)*100;
def buyavgpercent = (round(AvgVolume30_Bars,0) - Round(BuyingAvgBars,0))/Round(AvgVolume30_Bars,0)*100;
def perdiffavg = absvalue(sellavgpercent - buyavgpercent);
plot VolAvg = Average(volume, lengthVolAvgPlot);
VolAvg.Setdefaultcolor(Color.Gray);
def MA = if type == type.SMP then SimpleMovingAvg(volume, length_HV) else MovAvgExponential(volume, length_HV);
plot HV = if (100 * ((volume / ma) - 1) >= hotPct) then ma else Double.NaN;
hv.SetDefaultColor( Color.CYAN);
hv.SetLineWeight(2) ;
hv.SetPaintingStrategy( PaintingStrategy.TRIANGLES);
def bn = barnumber();
def HighV = if (100 * ((volume / ma) - 1) >= hotPct) then 1 else 0;
def HighV_Foldcondition = if MarketOpen and (100 * ((volume / ma) - 1) >= hotPct) and (buyvolPercent > sellvolpercent) then 1
else if MarketOpen and (100 * ((volume / ma) - 1) >= hotPct) and (buyvolPercent < sellvolpercent) then -1 else 0;
input HighVLookback = 100;
def HighV_lookback = fold uu = 1 to HighVLookback with pp do pp + HighV_Foldcondition[uu];
#Labels
AddLabel(ShowBuySellPercent, "Current Bar Buy: " + BuyVolPercent + "%",
    (if (BuyVolPercent > Sellvolpercent) and highV then Color.cyan
         else if (BuyVolPercent > Sellvolpercent) and (BuyVolPercent >= ControlPercent) then Color.Green
              else if (BuyVolPercent < Sellvolpercent) then Color.Gray
                   else Color.current));
AddLabel(ShowBuySellPercent, "Current Bar Sell: " + SellVolPercent + "%",
    (if (BuyVolPercent < Sellvolpercent) and highV then Color.cyan
         else if (BuyVolPercent < Sellvolpercent) and (SellVolPercent >= ControlPercent) then Color.red
              else if (BuyVolPercent > Sellvolpercent) then Color.Gray
                   else Color.current));
AddLabel(ShowCurrentBarControl, "Current Bar Control: " + percentdiff + "%",
    (if (BuyVolPercent > Sellvolpercent) and highV then Color.cyan
         else if (BuyVolPercent > Sellvolpercent) and (percentdiff >= ControlPercent) then Color.green
              else if (BuyVolPercent < Sellvolpercent) and (percentdiff >= ControlPercent) then Color.red           
                   else if (percentdiff < ControlPercent) then Color.Gray
                       else Color.current));

AddLabel(ShowTodayVolume,
if (DaysBias == 1) then "Todays Volume: " + (today) + " | " +  absvalue(percentDiffdays) + "% Above " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == -1) then "Todays Volume: " + (today) + " | " +  absvalue(percentDiffdays) + "% Below " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == 0) and (today > AvgVolume30_Bars) then "Todays Volume: " + (today) + " | " +  absvalue(percentDiffdays) + "% above " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == 0) and (today < AvgVolume30_Bars) then "Todays Volume: " + (today) + " | " +  absvalue(percentDiffdays) + "% below " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else "Todays Volume: " + (today) + " | " + absvalue(percentDiffdays) + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_day, 0)+ ")",
(if (DaysBias == 1) then Color.green
    else if (DaysBias == -1) then Color.RED
        else if (DaysBias == 0) and (curVolume > AvgVolume30_Day) then color.orange
            else if (DaysBias == 0) and (curVolume < AvgVolume30_Day) then color.orange         
                else color.light_gray));
AddLabel(ShowBarVolume,
if (BarsBias == 1) then "Current Bar Volume: " + (curVolume) + " | " +  absvalue(percentDiffBars) + "% Above " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == -1) then "Current Bar Volume: " + (curVolume) + " | " +  absvalue(percentDiffBars) + "% Below " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == 0) and (curVolume > AvgVolume30_Bars) then "Current Bar Volume: " + (curVolume) + " | " +  absvalue(percentDiffBars) + "% above " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == 0) and (curVolume < AvgVolume30_Bars) then "Current Bar Volume: " + (curVolume) + " | " +  absvalue(percentDiffBars) + "% below " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else "Current Bar Volume: " + (curVolume) + " | " + absvalue(percentDiffBars) + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")",   
(if (BarsBias == 1) then Color.green
    else if (BarsBias == -1) then Color.RED
        else if (BarsBias == 0) and (curVolume > AvgVolume30_Bars) then color.orange
            else if (BarsBias == 0) and (curVolume < AvgVolume30_Bars) then color.orange         
                else Color.light_gray));

addlabel(ShowBuySellPercentAvgXBars,lengthAvgXBarsControl + " Bar Average Buy: " + round(buyavgpercent,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.light_green
    else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Gray           
         else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
             else Color.current));
addlabel(ShowBuySellPercentAvgXBars,lengthAvgXBarsControl + " Bar Average Sell: " + round(sellavgpercent,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.gray
    else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Light_red           
        else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
             else Color.current));
addlabel(ShowControlAvgXBars,lengthAvgXBarsControl + " Bar Average Control: " + round(perdiffavg,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.light_green
    else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Light_red           
        else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
             else Color.current));





#
 
PTwbFRZ.png


Y2lxxl7.png


https://tos.mx/WJZDjWz

Code:
# HORSERIDER VOLUME V3 - @HODL
# Volume Buy Sell Pressure with Hot Percent for ThinkorSwim
# Show total volume in gray.  Buying volume in green.  Sell Volume in red.
# Volume average is gray line.
# Specified percent over average volume is cyan triangles.
# Horserider 12/30/2019 derived from some already existing studies.
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © sudoMode
#indicator(title = 'Pressure Gauge', shorttitle = 'Equilibrium', overlay = false)
# Converted and mod by Sam4Cok@Samer800    - 05/2023

declare lower;

#Inputs
input ControlPercent = 20; #hint above or below this value colors label
input ControlAvgPercent = 10;
input lengthVolAvgLabel = 30;
input lengthAvgXBarsControl = 30; #hint shows who is in control over X bars
input HotPct = 150.0; #hint total volume of bar greater than hotpct = cyan triangle
input ShowTodayVolume =  yes;
input ShowBarVolume = yes;
input ShowBuySellPercent = yes;
input ShowBuySellPercentAvgXBars = yes;
input ShowCurrentBarControl = yes;  
input ShowControlAvgXBars = yes;
input type = { default SMP, EXP } ;
#Definitions
def lengthVolAvgPlot = 21;
def tradeDaytimeOnly = yes; #hint tradeDaytimeOnly: (IntraDay Only) Only perform trades during hours stated
def OpenTime = 0930; #hint OpenTime: Opening time of market
def CloseTime = 1600; #hint CloseTime: Closing time of market
def length_HV = 20 ;
def Begin = SecondsFromTime(OpenTime);
def End = SecondsTillTime(CloseTime);
def isIntraDay = if GetAggregationPeriod() > 14400000 or GetAggregationPeriod() == 0 then 0 else 1;
def MarketOpen = if !tradeDaytimeOnly or !isIntraDay then 1 else if tradeDaytimeOnly and isIntraDay and Begin > 0 and End > 0 then 1 else 0;
def na = Double.NaN;
#Horserider Volume
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);
Plot SellVol = selling;
SellVol.setPaintingStrategy(PaintingStrategy.Histogram);
SellVol.SetDefaultColor(Color.Red);
SellVol.HideTitle();
SellVol.HideBubble();
SellVol.SetLineWeight(1);
plot TV =  volume;
TV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
TV.SetDefaultColor(Color.GRAY);
TV.SetLineWeight(1);
Plot BuyVol = buying;
BuyVol.setPaintingStrategy(PaintingStrategy.Histogram);
BuyVol.SetDefaultColor(Color.Green);
BuyVol.HideTitle();
BuyVol.HideBubble();
BuyVol.SetLineWeight(5);
Script F {
Input Length = 30;
def data = volume(period = "DAY");
def data1 =
    fold a = 1
    to Length + 1
    with K = 0
    do K + data[a];
def Vol30day_Average = data1 / length;
plot Vol = Vol30day_Average;
}
Script G {
Input Length = 30;
def data = volume;
def data1 =
    fold a = 1
    to Length + 1
    with k = 0
    do k + data[a];
def Vol30Bars_Average = data1 / length;
plot Vol2 = Vol30Bars_Average;
}
def AvgVolume30_Day = F(lengthVolAvgLabel);
def AvgVolume30_Bars = G(lengthVolAvgLabel);
def today = volume(period = "DAY");
def curVolume = volume;
def diffFromAvg = today - AvgVolume30_Day;
def diffFromAvgBars = curVolume - AvgVolume30_Bars;
def percentDiffdays = Round((diffFromAvg / AvgVolume30_Day) * 100, 0);
def percentOf30Bar = Round((curVolume / AvgVolume30_Bars) * 100, 0);
def SellVolPercent = Round((Selling / Volume) * 100, 0);
def buyVolPercent = Round((Buying / Volume) * 100, 0);
def percentDiffBars = Round((diffFromAvgBars / AvgVolume30_Bars) * 100, 0);
def BarsBias = if (percentDiffBars <> ControlPercent) and (curVolume > AvgVolume30_Bars) then 1 else if (percentDiffBars <> ControlPercent) and (curVolume < AvgVolume30_Bars) then -1 else 0;
def DaysBias = if (percentDiffdays <> ControlPercent) and (today > AvgVolume30_Day) then 1 else if (percentDiffdays <> ControlPercent) and (curVolume < AvgVolume30_Day) then -1 else 0;
def percentdiff = (sellvolpercent - buyvolpercent);
def percentdiffAbs = absvalue(sellvolpercent - buyvolpercent);
def SellingAvgBars = average(selling,lengthAvgXBarsControl);
def BuyingAvgBars = average(buying,lengthAvgXBarsControl);
def sellavgpercent = (round(AvgVolume30_Bars,0) - Round(SellingAvgBars,0))/Round(AvgVolume30_Bars,0)*100;
def buyavgpercent = (round(AvgVolume30_Bars,0) - Round(BuyingAvgBars,0))/Round(AvgVolume30_Bars,0)*100;
def perdiffavg = absvalue(sellavgpercent - buyavgpercent);
plot VolAvg = Average(volume, lengthVolAvgPlot);
VolAvg.Setdefaultcolor(Color.Gray);
def MA = if type == type.SMP then SimpleMovingAvg(volume, length_HV) else MovAvgExponential(volume, length_HV);
plot HV = if (100 * ((volume / ma) - 1) >= hotPct) then ma else Double.NaN;
hv.SetDefaultColor( Color.CYAN);
hv.SetLineWeight(2) ;
hv.SetPaintingStrategy( PaintingStrategy.TRIANGLES);
def bn = barnumber();
def HighV = if (100 * ((volume / ma) - 1) >= hotPct) then 1 else 0;
def HighV_Foldcondition = if MarketOpen and (100 * ((volume / ma) - 1) >= hotPct) and (buyvolPercent > sellvolpercent) then 1
else if MarketOpen and (100 * ((volume / ma) - 1) >= hotPct) and (buyvolPercent < sellvolpercent) then -1 else 0;
input HighVLookback = 100;
def HighV_lookback = fold uu = 1 to HighVLookback with pp do pp + HighV_Foldcondition[uu];
#Labels
AddLabel(ShowBuySellPercent, "Current Bar Buy: " + BuyVolPercent + "%",
    (if (BuyVolPercent > Sellvolpercent) and highV then Color.cyan
         else if (BuyVolPercent > Sellvolpercent) and (BuyVolPercent >= ControlPercent) then Color.Green
              else if (BuyVolPercent < Sellvolpercent) then Color.Gray
                   else Color.current));
AddLabel(ShowBuySellPercent, "Current Bar Sell: " + SellVolPercent + "%",
    (if (BuyVolPercent < Sellvolpercent) and highV then Color.cyan
         else if (BuyVolPercent < Sellvolpercent) and (SellVolPercent >= ControlPercent) then Color.red
              else if (BuyVolPercent > Sellvolpercent) then Color.Gray
                   else Color.current));
AddLabel(ShowCurrentBarControl, "Current Bar Control: " + percentdiff + "%",
    (if (BuyVolPercent > Sellvolpercent) and highV then Color.cyan
         else if (BuyVolPercent > Sellvolpercent) and (percentdiff >= ControlPercent) then Color.green
              else if (BuyVolPercent < Sellvolpercent) and (percentdiff >= ControlPercent) then Color.red          
                   else if (percentdiff < ControlPercent) then Color.Gray
                       else Color.current));

AddLabel(ShowTodayVolume,
if (DaysBias == 1) then "Todays Volume: " + (today) + " | " +  absvalue(percentDiffdays) + "% Above " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == -1) then "Todays Volume: " + (today) + " | " +  absvalue(percentDiffdays) + "% Below " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == 0) and (today > AvgVolume30_Bars) then "Todays Volume: " + (today) + " | " +  absvalue(percentDiffdays) + "% above " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == 0) and (today < AvgVolume30_Bars) then "Todays Volume: " + (today) + " | " +  absvalue(percentDiffdays) + "% below " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else "Todays Volume: " + (today) + " | " + absvalue(percentDiffdays) + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_day, 0)+ ")",
(if (DaysBias == 1) then Color.green
    else if (DaysBias == -1) then Color.RED
        else if (DaysBias == 0) and (curVolume > AvgVolume30_Day) then color.orange
            else if (DaysBias == 0) and (curVolume < AvgVolume30_Day) then color.orange        
                else color.light_gray));
AddLabel(ShowBarVolume,
if (BarsBias == 1) then "Current Bar Volume: " + (curVolume) + " | " +  absvalue(percentDiffBars) + "% Above " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == -1) then "Current Bar Volume: " + (curVolume) + " | " +  absvalue(percentDiffBars) + "% Below " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == 0) and (curVolume > AvgVolume30_Bars) then "Current Bar Volume: " + (curVolume) + " | " +  absvalue(percentDiffBars) + "% above " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == 0) and (curVolume < AvgVolume30_Bars) then "Current Bar Volume: " + (curVolume) + " | " +  absvalue(percentDiffBars) + "% below " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else "Current Bar Volume: " + (curVolume) + " | " + absvalue(percentDiffBars) + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")",  
(if (BarsBias == 1) then Color.green
    else if (BarsBias == -1) then Color.RED
        else if (BarsBias == 0) and (curVolume > AvgVolume30_Bars) then color.orange
            else if (BarsBias == 0) and (curVolume < AvgVolume30_Bars) then color.orange        
                else Color.light_gray));

addlabel(ShowBuySellPercentAvgXBars,lengthAvgXBarsControl + " Bar Average Buy: " + round(buyavgpercent,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.light_green
    else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Gray          
         else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
             else Color.current));
addlabel(ShowBuySellPercentAvgXBars,lengthAvgXBarsControl + " Bar Average Sell: " + round(sellavgpercent,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.gray
    else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Light_red          
        else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
             else Color.current));
addlabel(ShowControlAvgXBars,lengthAvgXBarsControl + " Bar Average Control: " + round(perdiffavg,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.light_green
    else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Light_red          
        else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
             else Color.current));





#

So glad someone did an updated version, thank you. Are you able to give a breakdown of the differences/wat they do. I see there's the 'control' % but unsure what that is. I am also trying to reorganize the lables by how they show up ex. curretnly it goes current buy%, current sell%, current control. Is there a way to say put the total current volume first then current sell % etc.?

Thanks in advance.
 
So glad someone did an updated version, thank you. Are you able to give a breakdown of the differences/wat they do. I see there's the 'control' % but unsure what that is. I am also trying to reorganize the lables by how they show up ex. curretnly it goes current buy%, current sell%, current control. Is there a way to say put the total current volume first then current sell % etc.?

Thanks in advance.

Swapped them around and added headings incase you need to swap them around further. the "control %" is just the buy % minus the sell % or vis versa (depending on if sell % is greather than buy% or vis versa) to show "who is in control".

Code:
# HORSERIDER VOLUME V3 - @HODL
# Volume Buy Sell Pressure with Hot Percent for ThinkorSwim
# Show total volume in gray.  Buying volume in green.  Sell Volume in red.
# Volume average is gray line.
# Specified percent over average volume is cyan triangles.
# Horserider 12/30/2019 derived from some already existing studies.
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © sudoMode
#indicator(title = 'Pressure Gauge', shorttitle = 'Equilibrium', overlay = false)
# Converted and mod by Sam4Cok@Samer800    - 05/2023

declare lower;

#Inputs
input ControlPercent = 20; #hint above or below this value colors label
input ControlAvgPercent = 10;
input lengthVolAvgLabel = 30;
input lengthAvgXBarsControl = 30; #hint shows who is in control over X bars
input HotPct = 150.0; #hint total volume of bar greater than hotpct = cyan triangle
input ShowTodayVolume =  yes;
input ShowBarVolume = yes;
input ShowBuySellPercent = yes;
input ShowBuySellPercentAvgXBars = yes;
input ShowCurrentBarControl = yes;
input ShowControlAvgXBars = yes;
input type = { default SMP, EXP } ;
#Definitions
def lengthVolAvgPlot = 21;
def tradeDaytimeOnly = yes; #hint tradeDaytimeOnly: (IntraDay Only) Only perform trades during hours stated
def OpenTime = 0930; #hint OpenTime: Opening time of market
def CloseTime = 1600; #hint CloseTime: Closing time of market
def length_HV = 20 ;
def Begin = SecondsFromTime(OpenTime);
def End = SecondsTillTime(CloseTime);
def isIntraDay = if GetAggregationPeriod() > 14400000 or GetAggregationPeriod() == 0 then 0 else 1;
def MarketOpen = if !tradeDaytimeOnly or !isIntraDay then 1 else if tradeDaytimeOnly and isIntraDay and Begin > 0 and End > 0 then 1 else 0;
def na = Double.NaN;
#Horserider Volume
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);
Plot SellVol = selling;
SellVol.setPaintingStrategy(PaintingStrategy.Histogram);
SellVol.SetDefaultColor(Color.Red);
SellVol.HideTitle();
SellVol.HideBubble();
SellVol.SetLineWeight(1);
plot TV =  volume;
TV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
TV.SetDefaultColor(Color.GRAY);
TV.SetLineWeight(1);
Plot BuyVol = buying;
BuyVol.setPaintingStrategy(PaintingStrategy.Histogram);
BuyVol.SetDefaultColor(Color.Green);
BuyVol.HideTitle();
BuyVol.HideBubble();
BuyVol.SetLineWeight(5);
Script F {
Input Length = 30;
def data = volume(period = "DAY");
def data1 =
    fold a = 1
    to Length + 1
    with K = 0
    do K + data[a];
def Vol30day_Average = data1 / length;
plot Vol = Vol30day_Average;
}
Script G {
Input Length = 30;
def data = volume;
def data1 =
    fold a = 1
    to Length + 1
    with k = 0
    do k + data[a];
def Vol30Bars_Average = data1 / length;
plot Vol2 = Vol30Bars_Average;
}
def AvgVolume30_Day = F(lengthVolAvgLabel);
def AvgVolume30_Bars = G(lengthVolAvgLabel);
def today = volume(period = "DAY");
def curVolume = volume;
def diffFromAvg = today - AvgVolume30_Day;
def diffFromAvgBars = curVolume - AvgVolume30_Bars;
def percentDiffdays = Round((diffFromAvg / AvgVolume30_Day) * 100, 0);
def percentOf30Bar = Round((curVolume / AvgVolume30_Bars) * 100, 0);
def SellVolPercent = Round((Selling / Volume) * 100, 0);
def buyVolPercent = Round((Buying / Volume) * 100, 0);
def percentDiffBars = Round((diffFromAvgBars / AvgVolume30_Bars) * 100, 0);
def BarsBias = if (percentDiffBars <> ControlPercent) and (curVolume > AvgVolume30_Bars) then 1 else if (percentDiffBars <> ControlPercent) and (curVolume < AvgVolume30_Bars) then -1 else 0;
def DaysBias = if (percentDiffdays <> ControlPercent) and (today > AvgVolume30_Day) then 1 else if (percentDiffdays <> ControlPercent) and (curVolume < AvgVolume30_Day) then -1 else 0;
def percentdiff = (sellvolpercent - buyvolpercent);
def percentdiffAbs = absvalue(sellvolpercent - buyvolpercent);
def SellingAvgBars = average(selling,lengthAvgXBarsControl);
def BuyingAvgBars = average(buying,lengthAvgXBarsControl);
def sellavgpercent = (round(AvgVolume30_Bars,0) - Round(SellingAvgBars,0))/Round(AvgVolume30_Bars,0)*100;
def buyavgpercent = (round(AvgVolume30_Bars,0) - Round(BuyingAvgBars,0))/Round(AvgVolume30_Bars,0)*100;
def perdiffavg = absvalue(sellavgpercent - buyavgpercent);
plot VolAvg = Average(volume, lengthVolAvgPlot);
VolAvg.Setdefaultcolor(Color.Gray);
def MA = if type == type.SMP then SimpleMovingAvg(volume, length_HV) else MovAvgExponential(volume, length_HV);
plot HV = if (100 * ((volume / ma) - 1) >= hotPct) then ma else Double.NaN;
hv.SetDefaultColor( Color.CYAN);
hv.SetLineWeight(2) ;
hv.SetPaintingStrategy( PaintingStrategy.TRIANGLES);
def bn = barnumber();
def HighV = if (100 * ((volume / ma) - 1) >= hotPct) then 1 else 0;
def HighV_Foldcondition = if MarketOpen and (100 * ((volume / ma) - 1) >= hotPct) and (buyvolPercent > sellvolpercent) then 1
else if MarketOpen and (100 * ((volume / ma) - 1) >= hotPct) and (buyvolPercent < sellvolpercent) then -1 else 0;
input HighVLookback = 100;
def HighV_lookback = fold uu = 1 to HighVLookback with pp do pp + HighV_Foldcondition[uu];
#Labels
##############################################
## TODAYS VOLUME LABEL
##############################################
AddLabel(ShowTodayVolume,
if (DaysBias == 1) then "Todays Volume: " + (today) + " | " +  absvalue(percentDiffdays) + "% Above " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == -1) then "Todays Volume: " + (today) + " | " +  absvalue(percentDiffdays) + "% Below " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == 0) and (today > AvgVolume30_Bars) then "Todays Volume: " + (today) + " | " +  absvalue(percentDiffdays) + "% above " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == 0) and (today < AvgVolume30_Bars) then "Todays Volume: " + (today) + " | " +  absvalue(percentDiffdays) + "% below " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else "Todays Volume: " + (today) + " | " + absvalue(percentDiffdays) + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_day, 0)+ ")",
(if (DaysBias == 1) then Color.green
    else if (DaysBias == -1) then Color.RED
        else if (DaysBias == 0) and (curVolume > AvgVolume30_Day) then color.orange
            else if (DaysBias == 0) and (curVolume < AvgVolume30_Day) then color.orange      
                else color.light_gray));
##############################################
## CURRENT BUY % LABEL
##############################################
                AddLabel(ShowBuySellPercent, "Current Bar Buy: " + BuyVolPercent + "%",
    (if (BuyVolPercent > Sellvolpercent) and highV then Color.cyan
         else if (BuyVolPercent > Sellvolpercent) and (BuyVolPercent >= ControlPercent) then Color.Green
              else if (BuyVolPercent < Sellvolpercent) then Color.Gray
                   else Color.current));
##############################################
## CURRENT SELL % LABEL
##############################################
AddLabel(ShowBuySellPercent, "Current Bar Sell: " + SellVolPercent + "%",
    (if (BuyVolPercent < Sellvolpercent) and highV then Color.cyan
         else if (BuyVolPercent < Sellvolpercent) and (SellVolPercent >= ControlPercent) then Color.red
              else if (BuyVolPercent > Sellvolpercent) then Color.Gray
                   else Color.current));
###########################################################
## CURRENT CONTROL % LABEL (Buy % minus Sell % or Sell % mins Buy %)
###########################################################
AddLabel(ShowCurrentBarControl, "Current Bar Control: " + percentdiff + "%",
    (if (BuyVolPercent > Sellvolpercent) and highV then Color.cyan
         else if (BuyVolPercent > Sellvolpercent) and (percentdiff >= ControlPercent) then Color.green
              else if (BuyVolPercent < Sellvolpercent) and (percentdiff >= ControlPercent) then Color.red        
                   else if (percentdiff < ControlPercent) then Color.Gray
                       else Color.current));
##############################################
## CURRENT BAR VOLUME
##############################################
AddLabel(ShowBarVolume,
if (BarsBias == 1) then "Current Bar Volume: " + (curVolume) + " | " +  absvalue(percentDiffBars) + "% Above " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == -1) then "Current Bar Volume: " + (curVolume) + " | " +  absvalue(percentDiffBars) + "% Below " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == 0) and (curVolume > AvgVolume30_Bars) then "Current Bar Volume: " + (curVolume) + " | " +  absvalue(percentDiffBars) + "% above " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == 0) and (curVolume < AvgVolume30_Bars) then "Current Bar Volume: " + (curVolume) + " | " +  absvalue(percentDiffBars) + "% below " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else "Current Bar Volume: " + (curVolume) + " | " + absvalue(percentDiffBars) + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")",
(if (BarsBias == 1) then Color.green
    else if (BarsBias == -1) then Color.RED
        else if (BarsBias == 0) and (curVolume > AvgVolume30_Bars) then color.orange
            else if (BarsBias == 0) and (curVolume < AvgVolume30_Bars) then color.orange      
                else Color.light_gray));
######################################################################################
## AVERAGE BUY % OF X NUMBER OF BARS (ADJUSTABLE LENGTH IN SETTINGS - 30 IS DEFAULT)
######################################################################################
addlabel(ShowBuySellPercentAvgXBars,lengthAvgXBarsControl + " Bar Average Buy: " + round(buyavgpercent,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.light_green
    else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Gray        
         else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
             else Color.current));
#######################################################################################
## AVERAGE SELL % OF X NUMBER OF BARS (ADJUSTABLE LENGTH IN SETTINGS - 30 IS DEFAULT)
#######################################################################################
addlabel(ShowBuySellPercentAvgXBars,lengthAvgXBarsControl + " Bar Average Sell: " + round(sellavgpercent,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.gray
    else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Light_red        
        else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
             else Color.current));
#########################################################################################
## AVERAGE CONTROL % OF X NUMBER OF BARS (ADJUSTABLE LENGTH IN SETTINGS - 30 IS DEFAULT)
#########################################################################################
addlabel(ShowControlAvgXBars,lengthAvgXBarsControl + " Bar Average Control: " + round(perdiffavg,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.light_green
    else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Light_red        
        else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
             else Color.current));




#
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
450 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top