All Buy / Sell Volume Pressure Indicators & Labels For ThinkOrSwim

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);
#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);
 
This only shows minute and 5 min.







I need weekly and monthly
I use this one 3 charts, A daily with the agg at weekly, a 30 minute 5 day chart with the agg at daily, and a 1 minute chart with the agg at 30 min, it all works for me, Ill paste it again below, you need to go into the settings and change it at the top

#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);
 
Code:
#Total Volume for Regular Trading Day

#Volume of Current Bar

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





#Volume of the Last Bar

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







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







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


#Volume Data


def today = volume(period = "Daily,Weekly,Monthly");

def curVolume = volume;

def SellVolPercent = Round((Selling / Volume) * 100, 0);



# 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 = 50;

plot Vol = volume;

plot VolAvg = Average(volume, length);

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
 
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);

Can Anyone make this into MTF
 
Chris's Enhanced Volume For ThinkOrSwim
Buy / Sell Volume Pressure Percentages

View attachment 913
Buyers and Sellers is not information available in the data feeds.
When we look at the movement of price in comparison to volume, it is called Volume Pressure.
The scripts discussed here are representative of the PRICE spread compared to the overall volume spread.

We create a percentage for buying and selling pressure by using the candlestick patterns weighted volume.
Volume Pressure identifies the price movement which when aggregated with volume it is used to define MOMENTUM not actual buyers and sellers.
You can't apply the momentum percentage to the volume number and declare that to be the number of buyers and sellers.
nOnSBvp.png
uwFHET6.png

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

declare on_volume;

###############
#DPL CRITERIA #
###############
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 > volume[1];
def devincrease = increase and abovedev;
def decrease = volume < volume[1];
def devdecrease = decrease and abovedev;

##############################
# UPTICK / DOWNTICK CRITERIA #
##############################
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.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);

Buy / Sell Volume Pressure w/ volumes and percentages -- Upper Study Labels Only
Ruby:
#Chris' Enhanced Volume V.2 /w Uptick/Downtick LABELS ONLY

declare upper;
###############
#DPL CRITERIA #
###############
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 > volume[1];
def devincrease = increase and abovedev;
def decrease = volume < volume[1];
def devdecrease = decrease and abovedev;

##############################
# UPTICK / DOWNTICK CRITERIA #
##############################
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 SV = Selling;
def BV = Buying;

#################
# Adding Volume Labels #
#################
DefineGlobalColor("LabelGreen",  CreateColor(0, 165, 0)) ;
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);
My understanding is that ThinkorSwim does not provide a "true" cumulative volume indicator on its platform similar to Tradingview or other more updated scripting capacity platforms. to be explicit ,TOS does not aggregate the individual spread difference for transactions spread between buyers and sellers during the actual auction process as it unfolds. (In my opinion scalpers especially favor cum delta volume because it shows the internal tension in a moment by moment unfolding process.) All the volume studies I have personally observed on usethinkscipt.com theads seem to have as their goal a "workaround" for this lack of precision and information. Given what I have seen so far, there is no perfect way to perform a true cumulative delta volume indicator in thinkorswim. Please feel free to reply and further enlighten me about this subject. One last comment: even with the cum delta volume study, I have personally observed many, I repeat, many false short term breakouts and reversals even in the most robust index like spx, spy and index options. Whatever signal a TOS trader uses to drill down into the internal auction process I suggest that it is critical pay attention to the tick indicators and the cumulative tick indicators along with all these (Mobius Volume Waves, Buy, Sell vol,

This is useful as a workaround for the reality that unlike Tradingview, there is no actual cumulative delta indicator on TOS (the accumulation spread between buyer and seller in the transactional auction process. Aside from that this is an excellent tool to decipher the internal tension over the selected time period in which you are trading. U could add a cumulative tick indicator across the price section (for the major indexes) in order to get a clearer picture of how the auction, price discovery process is unfolding. I take comfort that I have observed that the cumulative delta indicators on other platforms lead to many false breakouts and short term reversals. Do not despair as the only perfect indicator is already inside you. No single electronic signal will replace you when you are in total synchronization with the market. Thanks to everyone working on this thread. Very creative workarounds.

Here's a Watchlist Column Mod I just made.

ISgSxyr.png


Code:
# Original author: Unknown
# Watchlist Label
# Mod by Ramon DV aka Pelonsax

declare lower;


def O = open;
def H = high;
def C = close;
def L = low;
def Price = H + L + C / 3;
def V = volume;
def buying = V * (C - L) / (H - L);
def selling = V * (H - C) / (H - L);
def SellVolPercent = Round((Selling / Volume) * 100, 0);
def BuyVolPercent = 100 - SellVolPercent;

assignBackgroundColor(if buying >= selling then color.GREEN else if buying <= selling then color.RED else color.white);
AddLabel(buying <= selling, "Sell %: "+SellVolPercent, color.black);
AddLabel(buying >= selling, "Buy %: "+BuyVolPercent, color.black);

Great indicator. Thanks as always.
 

Attachments

  • nOnSBvp.png
    nOnSBvp.png
    18.9 KB · Views: 570
Last edited by a moderator:
@MerryDay is there a volume indicator that shows the volume percentage of buy or sell through out the entire day, so i can see how volume and price move together? if not is it possible to create one?
 
@MerryDay is there a volume indicator that shows the volume percentage of buy or sell through out the entire day, so i can see how volume and price move together? if not is it possible to create one?

Buying and Selling Volume Pressure Percentages plotted minute by minute
wBxiWSk.png

Ruby:
## ########################################################

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

# #####################################
# Charting & Formatting
declare lower ;
plot BuyPct = Buying/(Buying+Selling) ;
plot SellPct= Selling/(Buying+Selling) ;
AddCloud(buyPct, sellpct, color.green, color.red);
 
Last edited:
Perhaps this is close to what you want:
Code:
declare lower;

input length = 5;

def up_volume = sum( if close > open then VOLUME else 0, length );
def dn_volume  = sum( if close < open then VOLUME else 0, length );

plot VTM = up_volume - dn_volume;
VTM.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
VTM.AssignValueColor(if VTM < 0 then color.red else color.green);

-mashume
 
Perhaps this is close to what you want:
Code:
declare lower;

input length = 5;

def up_volume = sum( if close > open then VOLUME else 0, length );
def dn_volume  = sum( if close < open then VOLUME else 0, length );

plot VTM = up_volume - dn_volume;
VTM.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
VTM.AssignValueColor(if VTM < 0 then color.red else color.green);

-mashume

It's not perfect but it's close enough. Thank you very much!
 
It's not perfect but it's close enough. Thank you very much!
Can you elaborate on how it's not doing what you expect? I'll happily take another swing at getting it working for you. I just don't have any reference but the code provided for how it works.

-mashume
 
Buying and Selling Volume Pressure Percentages plotted minute by minute
wBxiWSk.png

Ruby:
## ########################################################

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

# #####################################
# Charting & Formatting
declare lower ;
plot BuyPct = Buying/(Buying+Selling) ;
plot SellPct= Selling/(Buying+Selling) ;
AddCloud(buyPct, sellpct, color.green, color.red);
thank you this is what ive been looking for, is there a way to make this MTF?
 
Is there a way to convert the script below to a percentage or to convert the volume pressure percentages to averages?

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);
 
Hey Everyone,

Need some help. Trying to plot the buy and sell volume averages on upper chart. I managed to get buy and sell to plot with the point at close, but can not figure out the crossover formula buy crosses below sell and vice versa. Thank you!
Maybe an ema cloud possible?

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);
#def buyvolumeaverage = if buyvolavg crosses below sellvolavg then sellvolavg else Double.NaN;
#def sellvolumeaverage = if sellvolavg crosses above buyvolavg then buyvolavg else Double.NaN;



plot BuyVolumeaverage = round(((high - open) + (close - low)) / 2 / (high - low) * volume(), 0);
plot SellVolumeaverage = round(((low - open) + (close - high)) / 2 / (high - low) * volume(), 0);
plot UpSignal = if buyvolumeaverage crosses below sellvolumeaverage then sellvolumeaverage else Double.NaN;
plot DownSignal = if sellvolumeaverage crosses above buyvolumeaverage then buyvolumeaverage else Double.NaN;

BuyVolumeAverage.setDefaultColor(color.GREEN);
SellVolumeAverage.setDefaultColor(color.RED);
 
@Epic_Trades
You've got your up and down signals looking for the same thing... If you replace buy and sell averages with 'a' and 'b' for explanation, you have:
a crosses below b
and
b crosses above a
which are the same thing. Unless I'm missing something. Which is possible.

You need something like this:
Code:
plot UpSignal = if buyvolumeaverage crosses above sellvolumeaverage then sellvolumeaverage else Double.NaN;
plot DownSignal = if sellvolumeaverage crosses above buyvolumeaverage then buyvolumeaverage else Double.NaN;
And then you can change them to be arrows or dots or whatever you want:
Code:
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
UpSignal.setDefaultColor(color.GREEN);
DownSignal.setDefaultColor(color.RED);

You also have both BuyVolumeAverage and BuyVol defined as the same thing, but you're only plotting the first. There is no averaging going on in your BuyVolumeAverage definition though there is in the definition for BuyVolAvg, but you don't use it in the Signals plots either. To clean up your script then:
Code:
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);
plot buyvolavg = MovingAverage(AvgTypes, buyvol, BuyVolumeAvgLength);
plot sellvolavg = MovingAverage(AvgTypes, absValue(sellvol), SellVolumeAvgLength);
buyvolavg.setDefaultColor(color.GREEN);
sellvolavg.setDefaultColor(color.RED);

plot UpSignal = if buyvolavg crosses above sellvolavg then sellvolavg else Double.NaN;
plot DownSignal = if sellvolavg crosses above buyvolavg then buyvolavg else Double.NaN;

UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
UpSignal.setDefaultColor(color.GREEN);
DownSignal.setDefaultColor(color.RED);

I did the editing here in usethinkscripts editor rather than launching ToS, so there may be a couple of typos... if it doesn't run, just come on back if you can't find them. :)

-mashume


-mashume
 
I modified the Buy and Sell Volume indicator
https://usethinkscript.com/threads/...ssure-indicators-labels-for-thinkorswim.8466/
to plot a "buy" moving average and "sell" moving average. When the two cross, it helps to show a trend reversal.

I included some code to plot when the two cross up or down. Unfortunately, it's only showing the "cross down" and doesn't show the "cross up" plots. Can someone help me get the "cross up" to show?
Ruby:
#Buy/Sell Volume Moving Averages

declare on_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);

# Selling Volume
plot SV = Selling;
SV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
SV.SetDefaultColor(Color.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.DARK_GREEN);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(5);

input length = 26;

plot VolAvg = Average(Selling, length);
plot VolAvg2 = Average(Buying, length);
VolAvg.SetDefaultColor(GetColor(2));
VolAvg2.SetDefaultColor(GetColor(6));

AddVerticalLine(VolAvg crosses above VolAvg2, "Up", Color.Green, Curve.Points);
AddVerticalLine(VolAvg2 crosses below VolAvg, "Down", Color.Yellow, Curve.Points);

#End
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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