Volume Pressure in a whole new light for ThinkOrSwim

View attachment 25972
I like my indicators to be easy on the eyes and intuitive just by a quick look. So, here is a volume pressure indicator that not only measures the chart asset, but it calculates the Magnificent 7, QQQ, and SPY. When the colors are all the same enter the trade! Can be used on any time frame.


SQL:
declare lower;

# ──────────────────────────────────────────────────────────────────
#  Inputs
# ──────────────────────────────────────────────────────────────────
input PaintBars         = yes;

# Volume Pressure Inputs
input Volume_AvgType    = AverageType.EXPONENTIAL;
input Volume_Length     = 14;
input Volume_AvgLength  = 200;

# Moving Average Inputs
input MovAvg_AvgType    = AverageType.EXPONENTIAL;
input MovAvg_Price      = close;
input MovAvg_Length     = 20;

# ───────────────────────────────────────────────────────────────────────
#  Raw Data
# ───────────────────────────────────────────────────────────────────────
def vol        = volume;
def selling    = vol * (high - close) / (high - low);
def buying     = vol * (close - low) / (high - low);

def buyV_ma   = MovingAverage(Volume_AvgType, buying, Volume_Length);
def sellV_ma  = MovingAverage(Volume_AvgType, selling, Volume_Length);

def MA        = MovingAverage(MovAvg_AvgType, MovAvg_Price, MovAvg_Length);

addlabel(yes, GetSymbol() +": " + round(buyV_ma - sellV_ma,0), if buyV_ma > sellV_ma then color.cyan else color.red);

plot Dot_Cyan = if buyV_ma > sellV_ma and close > MA then 1 else Double.NaN;
Dot_Cyan.SetPaintingStrategy(PaintingStrategy.Histogram);
Dot_Cyan.SetLineWeight(3);
Dot_Cyan.AssignValueColor(Color.CYAN);

plot Dot_Red  = if buyV_ma < sellV_ma and close < MA then 1 else Double.NaN;
Dot_Red.SetPaintingStrategy(PaintingStrategy.Histogram);
Dot_Red.SetLineWeight(3);
Dot_Red.AssignValueColor(Color.RED);

plot pos2Line = 2;
plot pos1Line = 1;
plot ZeroLine = 0;
plot neg1Line = -1;
plot neg2Line = -2;



AssignPriceColor(
    if PaintBars and !IsNaN(Dot_Cyan) then Color.CYAN
    else if PaintBars and !IsNaN(Dot_Red) then Color.RED
    else Color.GRAY
);

# ────────────────────────────────────────────────────────────────────────
#  4) Magnificent Seven aggregate dots at 0/100
# ────────────────────────────────────────────────────────────────────────
script VolumePressure {
    input sym = "AAPL";
    def o = open(sym);
    def h = high(sym);
    def l = low(sym);
    def c = close(sym);
    def v = volume(sym);

    def uw  = if c>o then h-c else h-o;
    def lw  = if c>o then o-l else c-l;
    def sp  = h - l;
    def bd  = sp - (uw + lw);
    def pctB= bd / sp;
    def pctW= (uw + lw) / sp;

    def buyR  = if c>o then (pctB + pctW/2) * v else (pctW/2) * v;
    def sellR = if c<o then (pctB + pctW/2) * v else (pctW/2) * v;

    plot Buy  = MovingAverage(AverageType.EXPONENTIAL, buyR, 14);
    plot Sell = MovingAverage(AverageType.EXPONENTIAL, sellR, 14);
}

def avgBuy  = ( VolumePressure("AAPL").Buy +
                VolumePressure("MSFT").Buy +
                VolumePressure("GOOGL").Buy +
                VolumePressure("AMZN").Buy +
                VolumePressure("META").Buy +
                VolumePressure("TSLA").Buy +
                VolumePressure("NVDA").Buy ) / 7;

def avgSell = ( VolumePressure("AAPL").Sell +
                VolumePressure("MSFT").Sell +
                VolumePressure("GOOGL").Sell +
                VolumePressure("AMZN").Sell +
                VolumePressure("META").Sell +
                VolumePressure("TSLA").Sell +
                VolumePressure("NVDA").Sell ) / 7;

addlabel(yes, "Mag 7: " + round(avgBuy - avgSell,0), if avgBuy > avgSell then color.cyan else color.red);
plot Cyan_M7 = if avgBuy > avgSell then -1 else Double.NaN;
Cyan_M7.SetPaintingStrategy(PaintingStrategy.Histogram);
Cyan_M7.SetLineWeight(3);
Cyan_M7.AssignValueColor(Color.CYAN);
plot Red_M7  = if avgBuy < avgSell then -1 else Double.NaN;
Red_M7.SetPaintingStrategy(PaintingStrategy.Histogram);
Red_M7.SetLineWeight(3);
Red_M7.AssignValueColor(Color.RED);

def qqqBuy  =  VolumePressure("QQQ").Buy;
def qqqSell  =  VolumePressure("QQQ").Sell;
addlabel(yes, "QQQ: " + round(qqqBuy - qqqSell,0), if qqqBuy > qqqSell then color.cyan else color.red);
plot Cyan_QQQ = if qqqBuy > qqqSell then -2 else Double.NaN;
Cyan_QQQ.SetPaintingStrategy(PaintingStrategy.Histogram);
Cyan_QQQ.SetLineWeight(3);
Cyan_QQQ.AssignValueColor(Color.CYAN);
plot Red_QQQ  = if qqqBuy < qqqSell then -2 else Double.NaN;
Red_QQQ.SetPaintingStrategy(PaintingStrategy.Histogram);
Red_QQQ.SetLineWeight(3);
Red_QQQ.AssignValueColor(Color.RED);

def spyBuy  =  VolumePressure("SPY").Buy;
def spySell  =  VolumePressure("SPY").Sell;
addlabel(yes, "SPY: " + round(spyBuy - spySell,0), if spyBuy > spySell then color.cyan else color.red);
plot Cyan_SPY = if spyBuy > spySell then -3 else Double.NaN;
Cyan_SPY.SetPaintingStrategy(PaintingStrategy.Histogram);
Cyan_SPY.SetLineWeight(3);
Cyan_SPY.AssignValueColor(Color.CYAN);
plot Red_SPY  = if spyBuy < spySell then -3 else Double.NaN;
Red_SPY.SetPaintingStrategy(PaintingStrategy.Histogram);
Red_SPY.SetLineWeight(3);
Red_SPY.AssignValueColor(Color.RED);

View attachment 25972
@dap711 Hi, someone asked about using circles, Dots ? I made some changes ,Hopefully is ok with you if not , admin can take it down.
 

Attachments

  • Volume-Pressure_ghla-combo.txt
    12 KB · Views: 54

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

@dap711 Hi, someone asked about using circles, Dots ? I made some changes ,Hopefully is ok with you if not , admin can take it down.
1765873640383.png


Instead of using "0" for the new bar, you might want to use "-3"
 
I believe-3 is SPY?
Original code:

plot pos2Line = 2; (blank line for labels)
plot pos1Line = 1; (Current chart asset)
plot ZeroLine = 0; (Mag7)
plot neg1Line = -1; (QQQ)
plot neg2Line = -2; (SPY)

It makes the indicator easier to read if the above are kept together.

So you would add a new line -3 and plot on -4. Just a suggestion.
 
@dap711 @cando13579

The reason for the dots version is that I like to throw another simple overlap indictor on top of it.
It just keeps me in check to make sure that I'm following my own trading rules.

Sometimes, I forget my own trading rules and I hit that "BUY" button at the wrong time!

I like the SIGNAL labels. I'm all about labels as it helps me keeps in check and I can quickly glance at it. I have a lot of labels that are comments and numerical data. I like to see the numbers move up and down, and make my decision on when to buy or sell.


1765897875939.png
 
Why include both the Mag7 and QQQ? Mag7 makes up over 44% of QQQ, so you're essentially double-weighting tech.

Also, why compare a non-tech stock against a tech basket? If you want to look at WMT, you don't really care what tech stocks are doing--except maybe in an anti-correlated way, as sector rotation might move stocks out of tech and into staples, etc.
 
Why include both the Mag7 and QQQ? Mag7 makes up over 44% of QQQ, so you're essentially double-weighting tech.

Also, why compare a non-tech stock against a tech basket? If you want to look at WMT, you don't really care what tech stocks are doing--except maybe in an anti-correlated way, as sector rotation might move stocks out of tech and into staples, etc.
I can tell you haven't used the indicator yet. ;)

Why include both the Mag7 and QQQ in this indicator?
✅ They aren’t the same thing — even if they’re correlated.
The Mag7 is a custom aggregation of the seven largest tech stocks (AAPL, MSFT, GOOGL, AMZN, META, TSLA, NVDA) averaged together in the script. QQQ is a market-cap-weighted ETF made up of the largest 100 Nasdaq stocks — not just those seven.
So:
  • Mag7 gives a pure view of mega-cap tech consensus (equal-weighted average of those leaders in the script).
  • QQQ gives the broad tech/innovation trend as seen through a real ETF (with heavy—but not exclusive—tech bias).
Even though Mag7 dominate QQQ (around ~38–40%+ of its weighting in real markets), their signals aren’t identical:
✔ Mag7 can diverge from the wider Nasdaq.
✔ QQQ includes semis, software, biotech, etc., beyond the Magnificent 7. StockCharts

So Mag7 + QQQ together is a way to check both tech-core leaders and broader market/tech trend strength.


Does this double-weight tech?
📌 Yes, it implicitly adds tech bias — but that’s intentional in the indicator’s design.
— the stated goal is to find confluence of volume pressure across the instrument you’re trading plus the dominant market drivers (Mag7, QQQ, SPY).

Think of it like:

“If the thing I want to trade, the mega leaders, broad tech, and the overall market all agree on direction, then signal strength is higher.”
From a risk-management perspective this does overweight tech exposure — but that’s the premise of the indicator rather than a coding mistake.


But why compare non-tech stocks (like WMT) to Mag7/QQQ at all?
This is where it gets more subjective — and where your question makes good sense.

There are two distinct analytical goals that people mix up:


1) Correlation/confirmation in short-term trading
Traders will sometimes check a market leader or broad market benchmark to confirm direction even for unrelated stocks.
Example: If the market and tech leaders are trending down on volume pressure, a weak-relative stock might be less trustworthy to go long. Same in reverse.

This isn’t fundamentally logical — it’s practically tactical:

  • Traders believe cross-market volume signals reflect risk appetite.
  • Broad market strength/weakness tends to influence most stocks (even staples to some degree).
So mag7/QQQ here act as market “context filters” — not as direct predictors of something like WMT.


2) Sector rotation context
If you’re analyzing something like WMT for sector-rotation reasons, then sure — tech weakness could be relevant (people moving from tech into staples), but that’s a different type of relationship.

✔ Anti-correlation or rotation dynamics matter.
Meaning: if QQQ is weakening and volume pressure in staples is rising, that’s a different trade signal than QQQ simply being strong with WMT weak.

But the indicator in the thread doesn’t explicitly model rotation or anti-correlation — it only looks for alignment (all signals the same). If the market is rotating, that alignment won’t happen — and this indicator won’t capture that nuance well.


So what’s the real takeaway?
🔹 Including Mag7 + QQQ is not a “mistake.” It’s a deliberate way to layer pure mega-cap tech direction with broad tech ETF trend and overall market (SPY) to filter signals.

🔹 But yes — it does inherently overweight tech biases, especially in a market where the Magnificent Seven are dominant.

🔹 Therefore — for non-tech stocks like WMT, you might prefer sector-specific context (e.g., consumer staples indices, sector volume signals, rotation indicators) over tech-centric metrics.


Better alternatives for non-tech context
If your goal is to analyze a stock like Walmart (WMT), consider:
  • Volume pressure for sector ETFs (XLP for staples).
  • Relative strength vs broad market.
  • Momentum/volume signals for the stock itself rather than tech benchmarks.
  • Sector rotation indicators (e.g., comparing XLP vs XLK).
That gives you context where tech isn’t dominating the signal.


In short:
The indicator intentionally layers multiple market views — which gives tech-heavy context rather than neutral analysis. For tech stocks that may be useful; for non-tech it may overemphasize unrelated drivers.
To sum it up, I created this indicator for the way I trade and decided to share it. :)
 
Last edited by a moderator:
I can tell you haven't used the indicator yet. ;)

Why include both the Mag7 and QQQ in this indicator?
✅ They aren’t the same thing — even if they’re correlated.
The Mag7 is a custom aggregation of the seven largest tech stocks (AAPL, MSFT, GOOGL, AMZN, META, TSLA, NVDA) averaged together in the script. QQQ is a market-cap-weighted ETF made up of the largest 100 Nasdaq stocks — not just those seven.
So:
  • Mag7 gives a pure view of mega-cap tech consensus (equal-weighted average of those leaders in the script).
  • QQQ gives the broad tech/innovation trend as seen through a real ETF (with heavy—but not exclusive—tech bias).
Even though Mag7 dominate QQQ (around ~38–40%+ of its weighting in real markets), their signals aren’t identical:
✔ Mag7 can diverge from the wider Nasdaq.
✔ QQQ includes semis, software, biotech, etc., beyond the Magnificent 7. StockCharts

So Mag7 + QQQ together is a way to check both tech-core leaders and broader market/tech trend strength.


Does this double-weight tech?
📌 Yes, it implicitly adds tech bias — but that’s intentional in the indicator’s design.
— the stated goal is to find confluence of volume pressure across the instrument you’re trading plus the dominant market drivers (Mag7, QQQ, SPY).

Think of it like:


From a risk-management perspective this does overweight tech exposure — but that’s the premise of the indicator rather than a coding mistake.


But why compare non-tech stocks (like WMT) to Mag7/QQQ at all?
This is where it gets more subjective — and where your question makes good sense.

There are two distinct analytical goals that people mix up:


1) Correlation/confirmation in short-term trading
Traders will sometimes check a market leader or broad market benchmark to confirm direction even for unrelated stocks.
Example: If the market and tech leaders are trending down on volume pressure, a weak-relative stock might be less trustworthy to go long. Same in reverse.

This isn’t fundamentally logical — it’s practically tactical:

  • Traders believe cross-market volume signals reflect risk appetite.
  • Broad market strength/weakness tends to influence most stocks (even staples to some degree).
So mag7/QQQ here act as market “context filters” — not as direct predictors of something like WMT.


2) Sector rotation context
If you’re analyzing something like WMT for sector-rotation reasons, then sure — tech weakness could be relevant (people moving from tech into staples), but that’s a different type of relationship.

✔ Anti-correlation or rotation dynamics matter.
Meaning: if QQQ is weakening and volume pressure in staples is rising, that’s a different trade signal than QQQ simply being strong with WMT weak.

But the indicator in the thread doesn’t explicitly model rotation or anti-correlation — it only looks for alignment (all signals the same). If the market is rotating, that alignment won’t happen — and this indicator won’t capture that nuance well.


So what’s the real takeaway?
🔹 Including Mag7 + QQQ is not a “mistake.” It’s a deliberate way to layer pure mega-cap tech direction with broad tech ETF trend and overall market (SPY) to filter signals.

🔹 But yes — it does inherently overweight tech biases, especially in a market where the Magnificent Seven are dominant.

🔹 Therefore — for non-tech stocks like WMT, you might prefer sector-specific context (e.g., consumer staples indices, sector volume signals, rotation indicators) over tech-centric metrics.


Better alternatives for non-tech context
If your goal is to analyze a stock like Walmart (WMT), consider:
  • Volume pressure for sector ETFs (XLP for staples).
  • Relative strength vs broad market.
  • Momentum/volume signals for the stock itself rather than tech benchmarks.
  • Sector rotation indicators (e.g., comparing XLP vs XLK).
That gives you context where tech isn’t dominating the signal.


In short:
The indicator intentionally layers multiple market views — which gives tech-heavy context rather than neutral analysis. For tech stocks that may be useful; for non-tech it may overemphasize unrelated drivers.
To sum it up, I created this indicator for the way I trade and decided to share it. :)
Still practice trading it and it has been pretty phenomenal used in conjunction with my trading strategy. There are obvious things to look at before entering long or short such as seeing the buy/sell signal at a peak or trough. Also, looking at the buy/sell where the security is consolidating and if an entry is warranted. Again, if used in conjunction with other indicators or candlestick patterns it performs very well. Maybe, if there was a selloff in tech signals might be more difficult, but in that case the overall market would like trend downward as well preventing a buy signal from occurring. I'll keep practice trades with it until February and see if it continues to perform as well as it has in the short time I've added it to my chart indicators.
 
Still practice trading it and it has been pretty phenomenal used in conjunction with my trading strategy. There are obvious things to look at before entering long or short such as seeing the buy/sell signal at a peak or trough. Also, looking at the buy/sell where the security is consolidating and if an entry is warranted. Again, if used in conjunction with other indicators or candlestick patterns it performs very well. Maybe, if there was a selloff in tech signals might be more difficult, but in that case the overall market would like trend downward as well preventing a buy signal from occurring. I'll keep practice trades with it until February and see if it continues to perform as well as it has in the short time I've added it to my chart indicators.
To my view, it's an excellent indicator when used with others for confluence. Just one use case--I tracked it for SPY on the 5D3M using an AGAIG chart (credit to @csricksdds). When the AGAIG long-short bubble fired (and keep in mind that it re-paints) and the other AGAIG indicators kicked in (vertical green/red bar etc), I would only take the trade if at least 3 of the 4 Volume Pressure bars were in the same direction. The results were very good....also I noticed that even if the bars were all the same color, the price could reverse very sharply (to my mind stop-hunting by the MMs but I could be wrong) but the sustained move would eventually come. I would say that this is among the best indicators on the entire UTS forum, as I trade SPY and QQQ frequently. I am not sure how effective it may be for other instruments.
 
Last edited:
To my view, it's an excellent indicator when used with others for confluence. Just one use case--I tracked it for SPY on the 5D3M using an AGAIG chart (credit to @csricksdds). When the AGAIG long-short bubble fired (and keep in mind that it re-paints) and the other AGAIG indicators kicked in (vertical green/red bar etc), I would only take the trade if at least 3 of the 4 Volume Pressure bars were in the same direction. The results were very good....also I noticed that even if the bars were all the same color, the price could reverse every sharply (to my mind stop-hunting by the MMs but I could be wrong) but the sustained move would eventually come. I would say that this is among the best indicators on the entire UTS forum, as I trade SPY and QQQ frequently. I am not sure how effective it may be for other instruments.
I’m glad you mentioned your focus on SPY/QQQ since they’re mine too (including leveraged long & short). Big thanks to @dap711 for the work on this and his service to the US!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
781 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