average Volume Positive Negative (VPN) indicator For ThinkOrSwim

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime

TOS average Volume Positive Negative (VPN) indicator

TOS released Markos Katsanos' new VPN indicator from the April issue of Stocks & Commodities. This indicator, as its name suggests, compares the difference between the volume on up days (positive) and the volume on down days (negative) with the total volume. You can read more about it here:
https://mkatsanos.com/vpn-indicator/

Revised: Now uses @BigBoss's color scheme:
Screenshot (173).png

a1.png

a1.png

Study Shared Link: http://tos.mx/iIVibqk Click here for --> Easiest way to load shared links
Ruby:
# TOS TOS average Volume Positive Negative (VPN) indicator indicator
# w/ lipstick :) @MerryDay 7/21

declare lower;
input vpn_critical_value = 10 ;
DefineGlobalColor("Pre_Cyan", CreateColor(50, 200, 255)) ;
DefineGlobalColor("Canteloupe", CreateColor(255, 200, 150)) ;

plot VPN = reference VPNIndicator()."VPN" ;
plot VPN_avg = reference VPNIndicator()."VPNAvg" ;

def phase =
     if VPN > VPN_avg and VPN > vpn_critical_value then 1 # leading
else if VPN < VPN_avg and VPN > vpn_critical_value then 2 # weakening
else if VPN < VPN_avg and VPN < vpn_critical_value then 3 # lagging
else if VPN < 0 then 5
else 4;

VPN.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
VPN.SetLineWeight(5);
VPN_avg.SetDefaultColor(Color.ORANGE);
VPN.AssignValueColor(
     if phase == 1  then Color.GREEN
else if phase == 2 then  Color.LIGHT_GRAY
else if phase == 3 then Color.RED
else if phase == 5 then  color.yellow
else GlobalColor("Pre_Cyan"));
# ########################################################
AddLabel(yes,
     if phase == 1 then "VPN: Leading"
else if phase == 2 then "VPN: Weakening"
else if phase == 3 then "VPN: Lagging"
else if phase == 5 then "VPN: Potential Zone"
else "VPN: Improving!",
     if phase == 1  then Color.GREEN
else if phase == 2 then  Color.LIGHT_GRAY
else if phase == 3 then Color.RED
else if phase == 5 then  color.yellow
else GlobalColor("Pre_Cyan"));
Watch List Shared Link: http://tos.mx/ykFhglj Click here for --> Easiest way to load shared links
Ruby:
# TOS TOS average Volume Positive Negative (VPN) indicator indicator
# w/ lipstick :) @MerryDay 7/21

declare lower;
input vpn_critical_value = 10 ;
DefineGlobalColor("Pre_Cyan", CreateColor(50, 200, 255)) ;
DefineGlobalColor("Canteloupe", CreateColor(255, 200, 150)) ;

def VPN = reference VPNIndicator()."VPN" ;
def VPN_avg = reference VPNIndicator()."VPNAvg" ;

def phase =
     if VPN > VPN_avg and VPN > vpn_critical_value then 1 # leading
else if VPN < VPN_avg and VPN > vpn_critical_value then 2 # weakening
else if VPN < VPN_avg and VPN < vpn_critical_value then 3 # lagging
else if VPN < 0 then 5
else 4;
# ########################################################
AddLabel(yes,
     if phase == 1 then "Leading"
else if phase == 2 then "Weakening"
else if phase == 3 then "Lagging"
else if phase == 5 then "Potential"
else "Improving!");
AssignBackgroundColor(
     if phase == 1  then Color.GREEN
else if phase == 2 then  Color.LIGHT_GRAY
else if phase == 3 then Color.RED
else if phase == 5 then  color.yellow
else color.cyan);
 
Last edited:
@MerryDay
Thank you so much! This one seems promising!

Right now I am searching for a good volume indicator. However, even the best volume indicators are hard to work with the price indicators.
(First, I get the signal from the price indicator. Then I cross-check with volume indicators. Quite often the volume indicator has no, delay or very short period signal)
Do you have suggestions?
 
@Jtopaz I am struggling w/ many of the same issues. Haven't found any great solutions yet.
It seems to combine this indicator with Welkin Advanced Volume Indicator is good enough for volume analysis:

Average Volume Positive Negative (VPN) Indicator - gives volume & price trend (good for medium-term analysis).
Welkin Advanced Volume Indicator - gives (1) Buy/Sell strength On Volume Bars (good to confirm signal from other indicators), (2) Volume strength signal (good for short-term analysis)
 
Last edited:
I'm trying to find a good volume indicator so I thought I'd study it a little bit.

My first take on it is that there are four phases - The VPN line above and below the VPN average line, and the VPN line above and below the Critical Line.

I've deemed these phases like so:
  1. VPN Leading Phase - The VPN line is above the VPN average and above the critical line. Theoretically we should see a positive effect on price.
  2. VPN Weakening Phase - The VPN line is below the VPN average, but above the critical line. This may be good opportunity to sell if you expect the trend to end, or to buy if you are looking for a pullback and expect the trend to continue.
  3. VPN Lagging Phase - The VPN line is below the VPN average line, and below the critical line. Expect a downward price trend.
  4. VPN Improving Phase - The VPN line is above the VPN average line, and below the critical line. This may be a good opportunity to buy if you expect to the trend to reverse, or to sell if you are looking for a pullback and expect the downtrend to continue.
Below is a picture and the upper study. After looking at it for 30 minutes or so, it looks.... kinda useful.


Code:
#
# TD Ameritrade IP Company, Inc. (c) 2021
#

# Modified by bigboss to be an upper study, and add vertical lines and a label based on phases


declare upper;

input length = 30;
input emaLength = 3;
input averageLength = 30;
input factor = 0.1;
input criticalValue = 10;
input averageType = AverageType.SIMPLE;
input paintbars = yes;

def atr = WildersAverage(TrueRange(high,  close,  low), length);
def diff = hlc3 - hlc3[1];
def vp = Sum(if diff > factor * atr then volume else 0, length);
def vn = Sum(if diff < -factor * atr then volume else 0, length);

def VPN = ExpAverage(100 * (vp - vn) / Sum(volume, length), emaLength);
def VPNAvg = MovingAverage(averageType, VPN, averageLength);
def CriticalLevel = criticalValue;

def phase = if VPN > VPNAvg and VPN > CriticalLevel then 1 # leading
else if vpn < vpnavg and vpn > criticalLevel then 2 # weakening
else if vpn < vpnavg and VPN < criticalLevel then 3 # lagging
else 4;

AddLabel(yes,
     if phase == 1 then "VPN: Leading"
else if phase == 2 then "VPN: Weakening"
else if phase == 3 then "VPN: Lagging"
else "VPN: Improving",
     if phase == 1  then color.green
else if phase == 2 then  Color.light_green
else if phase == 3 then color.red
else color.orange);

AddVerticalLine(
     if phase <> phase[1] then 1 else double.nan,
     if phase == 1 then "VPN: Leading"
else if phase == 2 then "VPN: Weakening"
else if phase== 3 then "VPN: Lagging"
else "VPN: Improving",
     if phase == 1 then color.green
else if phase == 2 then color.light_green
else if phase == 3 then color.red
else color.orange);

AssignPriceColor(  if !paintbars then color.current else   if phase == 1  then color.green
else if phase == 2 then  Color.light_green
else if phase == 3 then color.red
else color.orange);
 
I'm trying to find a good volume indicator so I thought I'd study it a little bit.

My first take on it is that there are four phases - The VPN line above and below the VPN average line, and the VPN line above and below the Critical Line.

I've deemed these phases like so:
  1. VPN Leading Phase - The VPN line is above the VPN average and above the critical line. Theoretically we should see a positive effect on price.
  2. VPN Weakening Phase - The VPN line is below the VPN average, but above the critical line. This may be good opportunity to sell if you expect the trend to end, or to buy if you are looking for a pullback and expect the trend to continue.
  3. VPN Lagging Phase - The VPN line is below the VPN average line, and below the critical line. Expect a downward price trend.
  4. VPN Improving Phase - The VPN line is above the VPN average line, and below the critical line. This may be a good opportunity to buy if you expect to the trend to reverse, or to sell if you are looking for a pullback and expect the downtrend to continue.
Below is a picture and the upper study. After looking at it for 30 minutes or so, it looks.... kinda useful.


Code:
#
# TD Ameritrade IP Company, Inc. (c) 2021
#

# Modified by bigboss to be an upper study, and add vertical lines and a label based on phases


declare upper;

input length = 30;
input emaLength = 3;
input averageLength = 30;
input factor = 0.1;
input criticalValue = 10;
input averageType = AverageType.SIMPLE;
input paintbars = yes;

def atr = WildersAverage(TrueRange(high,  close,  low), length);
def diff = hlc3 - hlc3[1];
def vp = Sum(if diff > factor * atr then volume else 0, length);
def vn = Sum(if diff < -factor * atr then volume else 0, length);

def VPN = ExpAverage(100 * (vp - vn) / Sum(volume, length), emaLength);
def VPNAvg = MovingAverage(averageType, VPN, averageLength);
def CriticalLevel = criticalValue;

def phase = if VPN > VPNAvg and VPN > CriticalLevel then 1 # leading
else if vpn < vpnavg and vpn > criticalLevel then 2 # weakening
else if vpn < vpnavg and VPN < criticalLevel then 3 # lagging
else 4;

AddLabel(yes,
     if phase == 1 then "VPN: Leading"
else if phase == 2 then "VPN: Weakening"
else if phase == 3 then "VPN: Lagging"
else "VPN: Improving",
     if phase == 1  then color.green
else if phase == 2 then  Color.light_green
else if phase == 3 then color.red
else color.orange);

AddVerticalLine(
     if phase <> phase[1] then 1 else double.nan,
     if phase == 1 then "VPN: Leading"
else if phase == 2 then "VPN: Weakening"
else if phase== 3 then "VPN: Lagging"
else "VPN: Improving",
     if phase == 1 then color.green
else if phase == 2 then color.light_green
else if phase == 3 then color.red
else color.orange);

AssignPriceColor(  if !paintbars then color.current else   if phase == 1  then color.green
else if phase == 2 then  Color.light_green
else if phase == 3 then color.red
else color.orange);
Thank you for the analysis.
Any good volume indicator you would recommend?

Now I am using this indicator with Welkin Advanced Volume Indicator (you can see my previous reply)
 

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