Indicator · Pine Script v6 · On the chart

Turtle Soup

by Ahmed1926· code credited to mickes

An overlay indicator that detects turtle soup setups, where price takes out a higher-timeframe pivot high or low and then reverses.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code64
Settings12inputs
LicenceNone statedfile: MPL-2.0
Last update9 months ago31 Jan 2026

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

64 lines of Pine Script v6 from Turtle soup.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Turtle soup.txt
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mickes

//@version=6
indicator("Turtle soup", overlay = true, max_boxes_count = 500, max_labels_count = 500, max_lines_count = 500)

import mickes/PriceAction/3

_marketStructureLeftPivotLength = input.int(5, "Pivot", inline = "pivot", group = "Market structure")
_marketStructureRightPivotLength = input.int(5, "", inline = "pivot", group = "Market structure")
_marketStructureShowPivots = input.bool(true, "", tooltip = "Set the left and right pivot lengths for the market structure that decides the trend.", inline = "pivot", group = "Market structure")

_pivotLeftLength = input.int(1, "Pivot", inline = "liquidityturtlesoup", group = "Turtle soup liquidity")
_pivotRightLength = input.int(1, "", tooltip = "Set the pivot lengths (right and left) that can be  target for a turtle soup.", inline = "liquidityturtlesoup", group = "Turtle soup liquidity")
_lookback = input.int(5, "Lookback", tooltip = "Set how many pivots back that can be a target for a turtle soup.", group = "Turtle soup liquidity")
_timeframe = input.timeframe("", "Timeframe", tooltip = "The higher timeframe for pivots that can be a target for a turtle soup.", group = "Turtle soup liquidity")
_color = input.color(color.new(color.orange, 70), "Color", group = "Turtle soup liquidity")
_confirmation = input.bool(true, "Confirmation", tooltip = "• ENABLED\nThe turtle soup needs to be followed by a change of character (CHoCH) in the opposite direction.\n\n• DISABLED\nAll potential turtle soups will be shown, even the once with the 'wrong' direction (this is due to how higher timeframe values (pivots in this case) are fethed in Pine Script and that the trend can change during that fetching).", group = "Turtle soup liquidity")

_marketStructureFontSize = input.int(7, "Market structure font size", group = "Display")

_alertFrequency = input.string(alert.freq_once_per_bar_close, "Frequency", [alert.freq_all, alert.freq_once_per_bar, alert.freq_once_per_bar_close], group = "Alerts")

_screenerKeep = input.int(5, "Keep", tooltip = "The indicator will use 'plot()' to be able to screen for turtle soups on the 'Pine Screener' by Tradingview. You can use tge Pine Screener for finding turtle soup setups on entire.\n\nNOTE: Screening is only possible if 'Confirmation' is enabled.", group = "Screening")

Confirm(PriceAction.TurtleSoups turtleSoupsContext, int trend, PriceAction.TurtleSoupSettings settings, int previousStructureBreakBarIndex, PriceAction.Screener screener) =>
    switch trend
        -1 => PriceAction.Confirm(turtleSoupsContext.Bearish, turtleSoupsContext, settings, previousStructureBreakBarIndex, screener)
        1 => PriceAction.Confirm(turtleSoupsContext.Bullish, turtleSoupsContext, settings, previousStructureBreakBarIndex, screener)
TurtleSoup(PriceAction.TurtleSoups turtleSoupsContext, PriceAction.TurtleSoupSettings settings) =>
    if barstate.isconfirmed // only if the bar is closed
        PriceAction.VisualizeTurtleSoups(turtleSoupsContext.Highs, turtleSoupsContext.Bearish, turtleSoupsContext, settings)
        PriceAction.VisualizeTurtleSoups(turtleSoupsContext.Lows, turtleSoupsContext.Bullish, turtleSoupsContext, settings)

var priceAction = PriceAction.PriceAction.new(Swing = PriceAction.Structure.new(_marketStructureLeftPivotLength, _marketStructureRightPivotLength, PriceAction.Type.Swing, 0, -1, false, "", color(na), array.new<box>(), array.new<box>(), array.new<PriceAction.StructureBreak>(), array.new<PriceAction.Pivot>(), _marketStructureFontSize, false, false, false))
PriceAction.Pivot(priceAction.Swing)
if _marketStructureShowPivots
    PriceAction.PivotLabels(priceAction.Swing)

var settings = PriceAction.TurtleSoupSettings.new(_pivotLeftLength, _pivotRightLength, _lookback, _confirmation, _color, _screenerKeep, _alertFrequency)
var turtleSoupsContext = PriceAction.TurtleSoups.new(array.new<PriceAction.Pivot>(), array.new<PriceAction.Pivot>(), array.new<PriceAction.TurtleSoup>(), array.new<PriceAction.TurtleSoup>(), array.new<string>())
var screener = PriceAction.Screener.new()

TurtleSoup(turtleSoupsContext, settings)

changeOfCharacter = false
breakOfStructure = false
if barstate.isconfirmed
    changeOfCharacter := PriceAction.ChangeOfCharacter(priceAction.Swing)
    breakOfStructure := PriceAction.BreakOfStructure(priceAction.Swing)
if settings.Confirmation
    var int previousStructureBreakBarIndex = na
    if changeOfCharacter and not na(previousStructureBreakBarIndex)
        Confirm(turtleSoupsContext, priceAction.Swing.Trend, settings, previousStructureBreakBarIndex, screener)
    if changeOfCharacter or breakOfStructure
        previousStructureBreakBarIndex := bar_index

[pivotHigh, pivotLow] = request.security(syminfo.tickerid, _timeframe, PriceAction.GetPivots(settings))
PriceAction.SetBarIndices(pivotHigh, pivotLow)
PriceAction.SetPivots(turtleSoupsContext, settings, pivotHigh, pivotLow)

PriceAction.Alert(turtleSoupsContext, settings)

plot(bar_index <= screener.TurtleSoupUntilBarIndex ? 1 : 0, "Turtle soup", display = display.none, precision = 0)

Overview

Turtle Soup uses an imported price action library for market structure, with separate pivot lengths for the trend structure and for the liquidity targets, a lookback count and a pivot timeframe. With confirmation on, a setup needs a change of character in the opposite direction. It draws on the chart and offers alerts with a chosen frequency and plotted values for the Pine Screener.

Details

Published by

Ahmed1926 on GitHub

Code credit

mickes, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

SMC / ICT / price action, Support & resistance

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
Pivotint5_marketStructureLeftPivotLength
_marketStructureRightPivotLengthint5_marketStructureRightPivotLength
_marketStructureShowPivotsbooltrue_marketStructureShowPivots
Pivotint1_pivotLeftLength
_pivotRightLengthint1_pivotRightLength
Lookbackint5_lookback
Timeframetimeframe_timeframe
Colorcolorcolor.new(color.orange, 70)_color
Confirmationbooltrue_confirmation
Market structure font sizeint7_marketStructureFontSize
Frequencystringalert.freq_once_per_bar_close_alertFrequency
Keepint5_screenerKeep
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

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows

DE-tracker

by Allen1212
303 stars

This indicator plots labels on the TradingView price chart to mark ARK Invest's buy and sell trades for the DE stock. Buy transactions appear in green with X1 or X2 multipliers showing the number of ARK ETFs involved on the same day; sells appear in red. The m

Indicator v4 Support & resistanceSMC / ICT / price action
Updated 2 years ago · None stated GitHub repository of DE-tracker

This Pine Script indicator plots a ZigZag on the price chart. It identifies reversal points when price moves more than a set percentage from the last pivot. The script calculates forecasts using zigzag data and labels detected geometric patterns including harm

Indicator v4 TrendSupport & resistance

Golden Bullet Strategy

by TradersPost
218 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy

Open Source Fractal

by cantolab
183 stars

This indicator implements the Fractal Model concept to plot market structure shifts, liquidity sweeps, and Change in State of Delivery (CISD) levels. It overlays custom higher-timeframe candle previews, open prices, and time markers directly on the price chart

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · MIT GitHub repository of Open Source Fractal

Swing Failure Signals

by Ganador1
154 stars

This indicator calculates pivot highs and pivot lows to detect liquidity sweeps and Swing Failure Patterns. It identifies when price breaks past recent key swing highs or lows within a configurable historical window, then looks for a quick reversal or change i

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · Apache-2.0 GitHub repository of Swing Failure Signals

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers