• The price of VIP membership is increasing to $199 beginning June 1. Click here to lock in the current rate of $149.

On Balance Volume Scanner

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

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:

AVdhTKS.png
 

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

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

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

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

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...
 

mmct

New member
@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
 

mmct

New member
@rad14733 how can scan the two pikes?

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

d041v7j.png


The pikes from the study, the script i posted above. I hope someone can help me other alternative way to scan these pikes.
 

Similar threads

Top