Indicator · Pine Script v5 · On the chart

Spinning Top (Candlestick Pattern)

by augustoerni

This Pine Script v5 indicator detects spinning top candlestick patterns by comparing the real body size to user-defined min and max thresholds as percentages of the candle's range.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code27
Settings4inputs
LicenceNone statedfile: MPL-2.0
Last update2 years ago9 Aug 2024

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

27 lines of Pine Script v5 from candlesticks/spinning_top_candlestick_pattern.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

spinning_top_candlestick_pattern.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AugustoErni

//@version=5
indicator("Spinning Top (Candlestick Pattern)", overlay=true)

maxSpinningTopTooltip = "Calculates whether the current candle is a spinning top using the max threshold set. If the size of the real body is less than the max threshold set of the overall range of the candle, then the candle is considered a spinning top."
maxSpinningTopThreshold = input.float(defval=0.55, title='Spinning top body size threshold in percentage. (0.55 = 55%)', step=0.01, tooltip=maxSpinningTopTooltip)

minSpinningTopTooltip = "Calculates whether the current candle is a spinning top using the min threshold set. If the size of the real body is less than the min threshold set of the overall range of the candle, then the candle is considered a spinning top."
minSpinningTopThreshold = input.float(defval=0.21, title='Spinning top body size threshold in percentage. (0.21 = 21%)', step=0.01, tooltip=minSpinningTopTooltip)

showBullishSpinningTop = input.bool(defval=true, title='Show bullish spinning top.', tooltip='Show or hide the bullish spinning top.')
showBearishSpinningTop = input.bool(defval=true, title='Show bearish spinning top.', tooltip='Show or hide the bearish spinning top.')

isBullishCandle = close > open
isBearishCandle = close < open

isSpinningTop = ( ( math.abs(close - open) < (maxSpinningTopThreshold * (high - low)) ) and ( math.abs(close - open) > (minSpinningTopThreshold * (high - low)) ) )

isSpinningTopBullish = isSpinningTop and isBullishCandle and high > close and low < open
isSpinningTopBearish = isSpinningTop and isBearishCandle and high > open and low < close

barcolor(isSpinningTopBullish ? color.white : isSpinningTopBearish ? color.black : na)

plotshape(isSpinningTopBullish and showBullishSpinningTop, title="Spinning Top", style=shape.arrowup, location=location.belowbar, color=color.rgb(255, 255, 255), text="Spinning Top", textcolor=color.green)
plotshape(isSpinningTopBearish and showBearishSpinningTop, title="Spinning Top", style=shape.arrowdown, location=location.abovebar, color=color.rgb(0, 0, 0), text="Spinning Top", textcolor=color.red)

Overview

Spinning Top (Candlestick Pattern) signals bullish spinning tops with a white arrow below the bar and bearish ones with a black arrow above the bar. The indicator draws these signals directly on the price chart. Settings allow toggling the display of each pattern and adjusting the threshold values. It provides visual cues for potential reversals based on candlestick formation.

Details

Published by

augustoerni on GitHub

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Spinning top body size threshold in percentage. (0.55 = 55%)float0.55maxSpinningTopThreshold
Spinning top body size threshold in percentage. (0.21 = 21%)float0.21minSpinningTopThreshold
Show bullish spinning top.booltrueshowBullishSpinningTop
Show bearish spinning top.booltrueshowBearishSpinningTop
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

947 stars

The Heikin-Ashi Chart Identifier is an indicator that checks if the current chart uses Heikin-Ashi candles. It tracks matched candles where open equals the average of previous open and close, and verifies no gaps between bars. When conditions match, it display

Indicator v4 Candlestick patterns
Updated 12 days ago · GPL-3.0 GitHub repository of Heikin-Ashi Chart Identifier
575 stars

The indicator plots ICT displacement candles on the price chart and can switch to retracement scanning. Displacement requires a move larger than a set share of the 14-bar average high-low range, lasting at least a chosen number of bars, with optional close, pr

Indicator v6 SMC / ICT / price actionCandlestick patterns
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Displacement Candles Indicator

All Candlestick Patterns

by shunjizhan
292 stars

All Candlestick Patterns detects and highlights a wide range of bullish, bearish, and neutral candlestick patterns directly on the price chart. It features optional trend filtering using either a 50-period simple moving average or a combination of 50-period an

Indicator v4 Candlestick patternsTrend
Updated 3 years ago · None stated GitHub repository of All Candlestick Patterns
285 stars

Mean Reversion Study is an indicator that identifies trade setups combining exponential moving averages, RSI extremes, and engulfing candlestick patterns. It highlights bullish setups when a bullish engulfing candle forms below the EMA while RSI is oversold, a

Indicator v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Study

[RS]MTF Candle Sticks

by ricardosantos79
261 stars

This indicator overlays up to five higher-timeframe candlestick groups on the price chart. For each enabled timeframe it requests open, high, low, and close and can show up to five candles, offset by a spacing setting. The main inputs set the candle count, the

Indicator v4 Candlestick patternsSupport & resistance Repaints
Updated 4 years ago · None stated GitHub repository of [RS]MTF Candle Sticks
257 stars

This indicator detects a large set of classic candlestick patterns and plots colored labels on the price chart. Trend context uses a 50-period simple moving average, or the 50 and 200 averages stacked together, and can be switched off. Users filter bullish, be

Indicator v4 Candlestick patternsTrend
Updated 7 weeks ago · None stated GitHub repository of Snag - All Candlestick Patterns

More Candlestick patterns scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers