Spinning Tops Candlestick Pattern for ThinkorSwim


Staff member
Spinning top is a candlestick pattern that shows indecision in the market.

It’s a small candlestick pattern. In this pattern, the stock prices open and close are near each other. This pattern forms when there’s indecision among the buyers and sellers in the uptrend, downtrend, or sideways trend. The pattern suggests a possible change in trend.



thinkScript Code

# Spinning Top Candlestick Pattern
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/LyNzdJVX-Spinning-Tops/

input stsize = 0.5;
def spinningtop = (open>close) and ((high-low)>(3*(open-close))and(((high-open)/(.001+high-low))< stsize)and (((close-low)/(.001+high-low))< stsize)) or (close>open) and ((high-low)>(3*(close-open))and(((high-close)/(.001+high-low))< stsize)and (((open-low)/(.001+high-low))< stsize));

assignPriceColor(if spinningtop then Color.CYAN else Color.WHITE);

A few resources to help you learn more about this pattern:


Active member
Hi I'm new! This seems to work very well on oil futures, 5mins. Due to me being partial colour blind, I can't spot colours that well, hence using a white background, with black and hollow candles. Is it possible to change the code "then Color.BLUE else Color.[no change]);
I'm unsure how to change this variable.

Edit: silly me. all i have to do is change color to black, since the up candles are hollow
Last edited:


Staff member
@Playstation Here you go:

# Plot Signal
plot signal = spinningtop;

The arrow isn't to give you direction, it's just telling you where the spinning top is.


New member
@BenTen I saw an indicator on TView where the “body” of the Spinning Top candle is displayed a S/R line. I can probably cut and paste a code but cannot find a code that does that. I’ve only found S/R lines that display High/Low/Middle. Thanks for the guidance.


Staff member
@MHCain Take a look at the "fancy version" of the Blast Off indicator here and use part of its script for this one.


New member
I usually refactor the code to get a better understanding of what it's doing. Here's what I got from this:

def body_top = Max(open, close);
def body_bottom = Min(open, close);
def upper_shadow = high - body_top;
def lower_shadow = body_bottom - low;
def candle_height = high - low;

def body_height_is_less_than_one_third_candle_height = candle_height > 3 * BodyHeight();
def upper_shadow_height_is_less_than_one_half_ish_candle_height = upper_shadow < (.001 + candle_height) / 2;
def lower_shadow_height_is_less_than_one_half_ish_candle_height = lower_shadow < (.001 + candle_height) / 2;

plot spinning_top = body_height_is_less_than_one_third_candle_height
    and upper_shadow_height_is_less_than_one_half_ish_candle_height
    and lower_shadow_height_is_less_than_one_half_ish_candle_height;

assignPriceColor(if spinning_top then Color.RED else Color.WHITE);

It appears to find some spinning tops, but according to Steve Nison, linking whether it is a spinning top to the heights of the shadows like this is going to leave a lot of stuff out. Make your decisions on what sources you trust and understand that not every source agrees.
“The Japanese term for a small real body (black or white) is a spinning top. Exhibit 3.6 shows examples of spinning tops. The lines illustrated in Exhibit 3.6 have upper and lower shadows, but the sizes of the shadows are not important. It is the small size of the real body that makes these spinning tops.”

Excerpt From: Steve Nison. “Japanese Candlestick Charting Techniques.” Apple Books. https://books.apple.com/us/book/japanese-candlestick-charting-techniques/id648523437


New member
Here's an alternative, attempting to just go by body size, relative to the average body size of the past 20 bars, adjustable of course. This is assuming that relatively small is when you start approaching a standard deviation less than the average. I use .5 standard deviation as a starting point since it still seems to be fairly small.

input scaling_factor= 0.5;
input length = 20;

def average_body_height = Average(BodyHeight(),length);
def body_height_std_dev = StDev(BodyHeight(),length);
def small_body = BodyHeight() < average_body_height - scaling_factor *  body_height_std_dev;

plot spinning_top = small_body;

assignPriceColor(if spinning_top then Color.RED else Color.WHITE);

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.