What are the best scripts to detect periods of consolidation?

i mean the rsi on a daily chart, each candle as a day. but honestly when people say follow "trend" its bullshit because something thats trending on a 5 minute chart might not be on a 4 hour chart. thats why is good to look at different time frames. and in my opinion thats why consolidation happens, price gets caught up between two time frames. so one time frame want to go up and then the other down. usually the higher time frame wins(usually i think). hopefully thats not confusing.
Nah, I get it. Good insight as well. Gonna take a look at some charts with your suggestions.
 

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

Just a few observations I had when thinking about your question. Consolidation will often times occur after large spikes in volatility (which can be measured with Bollinger Bandwidth or Keltner Bandwidth). After a spike, you can look for Balance of Volume to fade along with a fade in volatility and a narrowing price range (typically leading to a squeeze before the next big move). Just some thoughts. You can see some of what I am referring to in the image below. I would scan for bandwidth pulling off the 75 period length bulge and BoV pulling away from its 40 period length bulge. Again, I haven't tried this out yet, its just a thought. I hope it helps!
ORf4LJL.png
Yoooo. Good observation. I was kinda thinking of something similar. Bollinger Bands open up when the price is volatile, so naturally when price and volume starts to settle, the band will start to shrink. Good thinking too. I will take a look at both of your suggestions.
 
Just a few observations I had when thinking about your question. Consolidation will often times occur after large spikes in volatility (which can be measured with Bollinger Bandwidth or Keltner Bandwidth). After a spike, you can look for Balance of Volume to fade along with a fade in volatility and a narrowing price range (typically leading to a squeeze before the next big move). Just some thoughts. You can see some of what I am referring to in the image below. I would scan for bandwidth pulling off the 75 period length bulge and BoV pulling away from its 40 period length bulge. Again, I haven't tried this out yet, its just a thought. I hope it helps!
ORf4LJL.png
Also, what are these indicators and where can I get them?
 
Does anyone know of a script or how to make a script to scan stocks in consolidation patters? I tried thinkorswim's pattern search option and it isn't that great. The things I've noticed about consolidation patterns is that it follows after an impulsive move up. I guess the correct search parameters would be to scan for a stock that has high volume with large price movement in the last 10-25 days followed by a decrease in volume. I wanted to add that I tried using the thinkorswim quick script wizard and I did more harm than good. lol. Can anyone offer any insight or point me to the right location? Thank you all.
I had one more slightly more simplistic way of scanning for consolidation zones. You can scan for price trading below the 10 period ema on the day chart, but above its 10 period ema on the week chart. It definitely provides and interesting signal for consolidation.
htnKjJA.png
 
Last edited:
Also, what are these indicators and where can I get them?
I can't remember where the BoV original came from (possibly @Ben10) but I am really unsure. I modified it from its original version. Provides some interesting insight for sure.
Code:
#Balance of Volume
#Modified by Christopher84 04/27/2021

declare lower;
input length = 20;
input maxVolumeCutOff = 2.5;
input BulgeLength = 75;
input SqueezeLength = 75;
input BulgeLength2 = 20;
input SqueezeLength2 = 20;

assert(maxVolumeCutOff > 0, "'max volume cut off' must be positive: " + maxVolumeCutOff);

def cutOff = 0.2 * stdev(log(hlc3) - log(hlc3[1]), 30) * close;
def hlcChange = hlc3 - hlc3[1];
def avgVolume = Average(volume, 50)[1];
def minVolume = Min(volume, avgVolume * maxVolumeCutOff);
def dirVolume = if hlcChange > cutOff
    then minVolume
    else if hlcChange < -cutOff
        then -minVolume
        else 0;

plot VFI = ExpAverage(sum(dirVolume, length) / avgVolume, 3);
def VFI_UP = VFI [1] <= VFI;
def VFI_DOWN = VFI [1] > VFI;

VFI.AssignValueColor(if VFI_DOWN then color.RED else if VFI_UP then color.LIGHT_GREEN else color.GRAY);


def ZeroLine = 0;
#ZeroLine.SetDefaultColor(color.GRAY);
#ZeroLine.setStyle(Curve.SHORT_DASH);

plot Bulge = Highest(VFI, BulgeLength);
Bulge.SetPaintingStrategy(PaintingStrategy.Line);
Bulge.SetDefaultColor(color.RED);


plot Squeeze = Lowest(VFI, SqueezeLength);
Bulge.SetPaintingStrategy(PaintingStrategy.Line);
Squeeze.SetDefaultColor(color.LIGHT_GREEN);


plot Bulge2 = Highest(VFI, BulgeLength2);
Bulge2.SetDefaultColor(color.GRAY);
Bulge2.setStyle(Curve.SHORT_DASH);

plot Squeeze2 = Lowest(VFI, SqueezeLength2);
Squeeze2.SetDefaultColor(color.GRAY);
Squeeze2.setStyle(Curve.SHORT_DASH);

AddCloud(VFI, ZeroLine, Color.LIGHT_GREEN, Color.LIGHT_RED);

The Keltner Bandwidth was an idea I put together after seeing the Bollinger Bandwidth indicator. The nice part about this indicator is that it not only show volatility (like the Bollinger Bandwidth indicator), it also indicates trend direction by the color of the bandwidth line.
Code:
#Keltner_Bandwidth
#Created by Christopher84 04/28/2021

declare lower;
#STARC_Bands
input price = close;
input ATR_length = 18;
input SMA_length = 6;
input displace = 0;
input multiplier_factor = 1.15;

def val = Average(price, sma_length);
def average_true_range = Average(TrueRange(high, close, low), length = atr_length);
def Upper_Band = val[-displace] + multiplier_factor * average_true_range[-displace];
def Middle_Band = val[-displace];
def Lower_Band = val[-displace] - multiplier_factor * average_true_range[-displace];

#Keltner_Channel
input factor = 2.0;
input lengthK = 20;
input averageTypeK = AverageType.SIMPLE;
input trueRangeAverageType = AverageType.SIMPLE;
input BulgeLengthK = 150;
input SqueezeLengthK = 150;
input BulgeLengthK2 = 40;
input SqueezeLengthK2 = 40;

def shift = factor * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), lengthK);
def average = MovingAverage(averageTypeK, price, lengthK);
def Avg = average[-displace];
def Upper_BandK = average[-displace] + shift[-displace];
def Lower_BandK = average[-displace] - shift[-displace];

plot BandwidthK = (Upper_BandK - Lower_BandK) / Avg * 100;


plot BulgeK = Highest(BandwidthK, BulgeLengthK);
BulgeK.SetPaintingStrategy(PaintingStrategy.Line);
BulgeK.SetLineWeight(1);
BulgeK.SetDefaultColor(Color.RED);

plot SqueezeK = Lowest(BandwidthK, SqueezeLengthK);
SqueezeK.SetPaintingStrategy(PaintingStrategy.Line);
SqueezeK.SetLineWeight(1);
SqueezeK.SetDefaultColor(Color.GREEN);

plot BulgeK2 = Highest(BandwidthK, BulgeLengthK2);
BulgeK2.SetPaintingStrategy(PaintingStrategy.Line);
BulgeK2.SetStyle(Curve.SHORT_DASH);
BulgeK2.SetLineWeight(1);
BulgeK2.SetDefaultColor(Color.RED);

plot SqueezeK2 = Lowest(BandwidthK, SqueezeLengthK2);
SqueezeK2.SetPaintingStrategy(PaintingStrategy.LINE);
SqueezeK2.SetStyle(Curve.SHORT_DASH);
SqueezeK2.SetLineWeight(1);
SqueezeK2.SetDefaultColor(Color.LIGHT_GREEN);

def STARC_UP = (Upper_BandK[1] < Upper_BandK) and (Lower_BandK[1] < Lower_BandK);
def STARC_DOWN = (Upper_BandK[1] > Upper_BandK) and (Lower_BandK[1] > Lower_BandK);

BandwidthK.AssignValueColor(if ((BandwidthK > BandwidthK[1]) and STARC_UP) then Color.GREEN else if ((BandwidthK < BandwidthK[1]) and STARC_UP) then Color.GREEN else if ((BandwidthK > BandwidthK[1]) and STARC_DOWN) then Color.RED else if ((BandwidthK < BandwidthK[1]) and STARC_DOWN) then Color.RED else Color.GRAY);
 
Last edited:
Just a few observations I had when thinking about your question. Consolidation will often times occur after large spikes in volatility (which can be measured with Bollinger Bandwidth or Keltner Bandwidth). After a spike, you can look for Balance of Volume to fade along with a fade in volatility and a narrowing price range (typically leading to a squeeze before the next big move). Just some thoughts. You can see some of what I am referring to in the image below. I would scan for bandwidth pulling off the 75 period length bulge and BoV pulling away from its 40 period length bulge. Again, I haven't tried this out yet, its just a thought. I hope it helps!
ORf4LJL.png
Good works. Are the main and lower 2 studies available on our web sites?!
 
I had one more slightly more simplistic way of scanning for consolidation zones. You can scan for price trading below the 10 period ema on the day chart, but above its 10 period ema on the week chart. It definitely provides and interesting signal for consolidation.
htnKjJA.png
@Christopher84 Hi, may i know where can I find the script for the lower indicator that plots the consolidation zone or squeeze? Can this be configured as a scan? Thank u
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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