PSAR Transition Indicator for ThinkorSwim

tomsk

Well-known member
VIP
This study looks for a PSAR state transition (either from bullish to bearish or vice versa) and plots a horizontal price line into the expansion area.
If the state transition already triggered, it calculates the number of bars ago the event happened. I've included labels, alerts as well as chart bubbles.
As of this moment if you load a daily chart of GS, you'll see a state transition TODAY!

Here is the code

Code:
# PSAR Transition Indicator
# tomsk
# 11.20.2019

# V1.0 - 11.20.2019 - tomsk - Initial release of PSAR Transition Indicator

# This study looks for a PSAR state transition (either from bullish to bearish
# or vice versa) and plots a horizontal price line into the expansion area. If
# the state transition already triggered, it calculates the number of bars ago
# the event happened. I've included labels, alerts as well as chart bubbles

input accelerationFactor = 0.02;
input accelerationLimit = 0.2;
input offSet = 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 bar = barNumber();
def state = {default init, long, short};
def extreme;
def SAR;
def acc;

switch (state[1]) {
case init:
    state = state.long;
    acc = accelerationFactor;
    extreme = high;
    SAR = low;
case short:
    if (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 (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 parSAR = SAR;
parSAR.SetPaintingStrategy(PaintingStrategy.POINTS);
parSAR.SetDefaultColor(GetColor(5));
def transitionBull = state[1] == state.short and state == state.long;
def transitionBear = state[1] == state.long and state == state.short;
def transitionBar = if transitionBull or transitionBear
                    then bar
                    else transitionBar[1];
def transitionPrice = if bar == HighestAll(transitionBar)
                      then close
                      else transitionPrice[1];
def transitionBarsAgo = if bar != transitionBar
                 then bar - transitionBar
                 else if bar == transitionBar
                      then Double.NaN
                 else transitionBarsAgo[1];
def timeAxis = if IsNaN(close[-1]) and !IsNaN(close) then bar else timeAxis[1];
plot horizLine = if GetTime() <= RegularTradingEnd(getYYYYMMDD()) and
                 transitionBar == HighestAll(transitionBar)
                 then transitionPrice
                 else Double.NaN;
horizLine.SetLineWeight(2);
horizLine.SetDefaultColor(Color.Yellow);
AddLabel(transitionBull or transitionBear, "PSAR Transition Detected Now!", Color.Yellow);
AddLabel(!(transitionBull or transitionBear), "PSAR Transition " + transitionBarsAgo + " bars ago", Color.Cyan);
Alert(transitionBull, "PSAR Transition Bull", Alert.BAR, Sound.Ding);
Alert(transitionBear, "PSAR Transition Bear", Alert.Bar, Sound.Ring);
AddChartBubble(bar == HighestAll(timeAxis+offSet), transitionPrice, "PSAR\nTransitioned", Color.Pink);
# End PSAR Transition Indicator
 
Last edited:

ssara

New member
VIP
Excellent & Genius! Can we extend it a bit -- Can we show the last XX Transitions? Say last 5?
 

tomsk

Well-known member
VIP
Excellent & Genius! Can we extend it a bit -- Can we show the last XX Transitions? Say last 5?

I like to keep things simple and that's why I designed it to show the most recent transition. If you like to show more lines all you need to do is to replicate my code. Remember each line you draw needs it's own set of variables to keep track of the transition bar number and price. It also needs separate plot statement.

I've given you the methodology, so feel free to replicate as many lines as you need. Personally I'd think your chart will look very cluttered.
 
Last edited:

rogtrader

Member
Hello Good fellas,

Having had all these indicators, I have traded many parabolic moves poorly and lost money or missed the boat.

I can’t feel the confidence to drop big money into a trade.

How do I get that confidence? Here are a few questions on my mind:

1. What charts do you guys use? Ticks are better to exit sooner or Rinko are better?

2. How do you guys exit or save profits before the big drop or downward halt?

3. How do we enter into a trade after the halt?

4. What are the indicators? Pretty much everything is lagging and I see that it’s dropping in front of my eyes and I can’t get a better price during the sell... or I’ll hold the bag forever.

5. Anyone using conditional orders to exit quickly?

6. Have you guys tried the TDA API to automatically enter and exit?

7. Is there any pumping group? I see many no news runners running crazy.. not sure how people are buying in big numbers.. you’re look at 20x daily volume all of sudden .. with no catalyst.

8. Any paid indicators or scanners for these parabolic moves?

9. Looks like conditional orders based on 1m are too late.. as everyone seems to be trading ticks?

10. Any popular candle patterns or price action for the parabolic moves?

11. If you miss the waves, any short criteria?

Thanks much !!!
 

MerryDay

Well-known member
VIP
I love my PSAR. I use this one.

However, it is just a trending indicator, it can't tell you that an uptrend will continue to run.
  • I don't chase price so I can't tell you how to pick out those 'no news runners running crazy'. If you find a way, be sure to come back and let us know.
  • I trade on catalysts which I believe will drive the price.
  • I exit when it hits resistance on the AMM2. That sometimes leaves too early, but if it breaks through resistance, I can always buy back in.
  • If I feel unsure of a trade, I set a conditional order for when the zscore drops below 0.
  • I don't know anyone on this forum that uses the API to auto-trade. The sum and substance that I have seen: https://usethinkscript.com/threads/...y-the-script-for-autotrading.2189/#post-43619
 
Last edited by a moderator:

cabe1332

Member
@rogtrader

Been trading for 5 months now and have been following useThinkscript.com for two months. I maintain an 80% win trade ratio and kept my losses to a minimum. Some read books, but I've learned much of the strategies I use from YouTube and customize indicators (buy/sell) to do OK. Yes, we all lose some money along the way, but you are here to avoid that. You have a boatload of questions, and the answer you may find by doing some research.

Below is a boatload of youtube clips that will inspire you and get better on your journey to gain confidence. Again, you will find a boatload of strategies and awesome people sharing knowledge, subscribe and join their chat rooms and discord.

https://www.youtube.com/channel/UCKguLNWdrnrm2p6m3GVgKXQ/videos

Good Luck!

cabe1332
 

Vince Field

Active member
It's not easy to catch breakouts on the first move. Unless you already had your eye on that stock, you usually have to wait for a pullback after the initial move which can be caught with a momentum scanner. The most important thing for catching the first big move is having the right stocks in your watchlist - stocks with significant gaps due to good news and high relative volume. Just like almost all of the pro traders that I know of, I wouldn't focus on indicators. Price action and high probability chart patterns will serve you better. When I first started I was thrilled to have found this site, thinking that I would surely find the perfect set of indicators to give me the edge I was looking for to be a successful trader. I eventually found that I was wrong - you need much more than some fancy indicators to make it in this game. In fact, the most successful traders I know of use hardly any indicators.

I'd recommend checking out my day trading strategies onenote document to learn some high probability setups that only require the use of moving averages, VWAP and/or volume. https://1drv.ms/u/s!Ag3p10maeR_bjEr8zI1BRLgu1rUX?e=Y9gt1v
 

BenTen

Administrative
Staff
VIP
@doug914 This is more of a utility. If you want to scan for PSAR state change, then you can use the built-in ParabolicSARCrossover indicator.

Here is an example—scanning for bearish change.

emL5Ps3.png
 

Similar threads

Top