Need help with Volume index indicator

Glefdar

Active member
Hello all,

I would like to scan for the negative volume index trendline being above the positive volume index trendline (as shown in the below image where the cursor crosshair is):

OALnb9m.jpg


The intuitive way to do this would be to simply scan for the NegativeVolumeIndex value being higher than the PositiveVolumeIndex value but that won't work apparently, because even though the negative trendline is charting above the positive trendline, the actual value for the negative trendline is smaller (85.8219 vs. 95.7026). I don't understand how the math is working to make that the case*, so I don't understand how to make this scan work.

Does anyone know how this could be done?

*Edit: On further thought I guess the reason (that the absolute value can be lower while the trendline can be higher than the other index's trendline) is that these index trendlines are showing relative changes over time instead of absolute values.
 
Last edited:
I see that you combined both indicators by dragging them into one section. This is not the right way to do it.

Here is the code which plots the Negative and Positive Index.

Code:
declare lower;

def pos_index = compoundValue(1, pos_index[1] + if (volume > volume[1] and close[1] != 0) then 100 * (close - close[1]) / close[1] else 0, 100);

plot PVI = pos_index;
PVI.SetDefaultColor(GetColor(5));

def neg_index = compoundValue(1, neg_index[1] + if (volume < volume[1] and close[1] != 0) then 100 * (close - close[1]) / close[1] else 0, 100);

plot NVI = neg_index;

After adding it to your ThinkorSwim, set you your scanner and add a condition like this:

ZIvPJWn.png
 

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

I see that you combined both indicators by dragging them into one section. This is not the right way to do it.

Here is the code which plots the Negative and Positive Index.

Code:
declare lower;

def pos_index = compoundValue(1, pos_index[1] + if (volume > volume[1] and close[1] != 0) then 100 * (close - close[1]) / close[1] else 0, 100);

plot PVI = pos_index;
PVI.SetDefaultColor(GetColor(5));

def neg_index = compoundValue(1, neg_index[1] + if (volume < volume[1] and close[1] != 0) then 100 * (close - close[1]) / close[1] else 0, 100);

plot NVI = neg_index;

After adding it to your ThinkorSwim, set you your scanner and add a condition like this:

ZIvPJWn.png

Thanks for your reply. I can't explain why but when I do it the "wrong way" by combining them into one section, it gives me a more usable signal when I look for the negative volume line being above the positive volume line (by contrast when I plot them as one study using the code you provided, the same bars don't show the negative trendline above the positive trendline).

Maybe it's just an idiosyncracy of how I am trading but for my purposes I actually need a scan that can identify when the negative vol index line is appearing above the pos vol index line in the situation that the studies are plotting as they do when combined into one section. Do you know if it's possible?
 
@lmk99 It's the "wrong way" because when you drag-n-drop two indicators into one lower section, they create a scaling issue, you'll notice then when you zoom in and out of your chart.

In addition to using the script I shared with you, there is an alternative. Go to your scanner and set up a condition like this:

4kzKhYw.png
 
Hi, allow me to clarify, I want to scan for this situation:

OALnb9m.jpg


In this situation, I want to scan for "the positive volume index absolute value may (or may not) be higher than the negative volume index absolute value, but when the studies scale in a funky way because of being combined into one lower chart, the negative volume index trendline is above the positive volume index trendline."

If I did a scan using what you suggested, the situation of the above screenshot would not be picked up by the scanner because the negative volume index absolute value is in fact less than the positive volume index absolute value.
 
@lmk99 That is what I meant by doing it the "wrong way."

In reality, it never happened. But because you combined them into one lower section, the scaling gets mixed up, and now it's displaying the data incorrectly. I hope that helps.
 
@lmk99 That is what I meant by doing it the "wrong way."

In reality, it never happened. But because you combined them into one lower section, the scaling gets mixed up, and now it's displaying the data incorrectly. I hope that helps.

I know it never happened in reality, but for some reason I can't explain, it's actually a useful signal when I'm trading to look for this illusory "negative volume index trendline is above positive volume index trendline" signal. The real version of this (that is not a scaling illusion) is not a comparably useful signal. Odd, I know. Still, if it's possible then I'd like to scan for this illusory pattern that shows due to the scaling error.
 
@lmk99 It's not possible because value A was never higher than value B and vice versa. Best of luck.

I thought it might be possible if the scaling error was mathematically definable in some way, and could therefore be included in the scan formula to accordingly give the illusory trendline value instead of the real value. I guess whether it is theoretically possible or not, the scaling error would be difficult to mathematically define if it's not already a known definition that someone figured out before for some reason. Thanks for your replies and trying to help, I appreciate it and have a better understanding of the problem. All the best.
 
@lmk99 It's not possible because value A was never higher than value B and vice versa. Best of luck.

Just wanted to let you know that the scaling error was showing the neg vol index line above the pos vol index line incorrectly, but in a way that was predictable, i.e. that visual was happening with the scaling error specifically when the neg volume index value was increasing and the pos vol index value was decreasing over the same period. So that is the condition that I needed to describe in the scan, and your suggestion for how to make the scan was very useful for implementing that. Thanks again! Best wishes.
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
406 Online
Create Post

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