On Balance Volume Scanner

Rojo Grande

Rojo Grande

Member
VIP
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.
 
BenTen

BenTen

Administrative
Staff
VIP
What do you mean by "OBV is greater than or less than the previous time frame"?
 
BenTen

BenTen

Administrative
Staff
VIP
@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:

 
Rojo Grande

Rojo Grande

Member
VIP
Thanks Ben, That worked. I also reversed it to get a scanner for the less than day before.
 
Rojo Grande

Rojo Grande

Member
VIP
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);
 
BenTen

BenTen

Administrative
Staff
VIP
@Rojo Grande So you want to display the OBV value as a watchlist column? What are the conditions for the color change?
 
Rojo Grande

Rojo Grande

Member
VIP
@Rojo Grande So you want to display the OBV value as a watchlist column? What are the conditions for the color change?
Hello Ben,
If possible, I would like an arrow that shows direction. Green if its on an upward direction, red if it's downward. Thank you.
 
Rojo Grande

Rojo Grande

Member
VIP
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.
 
BenTen

BenTen

Administrative
Staff
VIP
@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.
 
Rojo Grande

Rojo Grande

Member
VIP
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?
 
rad14733

rad14733

Well-known member
VIP
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?
I wouldn't go as drastic as a complete uninstall and reinstall of Thinkorswim... I'd be leaning more towards removing and reinstalling the studies or deleting and remaking the chart window... I've had several detached windows become corrupt in recent months...
 

Similar threads

Top