OPEN-SOURCE SCRIPT
Updated Tertiary Pivot Structural Zones

Support and Resistance zones using Adam Grimes Tertiary Pivot concept.
Release Notes
Changed the default settings for better identification of pivotsRelease Notes
What This Indicator Does
This indicator automatically finds the most powerful "floors" (support) and "ceilings" (resistance) on a stock chart. It highlights the exact areas where major institutional players are likely to buy or sell, causing the price to change direction.
I got this idea from the book The Art and Science of Technical Analysis by Adam Grimes. Where he described how to identify the supply and demand zones using pivots.
How It Finds the Zones (The 3-Step Filter)
Instead of treating every tiny price wiggle as important, this indicator filters the market through a strict three-tier confirmation system based on Adam Grimes' core swing principles.
Each level works exactly the same way, but filters a broader layer of market information:
1. Basic Turns (1st-Order Pivots): This is the foundation, built by comparing individual candles.
- A 1st-Order Pivot High is any single candle whose peak is higher than the candles immediately to its left and right.
- A 1st-Order Pivot Low is any single candle whose bottom is lower than the candles immediately to its left and right.
2. Medium Turns (2nd-Order Pivots): This layer steps back to compare the basic turns against each other, filtering out minor noise.
- A 2nd-Order Pivot High is any 1st-order pivot high that is higher than the 1st-order pivot highs immediately to its left and right.
- A 2nd-Order Pivot Low is any 1st-order pivot low that is lower than the 1st-order pivot lows immediately to its left and right.
3. Major Turning Points (3rd-Order / Tertiary Pivots): This is the final macro layer, built by comparing the medium turns against each other to lock onto the strongest structural walls on the chart.
- A 3rd-Order Pivot High is any 2nd-order pivot high that is higher than the 2nd-order pivot highs immediately to its left and right.
- A 3rd-Order Pivot Low is any 2nd-order pivot low that is lower than the 2nd-order pivot lows immediately to its left and right.
How 3rd-Order Pivots Turn into Zones
Instead of treating a major turning point as a single, exact price line, the indicator turns a 3rd-order pivot into a colored block or **zone** (a box).
The box starts exactly at the peak or valley of that major turn. The thickness of the box is determined by the market's recent volatility (using the ATR tool). This creates a dynamic, breathing zone:
- The Volatility Mattress (ATR Sizing): The thickness of the zone automatically changes based on how wild the market is. If the market is moving violently with massive candles, the box gets thicker to absorb the noise. If the market is calm, the box shrinks to be razor-precise.
- Red Boxes (Ceilings): Major supply zones extending downward from a 3rd-order high, where heavy selling pressure is waiting to push the price down.
- Green Boxes (Floors): Major demand zones extending upward from a 3rd-order low, where heavy buying power is waiting to push the price up.
Why 3rd-Order Zones Are Vital for Traders
- Where "Smart Money" Steps In: 3rd-order pivots represent massive market turning points where major institutional investors and banks stepped in with heavy capital to completely reverse the trend.
- Institutional Memory (The Rematch): Big institutions usually don't buy or sell their entire position all at once. When the price eventually returns to a 3rd-order zone weeks or months later, these major players often defend that exact area again.
- High-Probability Reversals: Because these zones represent the strongest macro walls on the chart, they give traders high-probability entry coordinates. When price hits a 3rd-order zone, it is highly likely to react, stall, or completely reverse.
Keeping the Chart Clean
- Real-Time Tracking: The colored boxes automatically stretch out into the future as long as that floor or ceiling remains undefeated.
- The Break Protocol: If the price breaks completely through a zone and a candle **closes outside of it**, that wall is officially knocked down. The indicator instantly deletes the colored box to keep your workspace clean and leaves behind a simple dashed line so you can remember where a major historical level used to sit.
Release Notes
I added alert system to the indicator. So when the price enters the Supply or demand zone, you can setup an alert. Steps to Setup the alert:
Step 1: Add the indicator to your chart.
Step 2: Open the Alert Creation Window
There are three quick ways to do this:
- Press Alt + A on your keyboard (Windows) or Option + A (Mac).
- Click the Clock icon (Alerts) on the right-hand sidebar, then click Create Alert.
- Click the Three Dots next to the indicator's name on your chart and select Add alert on....
Step 3: Configure the Alert Settings
In the Create Alert dialog box, set the parameters exactly like this:
- Condition: Click the dropdown and select Tertiary Pivot Structural Zones (Adam Grimes) - Master.
- Secondary Dropdown: Right below the condition, click the next dropdown and select Zone Hit (Supply or Demand).
- Trigger: Select Once Per Bar (if you want to be alerted the exact second the price steps into the zone) or Once Per Bar Close (if you only want an alert if the candle stays inside the zone when it closes).
Step 4: Turn On the Sound
Scroll down to the Notifications section of the alert box:
- Check the box for Play sound.
- Leave the sound dropdown menu on your standard preference (or choose your preferred tone).
- Set the duration (e.g., 5 seconds or 10 seconds) so the chime loops long enough to catch your attention.
- Click Create.
Release Notes
Made changes so that no two supply or demand zones are overlapping.When a tertiary pivot forms in the existing zone, the zone expands covering the high or low of that newly formed tertiary pivot.
This way the chart will look clean and the liquidity sweeps will be taken into account.
Release Notes
Fixed Some bugs. Fixed the issue of two consecutive pivots having the same high or low(The second pivot will be recognised as the next level pivot)
Release Notes
Fixed Some bugsOpen-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.