OnBalanceVolume OBV OBVM Scan, Watchlist, Label For ThinkOrSwim

rak

New member
Lifetime
First time post and I have zero experience with writing code. I've opened scripts and added "plot" line or "addcloud" but that's about it. I currently just drop a SMA in the lower study panel on top of the OBV but that's not very accurate. I would like a 200 SMA of the OBV to plot for confirmation of who is in control.

I would appreciate someone sharing if they have this or something similar.
 
@rak
Code:
# OBV and MovingAverage average of OBV
# Horserider 1/23/2020

declare lower;
input length = 200;
plot OBV = TotalSum(Sign(close - close[1]) * volume);
plot obvma = Average(obv, length);
OBV.SetDefaultColor(GetColor(8));
obvma.setDefaultColor(GetColor(1));
 
Hello to all,

I have tried using the TOS scan tool to scan for stocks where the OBV is greater than or less than the previous time frame, but keep getting no results. It does not matter how many bars back I go or what time frame I use. Any help appreciated.

Thanks.
 
What do you mean by "OBV is greater than or less than the previous time frame"?
 
@Rojo Grande Use the script below:

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2008-2020
#

declare lower;

def OBV = TotalSum(Sign(close - close[1]) * volume);

plot scan = if OBV > OBV[1] then 1 else double.nan;

Add it as an indicator and then set up your scanner to something like this:

AVdhTKS.png
 
Hello to all,

I like the modified On Balance Volume. I altered it for color change when direction changes. I tried to make a column using the code, and eliminating the signal plot portion. The numbers I get don't match the numbers on my chart, and I do not get the color change either. Below is what I am using, any help is appreciated, thank you.

Code:
declare lower;

input length = 7;
input signalLength = 7;
input averageType = AverageType.Wilders;

def obv = reference OnBalanceVolume();

plot OBVM = MovingAverage(averageType, obv, length);
#plot Signal = MovingAverage(averageType, OBVM, signalLength);

OBVM.AssignValueColor(if OBVM > OBVM[1] then color.GREEN else if OBVM < OBVM[1] then color.RED else color.gray);
#Signal.SetDefaultColor(GetColor(2));

#Alert(OBVM crosses Signal, "", Alert.BAR, Sound.Bell);
 
@Rojo Grande So you want to display the OBV value as a watchlist column? What are the conditions for the color change?
 
When volume is increasing or ascending, it would generate a up green arrow. And naturally if the volume is decreasing or descending, a red down arrow would be generated. For instance, some RSI watchlist columns display the number in one color if its increasing, and another if its decreasing. Thank you.
 
@Rojo Grande The only way to define if the volume is decreasing or increasing is by comparing it to the previous bar. I can do that. But if you have another definition, I'm afraid I would not be able to help.

If you look at the code you posted, the following line will do just that:

Code:
OBVM.AssignValueColor(if OBVM > OBVM[1] then color.GREEN else if OBVM < OBVM[1] then color.RED else color.gray);

If current OBV is higher than previous OBV then green or if current OBV is less than previous OBV then color red.
 
Thank you Ben, I believe I need to uninstall and reinstall TOS. I'm using the same script for both the watch list column and for a lower indicator on my chart, but both the numbers and colors do not match up. Any idea's?
 
@Rojo Grande Use the script below:

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2008-2020
#

declare lower;

def OBV = TotalSum(Sign(close - close[1]) * volume);

plot scan = if OBV > OBV[1] then 1 else double.nan;

Add it as an indicator and then set up your scanner to something like this:

AVdhTKS.png
hi Ben,
could you help me on the script that scan obv just cross above 0 line:

def obv = TotalSum(Sign(close - close[1]) * volume);
plot zeroline= 0;
plot scan = obv >1 and obv[1] <0 ;

I don't know what wrong, it doesn't give me the right list.
thanks Ben
 
thank you Ben,
How do I add time frame such as 4hours in 180 days?
Four hours is four hours... Scans don't look back a given number of days like 180... Just set the aggregation to 4 Hours if that's what you want...
 

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

Thread starter Similar threads Forum Replies Date
W BuySell Volume, PreMarket OBV & CumuVol For ThinkOrSwim Custom 3

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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