What are the best scripts to detect periods of consolidation?


Active member
2019 Donor
I'm looking for something that can detect consolidation so I can stick to trading trends.

Consolidation where? Top of a given range, middle, etc? It makes a big difference. And what is a trend? There is always a trend, it all depends on how you define it.


2019 Donor
Here is scanning script for base formation with a breakout. Though the source of this is unknown I have used it for quite a long time and find it very helpful.
input spanOfBase = 8;
input maxPrctCorrection = 10;
input spanOfBreakoutHigh = 42;
def flatBaseHigh = highest(high[1], spanOfBase);
def flatBaseLow = lowest(low[1], spanOfBase);
def percentMaxCorrection = AbsValue(100 * (flatBaseLow / flatBaseHigh - 1));
def withinPrctCorrectionLimits = percentMaxCorrection <= maxPrctCorrection; def highShade = if withinPrctCorrectionLimits then flatBaseHigh else flatBaseLow; def lowShade = if withinPrctCorrectionLimits then flatBaseLow else flatBaseHigh; def flatBase = highShade > lowShade;
def highestHighForBreakout = highest(high[1], spanOfBreakoutHigh);
def currentBreakoutHigh = high > highestHighForBreakout;
# only one of these can be scanned for at one time. Use "#" comment marks to turn off
# the one you don't need
#plot flatBaseFormation = flatBase and currentBreakOutHigh == 0;
plot breakOutSignal = currentBreakOutHigh and currentBreakOutHigh[1] == 0 and flatBase;


Well-known member
To use the heiken mtf strategy to the best of its ability it needs a pairing with a study pf sorts. Anyone who has a favorite trend/chop/consolidation study please post it here so we can find the best pairing. I may end up asking @diazlaz to make a combo trend/chop/consolidation paintbar script with many of these indicators if they have promise put together.

So far stoplight v2 seems to be the best pairing.


Active member
2019 Donor
@tomsk Hi, when we are selecting the plot, is there a way to have the flat base formation or the breakout signal plotted on the price chart?

Unable to attach the pic link




New member
I am looking for a scanner that identifies stocks that are currently in consolidation and moving sideways. Ideally, this would identify stocks that have hit their support line twice.

Does anyone have anything similar? Thank you!

Similar threads