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

@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:

87k+ Posts
373 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?