PVT Price Volume Trend indicator For ThinkOrSwim

chewie76

Well-known member
VIP
VIP Enthusiast
The Price and Volume Trend (PVT) is a momentum indicator similar to the On Balance Volume (OBV) indicator but with a key difference. Unlike the OBV, which adds or subtracts total volume based on daily price changes, the PVT adjusts volume based on the percentage change in price, making it more sensitive to money flow.
hso3Hzr.png



@samer800 Is it possible to convert this PVT indicator and have the 21 EMA set to PVT like in this video in upper chart, or even a lower chart? This looks interesting.
 
Last edited by a moderator:
My take at it. There are too many arrows on smaller time frames. Try lowering the EMA within the code. Maybe add a filter to detect tight range squeezes?

Code:
#chatgpt created and @chewie76 cleaned up
# Define the PVT (Price Volume Trend) Indicator
declare lower;

def PVT = CompoundValue(1, if (IsNaN(close[1])) then 0 else PVT[1] + (close - close[1]) / close[1] * volume, 0);

# Define the 21-period EMA of the PVT
def EMA_21 = ExpAverage(PVT, 21);

# Plot the PVT and EMA on the lower chart
plot PVTLine = PVT;
plot EMA21Line = EMA_21;
PVTLine.SetDefaultColor(Color.CYAN);
EMA21Line.SetDefaultColor(Color.YELLOW);

# Define the crossover conditions
def crossoverUp = PVT crosses above EMA_21;
def crossoverDown = PVT crosses below EMA_21;

# Plot arrows on the upper chart when crossover conditions are met
plot UpArrow = if crossoverUp then pvt else Double.NaN;
UpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpArrow.SetDefaultColor(Color.GREEN);

plot DownArrow = if crossoverDown then pvt else Double.NaN;
DownArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownArrow.SetDefaultColor(Color.RED);

# Set the arrow size for better visibility
UpArrow.SetLineWeight(3);
DownArrow.SetLineWeight(3);
 
Last edited by a moderator:
uXR4JUe.png

This script analyzes the market by comparing price movement with volume changes.

It identifies different market conditions like confirming trends, exhaustion (divergence), and absorption (large buyers or sellers), and visually marks those conditions with labels on the chart.
It adds labels to the chart to indicate the detected market conditions:

PNVI is a modified version of the Price-Volume Trend (PVT) indicator, which combines price changes and volume data to give an indication of price movement relative to volume.

PNVI can be interpreted as a momentum indicator based on volume and price direction. The higher the PNVI, the more bullish the market, and the lower the PNVI, the more bearish the market.

The PEMA line is the average; essentially a smoothed version of PNVI, helping to reduce noise and make trends easier to spot.

AddLabel(PNVI crosses PEMA, "Absorption / Possible Reversal", Color.PLUM);
AddLabel(PNVI > PEMA and PNVI > PNVI[1], "Confirmed Uptrend", Color.BLUE);
AddLabel(PNVI < PEMA and PNVI < PNVI[1], "Potential Exhaustion", Color.ORANGE);
AddLabel(PNVI > PEMA and PNVI > PNVI[1], "Bullish Momentum", Color.GREEN);
AddLabel(PNVI < PEMA and PNVI < PNVI[1], "Bearish Momentum", Color.RED);


The lowest chart is without labels and the addition of combining a ROC price action and volume indicators.

Code:
# PNVI is a modified version of the Price-Volume Trend (PVT) indicator
# @antwerks 2/2/2025
declare lower;

input ma_length = 15;

def xROC = (close - close[1]) * 100 / close;

def nRes1 = if (volume < volume[1]) then nRes1[1] + xROC else nRes1[1];
def nRes2 = if (volume > volume[1]) then nRes2[1] + xROC else nRes2[1];
def nRes3 = nRes1 + nRes2;
def nResEMA3 = simpleMovingAvg(nRes1, ma_length) + simpleMovingAvg(nRes2, ma_length);

plot PNVI = nRes3;
plot PEMA = nResEMA3;

PNVI.SetDefaultColor(GetColor(1));
PNVI.DefineColor("Up Momentum", Color.BLUE);
PNVI.AssignValueColor(PNVI.color("Up Momentum"));

PEMA.SetDefaultColor(GetColor(1));
PEMA.DefineColor("Down Momentum", Color.RED);
PEMA.AssignValueColor(PEMA.color("Down Momentum"));

AddCloud(PNVI, PEMA, PNVI.color("Up Momentum"), PEMA.color("Down Momentum"));

# Define Trend Labels

# Define Trend Labels with Else Statements
AddLabel(PNVI crosses PEMA, "Absorption / Possible Reversal", Color.PLUM);
AddLabel(PNVI > PEMA and PNVI > PNVI[1], "Confirmed Uptrend", Color.BLUE);
AddLabel(PNVI < PEMA and PNVI < PNVI[1], "Potential Exhaustion", Color.ORANGE);
AddLabel(PNVI > PEMA and PNVI > PNVI[1], "Bullish Momentum", Color.GREEN);
AddLabel(PNVI < PEMA and PNVI < PNVI[1], "Bearish Momentum", Color.RED);

# Background Coloring
input paintCandles = yes ;
AssignPriceColor(
if !paintCandles then color.current else
if PNVI > PEMA then Color.GREEN else Color.RED);


Below is the script for the lowest chart is without labels and the addition of combining a ROC price action and volume indicators.
Code:
declare lower;

### INPUTS ###
input ma_length = 15;
input cvd_length = 15;

### PRICE RATE OF CHANGE ###
def xROC = (close - close[1]) * 100 / close;

### VOLUME RIBBON LOGIC ###
def nRes1 = if (volume < volume[1]) then nRes1[1] + xROC else nRes1[1];
def nRes2 = if (volume > volume[1]) then nRes2[1] + xROC else nRes2[1];
def nRes3 = nRes1 + nRes2;
def nResEMA3 = simpleMovingAvg(nRes1, ma_length) + simpleMovingAvg(nRes2, ma_length);

### CVD LOGIC ###
def buyVolume = if close > close[1] then volume else 0;
def sellVolume = if close < close[1] then volume else 0;
def CVD = CompoundValue(1, CVD[1] + buyVolume - sellVolume, 0);
def CVD_MA = Average(CVD, cvd_length);

### PLOTS ###
plot PNVI = nRes3;
plot PEMA = nResEMA3;
plot CVD_Plot = CVD;
plot CVD_MA_Plot = CVD_MA;

### COLOR CHANGES ###
PNVI.SetDefaultColor(GetColor(1));
PNVI.AssignValueColor(if PNVI > PEMA then Color.BLUE else Color.RED);
PEMA.SetDefaultColor(GetColor(7));

CVD_Plot.SetDefaultColor(GetColor(3));
CVD_Plot.AssignValueColor(if CVD > CVD_MA then Color.GREEN else Color.RED);
CVD_MA_Plot.SetDefaultColor(GetColor(5));

### CLOUDS & CROSS ALERTS ###
AddCloud(PNVI, PEMA, Color.BLUE, Color.RED);
AddCloud(CVD_Plot, CVD_MA_Plot, Color.GREEN, Color.RED);

Alert(CVD_Plot crosses above CVD_MA_Plot, "CVD Bullish Reversal!", Alert.BAR, Sound.Ring);
Alert(CVD_Plot crosses below CVD_MA_Plot, "CVD Bearish Reversal!", Alert.BAR, Sound.Bell);
 
Last edited by a moderator:

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