All Buy / Sell Volume Pressure Indicators & Labels For ThinkOrSwim

Thank you! Is there any way to separate the information possibly when I hover the candle? or maybe just show the info over each volume bar? Also, How can I change it from 2nd aggregation so that it can work on weekly and monthly time frames? Thank you!

Screenshot-2022-09-09-141710.png

a version to show bubbles above each vol bar

Code:
input show = yes; 
#volume 
#buy vol buying 
#buy vol % 
#sell vol % 
#sell vol selling 
# draw bubbles in reverse order, on same point, to have them stack

def v = volume;
AddChartBubble(show, v, selling, color.red, yes); 
AddChartBubble(show, v,  round((selling/volume) *100,1) + "%", color.red, yes);
AddChartBubble(show, v,  round((buying/volume) *100,1) + "%", color.green, yes); 
AddChartBubble(show, v, buying, color.green, yes); 
AddChartBubble(show, v, volume, color.white, yes); 
#
 

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

I know versions of this are popular across the internet, but I can't seem to find it on these forums. Anyway, it's been modified to allow it to work with aggregation periods greater than DAY and features an option for custom aggregation periods. If something similar to this has already been submitted, then I apologize for cluttering the forums.


# Original author: Unknown
# Modified by 7of9
# Further modified Magnetar513

declare on_volume;

#Inputs

input Show30PeriodAvg = yes;
input ShowTodayVolume = yes;
input ShowPercentOf30PeriodAvg = yes;
input UnusualVolumePercent = 200;
input Show30BarAvg = yes;
input ShowCurrentBar = yes;
input ShowPercentOf30BarAvg = yes;
input ShowSellVolumePercent = yes;
input allowCustomAggPeriod= no;
input customAggPeriod= AggregationPeriod.DAY; #Only works if allowCustomAggPeriod== yes
def chartAggPeriod= GetAggregationPeriod();
def aggPeriod= if !allowCustomAggPeriod and chartAggPeriod> AggregationPeriod.DAY then chartAggPeriod else if !allowCustomAggPeriod and chartAggPeriod<= AggregationPeriod.DAY then AggregationPeriod.DAY else customAggPeriod;

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(CreateColor(255,69,0));
SellVol.HideTitle();
SellVol.HideBubble();
SellVol.SetLineWeight(5);

# Total Volume

Plot BuyVol = volume;
BuyVol.setPaintingStrategy(PaintingStrategy.Histogram);
BuyVol.SetDefaultColor(CreateColor(60, 235, 60));
BuyVol.HideTitle();
BuyVol.HideBubble();
BuyVol.SetLineWeight(5);

#Volume Data

def volLast30PeriodAvg = (volume(period = aggPeriod)[1] + volume(period = aggPeriod)[2] + volume(period = aggPeriod)[3] + volume(period = aggPeriod)[4] + volume(period = aggPeriod)[5] + volume(period = aggPeriod)[6] + volume(period = aggPeriod)[7] + volume(period = aggPeriod)[8] + volume(period = aggPeriod)[9] + volume(period = aggPeriod)[10] + volume(period = aggPeriod)[11] + volume(period = aggPeriod)[12] + volume(period = aggPeriod)[13] + volume(period = aggPeriod)[14] + volume(period = aggPeriod)[15] + volume(period = aggPeriod)[16] + volume(period = aggPeriod)[17] + volume(period = aggPeriod)[18] + volume(period = aggPeriod)[19] + volume(period = aggPeriod)[20] + volume(period = aggPeriod)[21] + volume(period = aggPeriod)[22] + volume(period = aggPeriod)[23] + volume(period = aggPeriod)[24] + volume(period = aggPeriod)[25] + volume(period = aggPeriod)[26] + volume(period = aggPeriod)[27] + volume(period = aggPeriod)[28] + volume(period = aggPeriod)[29] + volume(period = aggPeriod)[30]) / 30;
def today = volume(period = aggPeriod);
def percentOf30Period = Round((today / volLast30PeriodAvg) * 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(Show30PeriodAvg, if aggPeriod== AggregationPeriod.DAY then "Avg 30 Days: " + Round(volLast30PeriodAvg, 0) else "Avg 30 Periods: " + Round(volLast30PeriodAvg, 0), Color.LIGHT_GRAY);

AddLabel(ShowTodayVolume, if aggPeriod== AggregationPeriod.DAY then "Today: " + today else "Current Period: " + today, (if percentOf30Period >= UnusualVolumePercent then CreateColor(60, 235, 60) else if percentOf30Period >= 100 then CreateColor(195, 235, 60) else Color.LIGHT_GRAY));

AddLabel(ShowPercentOf30PeriodAvg, percentOf30Period + "%", (if percentOf30Period >= UnusualVolumePercent then CreateColor(60, 235, 60) else if percentOf30Period >= 100 then CreateColor(195, 235, 60) else Color.LIGHT_GRAY) );

AddLabel(Show30BarAvg, "Avg 30 Bars: " + Round(avg30Bars, 0), Color.LIGHT_GRAY);

AddLabel(ShowCurrentBar, "Cur Bar: " + curVolume, (if percentOf30Bar >= UnusualVolumePercent then CreateColor(60, 235, 60) else if PercentOf30Bar >= 100 then CreateColor(195, 235, 60) else Color.LIGHT_GRAY));

AddLabel(ShowPercentOf30BarAvg, PercentOf30Bar + "%", (if PercentOf30Bar >= UnusualVolumePercent then CreateColor(60, 235, 60) else if PercentOf30Bar >= 100 then CreateColor(195, 235, 60) else Color.LIGHT_GRAY) );

AddLabel(ShowSellVolumePercent, "Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 51 then CreateColor(255, 235, 100) else if SellVolPercent < 49 then CreateColor(195, 235, 60) else Color.Light_Gray));
 
Hey everyone,

On thinkorswim, the volume indicator shows green or red based on buying on selling but its above 0.

Is there a indicator which only shows green above 0 (in case of buying) and red below 0 (in case of selling)? I feel this type of volume indicator will be much easier to read than the current volume indicator on thinkorswim.

Thanks in advance!
 
Hey everyone,

On thinkorswim, the volume indicator shows green or red based on buying on selling but its above 0.

Is there a indicator which only shows green above 0 (in case of buying) and red below 0 (in case of selling)? I feel this type of volume indicator will be much easier to read than the current volume indicator on thinkorswim.

Thanks in advance!

Just take the code in the first post of this link https://usethinkscript.com/threads/all-buy-sell-pressure-indicators-labels-for-thinkorswim.8466/ and where it plots SV, put a minus sign in front of Selling and plot the script in a lower panel, not the volume panel, but another lower panel.

Here is an image of what it should look like when you are done.

Screenshot-2022-10-24-141722.png
 
Last edited by a moderator:
Any way to make the volume pressure indicator Multiple Time Frame?

Making something MTF is merely creating an input for the aggregation period (agg) and then adding (period=agg) to all of the price variables in the code.

Example
Code:
input agg = aggregationperiod.five_min;
def close = close(period=agg);

Here is the volume pressure with the modifications

Ruby:
#Chris' Enhanced Volume V.2 /w Uptick/Downtick

declare on_volume;

###############
#DPL CRITERIA #
###############
input agg = aggregationPeriod.fIVE_MIN;
input Audible_Alert = yes;
def Deviation_Length = 60;
def Deviate = 2;
def volumestdev = RelativeVolumeStDev(length = Deviation_Length);
def abovedev = volumestdev >= Deviate;
def belowdev = volumestdev <= Deviate;

############
# DPL BARS #
############
def increase = volume(period=agg) > volume(period=agg)[1];
def devincrease = increase and abovedev;
def decrease = volume(period=agg) < volume(period=agg)[1];
def devdecrease = decrease and abovedev;

##############################
# UPTICK / DOWNTICK CRITERIA #
##############################
def O = open(period=agg);
def H = high(period=agg);
def C = close(period=agg);
def L = low(period=agg);
def V = volume(period=agg);
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);

##################
# Selling Volume #
##################
plot SV = Selling;
SV.DefineColor("Decrease", Color.rED);
SV.DefineColor("DevDecrease", Color.pink);
SV.AssignValueColor(if devdecrease then SV.Color("DevDecrease") else SV.Color("Decrease"));
SV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(5);

#################
# Buying Volume #
#################
DefineGlobalColor("LabelGreen",  CreateColor(0, 165, 0)) ;
plot BV = Buying;
BV.DefineColor("Increase", GlobalColor("LabelGreen"));
BV.DefineColor("DevIncrease", Color.light_GREEN);
BV.AssignValueColor(if devincrease then BV.Color("DevIncrease") else BV.Color("Increase"));
BV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(5);

#################
# Adding Volume Labels #
#################

input Show_Labels = yes;
AddLabel(Show_Labels, "Buy Vol = " + Round(Buying, 0),
if Buying > Selling then GlobalColor("LabelGreen") else color.red);

AddLabel(Show_Labels, "Buy %: " + Round((Buying/(Buying+Selling))*100,2), If (Buying/(Buying+Selling))*100 > 60 then GlobalColor("LabelGreen") else color.red);

AddLabel(Show_Labels, "Sell Vol = " + Round(Selling, 0),
if Selling > Buying then GlobalColor("LabelGreen") else color.red);

AddLabel(Show_Labels, "Sell %: " + Round((Selling/(Selling+Buying))*100,2), If (Selling/(Selling+Buying))*100 > 60 then GlobalColor("LabelGreen") else color.RED);
 
Hey all!

I recently created the following script to say that if the RSI is below a specified threshold and the VWAP is below the specified threshold, then plot a "Buy" signal on the chart. Vice versa for a "Sell" signal. I like the way this turned out, however, I don't like when there are a cluster of these signals together due to the signal repeating on several bars next to each other. Would there be a way to say if a "Buy" signal is produced on the current bar, but there is already a "Buy" signal on the previous bar, then do not plot the current "Buy" signal? Vice versa for the "Sell" signal. I am just looking to clean up the plotting of the indicator a bit.

Here is the script:

Code:
input timeFrame = {default Quarter, Day, Week, Month, Year, Minute, Hour, Chart, "Opt Exp", Bar};
input BandType = {default Standard, "1/4 Day Range", "3x Avg Bar Range", ThinkScripter, None};
input HideSdLines = no;


def cap = GetAggregationPeriod();
def errorInAggregation =
    timeFrame == timeFrame.Day and cap >= AggregationPeriod.WEEK or
    timeFrame == timeFrame.Week and cap >= AggregationPeriod.MONTH;
Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");

def yyyyMmDd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def year = GetYear();
def day_number = DaysFromDate(First(yyyyMmDd)) + GetDayOfWeek(First(yyyyMmDd));
def dom = GetDayOfMonth(yyyyMmDd);
def dow = GetDayOfWeek(yyyyMmDd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
def periodIndx;
def qtr = (GetMonth() - 1) % 3;
switch (timeFrame) {
case Chart:
    periodIndx = 0;
case Minute:
    periodIndx = Floor(seconds / 60 + day_number * 24 * 60);
case Hour:
    periodIndx = Floor(seconds / 3600 + day_number * 24);
case Day:
    periodIndx = CountTradingDays(Min(First(yyyyMmDd), yyyyMmDd), yyyyMmDd) - 1;
case Week:
    periodIndx = Floor(day_number / 7);
case Month:
    periodIndx = Floor(month - First(month));
case Year:
    periodIndx = Floor(year - First(year));
case Quarter:

    periodIndx = qtr == 0 and qtr[1] != 0;
case "Opt Exp":
    periodIndx = exp_opt - First(exp_opt);
case Bar:
    periodIndx = BarNumber() - 1;
}
def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);

def volumeSum;
def volumeVwapSum;
def volumeVwap2Sum;

if (isPeriodRolled) {
    volumeSum = volume;
    volumeVwapSum = volume * vwap;
    volumeVwap2Sum = volume * Sqr(vwap);
} else {
    volumeSum = CompoundValue(1, volumeSum[1] + volume, volume);
    volumeVwapSum = CompoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);
    volumeVwap2Sum = CompoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));
}
def price = volumeVwapSum / volumeSum;

def deviation;
switch (BandType) {
case Standard:
    deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(price), 0));
case "1/4 Day Range":
    deviation = Sqrt(AbsValue(high(Period = timeFrame) - low(Period = timeFrame)) * .25);
case "3x Avg Bar Range":
    deviation = Sqrt(Average(TrueRange(high,  close,  low),  20) * 3);
case ThinkScripter:
    deviation = Sqrt(TotalSum(Sqr(((open + high + low + close) / 4) - price) * volume) / TotalSum(volume));
case None:
    deviation = Double.NaN;
}

plot VWAP = price;

VWAP.SetStyle(Curve.POINTS);
VWAP.SetLineWeight(2);
VWAP.SetDefaultColor(Color.MAGENTA);


input numDevUp1 = 2;

plot Upperband = VWAP + numDevUp1 * deviation;
plot Lowerband = VWAP - numDevUp1 * deviation;

Upperband.SetDefaultColor(Color.UPTICK);
Lowerband.SetDefaultColor(Color.UPTICK);


Upperband.SetStyle(Curve.LONG_DASH);
Lowerband.SetStyle(Curve.LONG_DASH);

VWAP.HideBubble();
Upperband.HideBubble();
Lowerband.HideBubble();


Upperband.SetHiding(HideSdLines);
Lowerband.SetHiding(HideSdLines);


input length = 14;
input oversold = 30;
input overbought = 70;
input barprice = close;
input averageType = AverageType.WILDERS;


input LabelSell = yes;
input LabelBuy = yes;


def NetChgAvg = MovingAverage(averageType, barprice - barprice[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(barprice - barprice[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);


def BuySignal = barprice <= lowerband and RSI <= oversold ;
def SellSignal = barprice >= upperband and RSI >= overbought;



AddChartBubble(BuySignal and LabelBuy, low, "BUY", Color.LIGHT_GREEN, no);

AddChartBubble(SellSignal and LabelSell, high, "SELL", Color.LIGHT_RED, yes);

Thank you for the help in advance!
 
Hey all!

I recently created the following script to say that if the RSI is below a specified threshold and the VWAP is below the specified threshold, then plot a "Buy" signal on the chart. Vice versa for a "Sell" signal. I like the way this turned out, however, I don't like when there are a cluster of these signals together due to the signal repeating on several bars next to each other. Would there be a way to say if a "Buy" signal is produced on the current bar, but there is already a "Buy" signal on the previous bar, then do not plot the current "Buy" signal? Vice versa for the "Sell" signal. I am just looking to clean up the plotting of the indicator a bit.

Here is the script:

Code:
input timeFrame = {default Quarter, Day, Week, Month, Year, Minute, Hour, Chart, "Opt Exp", Bar};
input BandType = {default Standard, "1/4 Day Range", "3x Avg Bar Range", ThinkScripter, None};
input HideSdLines = no;


def cap = GetAggregationPeriod();
def errorInAggregation =
    timeFrame == timeFrame.Day and cap >= AggregationPeriod.WEEK or
    timeFrame == timeFrame.Week and cap >= AggregationPeriod.MONTH;
Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");

def yyyyMmDd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def year = GetYear();
def day_number = DaysFromDate(First(yyyyMmDd)) + GetDayOfWeek(First(yyyyMmDd));
def dom = GetDayOfMonth(yyyyMmDd);
def dow = GetDayOfWeek(yyyyMmDd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
def periodIndx;
def qtr = (GetMonth() - 1) % 3;
switch (timeFrame) {
case Chart:
    periodIndx = 0;
case Minute:
    periodIndx = Floor(seconds / 60 + day_number * 24 * 60);
case Hour:
    periodIndx = Floor(seconds / 3600 + day_number * 24);
case Day:
    periodIndx = CountTradingDays(Min(First(yyyyMmDd), yyyyMmDd), yyyyMmDd) - 1;
case Week:
    periodIndx = Floor(day_number / 7);
case Month:
    periodIndx = Floor(month - First(month));
case Year:
    periodIndx = Floor(year - First(year));
case Quarter:

    periodIndx = qtr == 0 and qtr[1] != 0;
case "Opt Exp":
    periodIndx = exp_opt - First(exp_opt);
case Bar:
    periodIndx = BarNumber() - 1;
}
def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);

def volumeSum;
def volumeVwapSum;
def volumeVwap2Sum;

if (isPeriodRolled) {
    volumeSum = volume;
    volumeVwapSum = volume * vwap;
    volumeVwap2Sum = volume * Sqr(vwap);
} else {
    volumeSum = CompoundValue(1, volumeSum[1] + volume, volume);
    volumeVwapSum = CompoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);
    volumeVwap2Sum = CompoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));
}
def price = volumeVwapSum / volumeSum;

def deviation;
switch (BandType) {
case Standard:
    deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(price), 0));
case "1/4 Day Range":
    deviation = Sqrt(AbsValue(high(Period = timeFrame) - low(Period = timeFrame)) * .25);
case "3x Avg Bar Range":
    deviation = Sqrt(Average(TrueRange(high,  close,  low),  20) * 3);
case ThinkScripter:
    deviation = Sqrt(TotalSum(Sqr(((open + high + low + close) / 4) - price) * volume) / TotalSum(volume));
case None:
    deviation = Double.NaN;
}

plot VWAP = price;

VWAP.SetStyle(Curve.POINTS);
VWAP.SetLineWeight(2);
VWAP.SetDefaultColor(Color.MAGENTA);


input numDevUp1 = 2;

plot Upperband = VWAP + numDevUp1 * deviation;
plot Lowerband = VWAP - numDevUp1 * deviation;

Upperband.SetDefaultColor(Color.UPTICK);
Lowerband.SetDefaultColor(Color.UPTICK);


Upperband.SetStyle(Curve.LONG_DASH);
Lowerband.SetStyle(Curve.LONG_DASH);

VWAP.HideBubble();
Upperband.HideBubble();
Lowerband.HideBubble();


Upperband.SetHiding(HideSdLines);
Lowerband.SetHiding(HideSdLines);


input length = 14;
input oversold = 30;
input overbought = 70;
input barprice = close;
input averageType = AverageType.WILDERS;


input LabelSell = yes;
input LabelBuy = yes;


def NetChgAvg = MovingAverage(averageType, barprice - barprice[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(barprice - barprice[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);


def BuySignal = barprice <= lowerband and RSI <= oversold ;
def SellSignal = barprice >= upperband and RSI >= overbought;



AddChartBubble(BuySignal and LabelBuy, low, "BUY", Color.LIGHT_GREEN, no);

AddChartBubble(SellSignal and LabelSell, high, "SELL", Color.LIGHT_RED, yes);

Thank you for the help in advance!
In order to only show the bubble if it is not present on the previous bubble, change your bubble code to:
AddChartBubble(BuySignal and !BuySignal[1] and LabelBuy, low, "BUY", Color.LIGHT_GREEN, no);
 
hi gang, will be possible to add arrow instead the label? thanks in advance
Use this for arrows instead :)

Code:
input timeFrame = {default Quarter, Day, Week, Month, Year, Minute, Hour, Chart, "Opt Exp", Bar};
input BandType = {default Standard, "1/4 Day Range", "3x Avg Bar Range", ThinkScripter, None};
#input ShowCloud = yes;
input HideSdLines = no;


def cap = GetAggregationPeriod();
def errorInAggregation =
    timeFrame == timeFrame.Day and cap >= AggregationPeriod.WEEK or
    timeFrame == timeFrame.Week and cap >= AggregationPeriod.MONTH;
Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");

def yyyyMmDd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def year = GetYear();
def day_number = DaysFromDate(First(yyyyMmDd)) + GetDayOfWeek(First(yyyyMmDd));
def dom = GetDayOfMonth(yyyyMmDd);
def dow = GetDayOfWeek(yyyyMmDd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
def periodIndx;
def qtr = (GetMonth() - 1) % 3;
switch (timeFrame) {
case Chart:
    periodIndx = 0;
case Minute:
    periodIndx = Floor(seconds / 60 + day_number * 24 * 60);
case Hour:
    periodIndx = Floor(seconds / 3600 + day_number * 24);
case Day:
    periodIndx = CountTradingDays(Min(First(yyyyMmDd), yyyyMmDd), yyyyMmDd) - 1;
case Week:
    periodIndx = Floor(day_number / 7);
case Month:
    periodIndx = Floor(month - First(month));
case Year:
    periodIndx = Floor(year - First(year));
case Quarter:

    periodIndx = qtr == 0 and qtr[1] != 0;
case "Opt Exp":
    periodIndx = exp_opt - First(exp_opt);
case Bar:
    periodIndx = BarNumber() - 1;
}
def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);

def volumeSum;
def volumeVwapSum;
def volumeVwap2Sum;

if (isPeriodRolled) {
    volumeSum = volume;
    volumeVwapSum = volume * vwap;
    volumeVwap2Sum = volume * Sqr(vwap);
} else {
    volumeSum = CompoundValue(1, volumeSum[1] + volume, volume);
    volumeVwapSum = CompoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);
    volumeVwap2Sum = CompoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));
}
def price = volumeVwapSum / volumeSum;

def deviation;
switch (BandType) {
case Standard:
    deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(price), 0));
case "1/4 Day Range":
    deviation = Sqrt(AbsValue(high(Period = timeFrame) - low(Period = timeFrame)) * .25);
case "3x Avg Bar Range":
    deviation = Sqrt(Average(TrueRange(high,  close,  low),  20) * 3);
case ThinkScripter:
    deviation = Sqrt(TotalSum(Sqr(((open + high + low + close) / 4) - price) * volume) / TotalSum(volume));
case None:
    deviation = Double.NaN;
}

plot VWAP = price;

VWAP.SetStyle(Curve.POINTS);
VWAP.SetLineWeight(2);
VWAP.SetDefaultColor(Color.MAGENTA);


input numDevUp1 = 2;

plot Upperband = VWAP + numDevUp1 * deviation;
plot Lowerband = VWAP - numDevUp1 * deviation;

Upperband.SetDefaultColor(Color.UPTICK);
Lowerband.SetDefaultColor(Color.UPTICK);


Upperband.SetStyle(Curve.LONG_DASH);
Lowerband.SetStyle(Curve.LONG_DASH);

VWAP.HideBubble();
Upperband.HideBubble();
Lowerband.HideBubble();


Upperband.SetHiding(HideSdLines);
Lowerband.SetHiding(HideSdLines);


input length = 14;
input oversold = 30;
input overbought = 70;
input barprice = close;
input averageType = AverageType.WILDERS;


input LabelSell = yes;
input LabelBuy = yes;


def NetChgAvg = MovingAverage(averageType, barprice - barprice[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(barprice - barprice[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);


def BuySignal = barprice <= lowerband and RSI <= oversold ;
def SellSignal = barprice >= upperband and RSI >= overbought;


#AddChartBubble(BuySignal and !BuySignal[1] and LabelBuy, low, "BUY", Color.LIGHT_GREEN, no);

#AddChartBubble(SellSignal and !SellSignal[1] and LabelSell, high, "SELL", Color.LIGHT_RED, yes);

plot BuyArrow = BuySignal and !BuySignal[1] and LabelBuy;
plot SellArrow = SellSignal and !SellSignal[1] and LabelSell;

BuyArrow.SetDefaultColor(color.cyan);
BuyArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BuyArrow.SetLineWeight(2);

SellArrow.SetDefaultColor(color.magenta);
SellArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
SellArrow.SetLineWeight(2);
 
I'm looking to make an indictor that takes the change in price over X period of time divided by the change in volume over X period of time. I think a barchart style would be the most intuitive format, since it would be comparing candlesticks to volume bars. If anyone can help, I thank you greatly!

Edit: The specific math I would be looking for would look like this -> (candlestick open - candlestick close) / volume high -> over 5m timeframe
 
Last edited:
I'm looking to make an indictor that takes the change in price over X period of time divided by the change in volume over X period of time. I think a barchart style would be the most intuitive format, since it would be comparing candlesticks to volume bars. If anyone can help, I thank you greatly!

Edit: The specific math I would be looking for would look like this -> (candlestick open - candlestick close) / volume high -> over 5m timeframe



https://usethinkscript.com/threads/...labels-for-thinkorswim.8466/page-3#post-98416
It is in barchart format too.

VP is the sum of the comparison between the close and open over the high - low, weighted by the volume.

VPup occurs when the current Pricevolume is larger than the previous candle
When that happens and VP is negative, the histogram is light green.
When that happens and VP is negative, the histogram is light green.
VPdn is when it is smaller than the previous candle.
if VP is negative too , the histogram is light yellow ,
if the VP is positive , the histogram is red.

Zerobase is there to handle where there is no volume , literally .

Trendline ( the blue and white line in the background )
From TOS : Intertia Draws the linear regression curve using the least-squares method to approximate data for each set of bars defined by the length parameter. The resulting interpolation function for each set of bars is defined by equation: y = a * current_bar + b
From IBM :
Linear regression analysis is used to predict the value of a variable based on the value of another variable. The variable you want to predict is called the dependent variable. The variable you are using to predict the other variable's value is called the independent variable.

The trendline plot can be used to predict a change in trend . White Downtrend , Blue Uptrend


From
Mobius_ts
Monthly Top 1% Karma
+2·2 mo. ago
The study is a simple stochastic of price multiplied by volume. Which attempts to show more accurately the correlation between price and volume. I don't make suggestions for use of anything I post publicly. Every trader needs to decide what indicator, if any, meets their personal needs. Understanding the math in any indicator should be of first concern. You'd never risk money using anything or on anything you don't fully understand.
 
When we look at the movement of price in comparison to volume, it is called Volume Pressure.

You can start with these two scripts:
https://usethinkscript.com/threads/...ssure-indicators-labels-for-thinkorswim.8466/
https://usethinkscript.com/threads/...labels-for-thinkorswim.8466/page-3#post-98416
(there are a dozen variations in the above thread alone, see which ones work for you).

Here are the other Volume Pressure Threads on the forum:
https://usethinkscript.com/search/1...1&c[nodes][0]=3&c[title_only]=1&o=replies&g=1

You are correct. Volume Pressure is an indicator that provides an abundance of information for all types of traders.
For those that don't have lower chart real estate available, the above threads also include labels, watchlists, and scanner scripts.
Definitely a tool that belongs in every trader's toolbox.
@MerryDay , I found what I am looking for in your script https://usethinkscript.com/threads/...labels-for-thinkorswim.8466/page-3#post-98416

on post #50. I downloaded the script under “My Chris Enhanced Labels:” but I do not get the yellow Amateur Trading or the histogram bars. I downloaded the script on post #59 but get an error on the last line of code. I am looking for the code that shows the Amateur Trading. Thank you!
 
Any way to turn the MTF volume pressure percentage label into an oscillator so you can see the direction the volume pressure is going?
 
The only mention I found of your referenced indicator is from 2018 when Mobius shared it in the ToS ThinkScript Lounge.
His complete description on OneNote is:

It is a different take on Buy / Sell Volume Pressure
Most of the Buy / Sell Volume Pressure scripts on this forum look at Buying / Selling Pressure on a bar-by-bar basis.

Mobius takes the Buying / Selling Pressure and averages them over 21 bars.
He also adds an inertia line to filter chop.

I couldn't make his 21 length of bars work (except if you were looking at maybe a monthly chart)
When I changed the length to 12. It became a clearer trend tool.
This has some potential. Thank you for sharing.
oNld3V8.png

Compared to:
https://usethinkscript.com/threads/...cator-labels-for-thinkorswim.8466/#post-75452
https://usethinkscript.com/threads/...labels-for-thinkorswim.8466/page-3#post-98390
I use this on Thinkorswim.. to reiterate the fundamental signal this generates. It shows the Net change

I am laughing at myself.... I've had something called "mobius volume pressure" on my charts for years, and I've never figured it out. I tried a google, and haven't found anything. Anyone know anything about it?! http://tos.mx/Sw7p7Nw
Ruby:
# Volume Pressure
# Mobius
# Mobius at MyTrade
# V01.02.2010

declare lower;

input nVP = 12;
input VPdelta = 12;

plot VP = Sum(((close - open) / (high - low)) * volume, nVP);
def VPup = Average(VP, VPdelta)  >  Average(VP, VPdelta)[1];
def VPdn = Average(VP, VPdelta)  <  Average(VP, VPdelta)[1];
;
VP.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
VP.SetLineWeight(3);
VP.AssignValueColor(if VP < 0 and VPup
                                            then Color.LIGHT_GREEN
                                            else if VP > 0 and VPup
                                            then Color.GREEN
                                            else if VP > 0 and VPdn
                                            then Color.YELLOW
                                            else  Color.RED);

plot zerobase = if IsNaN(volume) then Double.NaN else 0;
zerobase.SetPaintingStrategy(PaintingStrategy.LINE);
zerobase.SetLineWeight(1);
zerobase.AssignValueColor(if IsAscending(VP, nVP)
                                                        then Color.GREEN
                                                        else  Color.RED);

plot TrendLine = Inertia(VP, 55);
TrendLine.SetLineWeight(3);
TrendLine.AssignValueColor(if Sum(TrendLine > TrendLine[1], 3) == 3
                                                          then Color.Blue                                                        else  Color.YELLOW);
Mobius's volume delta calculation is that it shows the average combination of net price movement x volume (either negative or positive) which is defined as VP, volume pressure up or down and sums it for a Volume Delta over 21 bars. You can then go to inputs and options and change the default settings to look at the print on the charts: the default is 12 NVP vs VPressure 21 periods. The user can alter it depending on scalping or trend trading. I would advise you can add in a useful Rate of Change in Volume in the same panel
example ROC 12 volume and see it track versus the actual directional Volume pressure indicator.. But remember this is actual trades. not Net Cumulative Delta of Bids and Asks that exists at Tradingview.com... Actually TOS does not provide that information.But some creative coders try workarounds that are similar to the Bid Ask net calculation at Tradingview.. .. they are stlll lagging indicators. No perfect signal exists
 
Can anyone here convert this into a percentage of buy sell rather than total shares traded?

declare lower;

input AvgTypes = averageType.EXPONENTIAL;
input BuyVolumeAvgLength = 18;
input SellVolumeAvgLength = 18;

def buyvol = Round(((high - open) + (close - low)) / 2 / (high - low) * volume(), 0);
def sellvol = Round(((low - open) + (close - high)) / 2 / (high - low) * volume(), 0);
def buyvolavg = MovingAverage(AvgTypes, buyvol, BuyVolumeAvgLength);
def sellvolavg = MovingAverage(AvgTypes, absValue(sellvol), SellVolumeAvgLength);

plot BuyVolumeAverage = buyvolavg;
plot SellVolumeAverage = sellvolavg;

BuyVolumeAverage.setDefaultColor(color.GREEN);
SellVolumeAverage.setDefaultColor(color.RED);
Thanks for this. I've been playing with some code to spot divergences between the averages,, getting some interesting results

def divgBull= buyvol>buyvol[1] and sellvol<sellvol[1];
def divgBear= buyvol<buyvol[1] and sellvol>sellvol[1];

def divgBull1= buyvolumeaverage>buyvolumeAverage[1] and sellvolumeAverage<sellvolumeAverage[1];
def divgBear1= buyvolumeAverage<buyvolumeAverage[1] and sellvolumeAverage>sellvolumeAverage[1];

assignpricecolor(if divgbear and divgbear1 then color.magenta else if divgbull1 then color.green else if divgbear1 then color.red else color.current);
 
Thanks for this. I've been playing with some code to spot divergences between the averages,, getting some interesting results

def divgBull= buyvol>buyvol[1] and sellvol<sellvol[1];
def divgBear= buyvol<buyvol[1] and sellvol>sellvol[1];

def divgBull1= buyvolumeaverage>buyvolumeAverage[1] and sellvolumeAverage<sellvolumeAverage[1];
def divgBear1= buyvolumeAverage<buyvolumeAverage[1] and sellvolumeAverage>sellvolumeAverage[1];

assignpricecolor(if divgbear and divgbear1 then color.magenta else if divgbull1 then color.green else if divgbear1 then color.red else color.current);
What is this an add on to the current script or a replacement?
 
Buy and Sell Volume Pressure Indicator for higher TimeFrames (Weekly, Monthly etc.)
Anyone know how to modify this Indicator to view / use it on higher time frames

Code:
#Total Volume for Regular Trading Day

AddLabel(yes, "Total Vol: " + volume(period = AggregationPeriod.DAY), Color.white);





#Volume of Current Bar

AddLabel(yes, "CurrentBar Vol: " + volume, Color.LIGHT_GREEN);





#Volume of the Last Bar

AddLabel(yes, "LastBar Vol: " + volume[1], Color.LIGHT_ORANGE);







#PreMarket Volume

input startTime = 0400;

input endTime = 0929;

def startCounter = SecondsFromTime(startTime);

def endCounter = SecondsTillTime(endTime);

def targetPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;

rec volumeTotal = if targetPeriod and !targetPeriod[1] then volume else if targetPeriod then volumeTotal[1] + volume else volumeTotal[1];

AddLabel(yes, Concat("PreMrket Vol: ", volumeTotal), Color.VIOLET);







#Volume color coded by amount of volume on up-tick versus amount of volume on down-tick



declare lower;



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 SV = Selling;

SV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

SV.SetDefaultColor(Color.LIGHT_RED);

SV.HideTitle();

SV.HideBubble();

SV.SetLineWeight(5);



# Buying Volume

# Plot BV = Buying;

# Note that Selling + Buying Volume = Volume.

plot BV =  volume;

BV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

BV.SetDefaultColor(Color.GREEN);

BV.HideTitle();

BV.HideBubble();

BV.SetLineWeight(5);





#Create an average volume line based on last 50 bars



input length = 20;

plot Vol = volume;

plot VolAvg = Average(volume, length);

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
215 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