Parabolic SAR Structural Levels For ThinkOrSwim

Cwparker23

Active member
Plus
mod note:
This is not just another PSAR.

This is a custom‑rolled Parabolic SAR engine with two meaningful upgrades:
1. It exposes the last confirmed SAR levels as horizontal support/resistance, which classic PSAR does not do.​
2. It gives you a stable midline between those levels, which is actually the most useful part for intraday structure.​
Screenshot 2026-02-07 165901.png

Code:
################################
# Original script by Cwparker23#
################################
#-----------------
#- DISCLAIMER
#-----------------
#- I am not a certified financial advisor. The content of this page/site and tools are for informational purposes only and does not constitute financial or legal advice. Under no circumstances will the author be responsible for errors or use of this tool and site. User assumes all risks.

input accelerationFactor = 0.02;
input accelerationLimit  = 0.2;

assert(accelerationFactor > 0, "'acceleration factor' must be positive: " + accelerationFactor);
assert(accelerationLimit >= accelerationFactor,
       "'acceleration limit' (" + accelerationLimit + ") must be greater than or equal to 'acceleration factor' (" + accelerationFactor + ")");

def state = {default init, long, short};
def extreme;
def SAR;
def acc;

def first = IsNaN(SAR[1]);

switch (state[1]) {

case init:
    state   = state.long;
    acc     = accelerationFactor;
    extreme = high;
    SAR     = low;

case short:
    if (first or SAR[1] < high) then {
        state   = state.long;
        acc     = accelerationFactor;
        extreme = high;
        SAR     = extreme[1];
    } else {
        state = state.short;

        if (low < extreme[1]) then {
            acc     = Min(acc[1] + accelerationFactor, accelerationLimit);
            extreme = low;
        } else {
            acc     = acc[1];
            extreme = extreme[1];
        }

        SAR = Max(Max(high, high[1]), SAR[1] + acc * (extreme - SAR[1]));
    }

case long:
    if (first or SAR[1] > low) then {
        state   = state.short;
        acc     = accelerationFactor;
        extreme = low;
        SAR     = extreme[1];
    } else {
        state = state.long;

        if (high > extreme[1]) then {
            acc     = Min(acc[1] + accelerationFactor, accelerationLimit);
            extreme = high;
        } else {
            acc     = acc[1];
            extreme = extreme[1];
        }

        SAR = Min(Min(low, low[1]), SAR[1] + acc * (extreme - SAR[1]));
    }
}

plot Psar = sar;
Psar.SetPaintingStrategy(PaintingStrategy.points);
Psar.DefineColor("Bearish", Color.red);
Psar.DefineColor("Bullish", Color.green);
Psar.AssignValueColor(if Psar > close then Psar.color("Bearish") else Psar.color("Bullish"));

# Detect flips
def flippedToLong  = state == state.long  and state[1] == state.short;
def flippedToShort = state == state.short and state[1] == state.long;

# Store only the most recent completed levels
def lastBullSAR = CompoundValue(1,
    if flippedToLong then SAR else lastBullSAR[1],
    Double.NaN);

def lastBearSAR = CompoundValue(1,
    if flippedToShort then SAR else lastBearSAR[1],
    Double.NaN);

plot SAR_Support = lastBullSAR;
plot SAR_Resistance = lastBearSAR;
plot Mid = (SAR_Support + SAR_Resistance)/2;
mid.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
mid.SetDefaultColor(Color.white);
mid.SetLineWeight(2);

SAR_Support.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SAR_Resistance.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

SAR_Support.SetDefaultColor(Color.GREEN);
SAR_Resistance.SetDefaultColor(Color.RED);

SAR_Support.SetLineWeight(2);
SAR_Resistance.SetLineWeight(2);
 
Last edited by a moderator:

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

I like the idea of this indicator.
Testing on intraday timeframes indicates that the support and resistance levels are similar to the previous highs and lows.

UPDATE:
I take it back! This is a superior indicator! Thank you @Cwparker23
The SAR‑based structural levels encode behavioral regime flips, while previous highs/lows encode location only.

Traders don’t need where price once turned. Which is what previous high/lows tell us.
We need to know where the prior regime met resistance and died and where regimes found support and began. This is what this indicator provides, making it vastly superior to previous highs/lows.
 
Last edited:
I like the idea of this indicator.
Testing on intraday timeframes indicates that the support and resistance levels are the exact same or close to the previous highs and lows.
I think it would work great as a pivot study. Also, help to find higher highs, lower highs, higher lows, and lower lows.
 
Is it statistically proven? No.
Is it structurally logical? Yes.
Is it powerful when combined with:
  • Gamma context
  • Distortion state
  • Efficiency reading
  • Acceptance logic
Very much yes.

The last PSAR dot works as S/R not because of math…but because it marks the last structural stop cascade.
If price returns there:
  • Either prior flow defends
  • Or the unwind resumes
That makes it a decision point.

Works better when:
  • Market is rotational
  • Gamma is positive
  • Volatility suppressed
  • Price respect's structure
Fails when: (but most things do)
  • Negative gamma environment
  • High efficiency > 1
  • Trend day
  • Panic expansion

Good job!
 
Is the stronger level the final dot of the old trend
or the first dot of the new trend?
They are not the same thing structurally.

What Those Two Points Actually Represent
End of the Old PSAR (Last Dot Before Flip)

This is:
  • The final trailing stop of the prior trend
  • The exact level where that trend gets invalidated
  • Where stops were triggered
  • Where forced positioning happened
This level represents the breaking point. It’s where one side lost control. That makes it a liquidity level.

Beginning of the New PSAR (First Dot After Flip)
This is:
  • The first trailing stop of the new trend
  • Often placed aggressively near price
  • More reactive than structural
This level represents the early trailing logic of the new move. It is not where the break happened. It is where the algorithm starts trailing the new side. Very different meaning.

Which Is Stronger? (in our case)
In most market structures, the end of the old PSAR is more structurally meaningful. (@merryDay ?)

Why?
Because:
  • That is where stops triggered
  • That is where the flip was forced
  • That is where liquidity shifted
Markets respect liquidity more than indicators.

How It Behaves in Practice is if price returns to the last old PSAR level, you typically get one of two reactions:
  1. Rejection → continuation of new trend
  2. Acceptance → fake break / regime shift
That makes it a true decision zone.

If price returns to the first new PSAR dot, it often:
  • Gets sliced through
  • Acts as minor trailing noise
  • Only matters in slow grind markets
It’s usually weaker unless:
  • Gamma is positive
  • Volatility suppressed
  • Efficiency low
Then structure holds tighter.

The Deeper Answer is the last dot of the old PSAR marks where the prior market narrative died.
That’s more important than where the new one began.

When the New Dot Becomes Strong is when the first new PSAR dot:
  • Trend is clean
  • Efficiency > 1
  • Gamma negative
  • Market expanding
In that case, the new PSAR acts like a trailing trend rail. But structurally, the old flip level is still the stronger inflection zone.

One Clean Rule You Can Use, if you want something mechanical:
• Use old PSAR flip level as horizontal S/R
• Use new PSAR dots only as trailing stop logic

That separation keeps things clean.
 
PSAR looks amazing in hindsight…and completely useless in the wrong environment.

Here’s when you should ignore PSAR levels completely, not reduce size, not “be cautious”… literally ignore them.

During Negative Gamma + Expansion
If:
  • Price is below gamma flip
  • Efficiency > 1
  • Distortion > 1 (stress)
  • Market is expanding
That’s a trend regime.
In this environment:
• Stops cascade
• Dealers hedge in the direction of the move
• Volatility expands
• Structure stretches

PSAR will flip repeatedly and get steamrolled.
***NOTE: In negative gamma expansion, price does not respect trailing logic.
It accelerates through it. PSAR becomes lagging noise.

On Impulse Breaks Through Walls
If price:
  • Accepts above a call wall
  • Accepts below a put wall
  • Clears a high-gamma node with expansion
PSAR flip levels become irrelevant because that liquidity pocket is already consumed. The market is transitioning to the next liquidity pool. PSAR still thinks in terms of the old regime.

When Efficiency Is > 1.2 (Momentum Environment), High efficiency means Realized move > straddle expectation. That’s not a grind. That’s initiative.

In initiative flows:
• Pullbacks are shallow
• Stops are wide
• PSAR dots are too tight

You’ll get faked out constantly watching PSAR.

On Macro / Event Days PSAR is not followed:
CPI
FOMC
Big earnings
Unexpected headlines

PSAR assumes smooth acceleration. Event days are discontinuous repricing. PSAR can’t model jumps.

When Volatility State and Gamma State Conflict

Example:
  • Suppressed distortion (cheap premium)
  • Negative gamma
  • Efficiency rising
That’s breakout pressure building. PSAR will still try to mean revert because it is based on prior trend geometry. That’s a trap.

When PSAR Actually Works

PSAR works best in:
• Positive gamma
• Suppressed distortion
• Efficiency < 0.8
• Structured rotation

That’s a low vol grind / dealer control regime. There, PSAR levels act like rails. (buy the dips - sell the rips)

The Real Rule

Ignore PSAR when the market is expanding faster than the SAR acceleration factor. PSAR is a trailing stop model. It works when markets trend smoothly. It fails when markets jump regimes.

Use this Quick Decision Filter

Before respecting a PSAR level, ask:
  1. Are we in positive gamma?
  2. Is distortion suppressed?
  3. Is efficiency < 1?

If 2 out of 3 are false, ignore PSAR.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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