Time Segmented Volume with TTM Squeeze For ThinkOrSwim

esvafromdc

New member
This is something I used that combines the TTM squeeze (written as the "Momentum Squeeze" by Mobius) with Time Segmented Volume as written by @cos251. I've used TSV for so long that I forgot it came from here (thought it was standard on TOS)! I've always found the momentum indicator part of the TTM squeeze fairly useless. It's very lagging and even when adjusted, it just reflects obvious price action. Why not use something much more valuable like volume?

Basically, you are looking at the TSV indicator colored like TTM squeeze and with the zero line marked out with the periods where ATR is inside Bollinger bands (red dots), along with the TSV moving average. I have a version of this that is similar on some charts that combines the lower squeeze indicator with advanced volume bars as well. Anyway, just thought I'd throw this out there in case anyone had any other ideas for adding to it or sprucing it up. I've found it much more useful than traditional Carter TTM squeeze for obvious reasons, but including seeing more obvious divergence setups.

Hopefully I've credited everyone correctly!

Code:
# Time Segmented Volume with Squeeze Indicator
# Uses Mobius' Momentum Squeeze code

declare lower;

input length = 20;
input price = close;
input SDmult = 2.0;
input ATRmult = 1.5;
   def K = (Highest(High, length) + Lowest(low, length)) /
2 + ExpAverage(close, length);
def Momo = Inertia(price - K / 2, length);


## Time_Segmented_Volume
##
##
## CREDITS
## Requested by @squatsandstonks from orignal source https://www.tradingview.com/chart/BTCUSD/TG3DTxTR-INDICATOR-TIME-SEGMENTED-VOLUME/
##
##
## Removing the header Credit credits and description is not permitted, any modification needs to be shared.
##
##
## V 1.0 :    @cos251 - Initial release per request from usethinkscript forum.  All logic has not been ported, only base idea
##       :   

input tsvLength = 13;
input maLength = 7;

def t = Sum(if close > close[1] then (volume * (close-close[1])) else if close < close[1] then (volume *(close-close[1])) else 0,tsvLength);
def m = MovingAverage(AverageType.SIMPLE,t,maLength);

def PAL = (t > m) and (t > 0);
def PAL_Fail = (t < m) and (t > 0);
def PAS = (t <m) and (t < 0);
def PAS_Fail = (t > m) and (t < 0);

plot TSV = t;
TSV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
TSV.AssignValueColor(if TSV > 0 then Color.CYAN else Color.RED);
TSV.SetLineWeight(4);
plot TSV_MA = m;
TSV_MA.SetDefaultColor(Color.White);
TSV_MA.SetlineWeight(2);

# Plot Squeeze

def SD = StDev(close, length);
def Avg = Average(close, length);
def ATR = Average(TrueRange(high, close, low), length);
def SDup = Avg + (SdMult * Sd);
def ATRup = Avg + (AtrMult * ATR);
plot Squeeze = if SDup < ATRup
then 0
else Double.NaN;
Squeeze.SetPaintingStrategy(PaintingStrategy.Points);
Squeeze.SetLineWeight(3);
Squeeze.SetDefaultColor(Color.Red);
plot zero = if IsNaN(close) or !IsNaN(Squeeze) then Double.NaN else 0;
zero.SetPaintingStrategy(PaintingStrategy.Points);
zero.SetLineWeight(3);
zero.SetDefaultColor(Color.Green);


# End Code - TSV Squeeze
 
I think that's awesome how you combined the squeeze indicator into this but I do have a question involving the TSV and multiple versions of it on here...
Theres another useful version that works like yours other than the dots. The dots in this one have green, yellow, and red which I am assuming represent the trend. My question to you - is there a way to add more than one dot per candlestick/time? It would be cool for a confirmed green dot trend, followed by strong volume, and a squeeze could help you determine the direction the squeeze would fire.
 
I think that's awesome how you combined the squeeze indicator into this but I do have a question involving the TSV and multiple versions of it on here...
Theres another useful version that works like yours other than the dots. The dots in this one have green, yellow, and red which I am assuming represent the trend. My question to you - is there a way to add more than one dot per candlestick/time? It would be cool for a confirmed green dot trend, followed by strong volume, and a squeeze could help you determine the direction the squeeze would fire.
I'm not entirely sure what you're asking. If you mean two rows of dots, one on top of the other, I'm not aware of a way to do that. As it stands on the indicator now, the direction of the volume bars (red down or blue up) show the impending direction of the trend much more accurately than the momentum indicator that's part of the traditional TSM squeeze. The only I issue I've seen with red dots appearing and an upcoming trend direction is a dud firing and no real trend after the squeeze finishes (red dots become green). For this, there are of course numerous other indicators or price action analysis you can use to confirm or foresee what will happen when coming out of the squeeze (volume spread analysis being the among the best).
 

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