Tweezer and Kangaroo Tail
"Tweezers and Kangaroo Tail" by LonesomeTheBlue, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Tweezers and Kangaroo Tail (v4.0), read 2026-10-12T16:09:11.067Z; source language v4.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
Tweezers and Kangaroo Tail by LonesomeTheBlue, ported from Pine v4. Overlay indicator with 4 marker series, alerts and 13 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LonesomeTheBlue
// ------------------------------------------------------------------------------------------------
// Original author: LonesomeTheBlue
// Original title: Tweezers and Kangaroo Tail
// Licence: MPL-2.0 (the header above is the original notice, kept verbatim)
// Pine version: 4
// Fetched: 2026-10-12
// Ported to FloScript by FloSignals; modifications under MPL-2.0.
// Converter: @flosignals/floscript 0.1.0, strict mode, score 100/100
// ------------------------------------------------------------------------------------------------
//@floscript=1
//@version=5
// Converted by the FloScript converter from a Pine-compatible v4 source.
indicator("Tweezer and Kangaroo Tail", overlay=true)
enable_tweezer = input(defval=true, title="Enable Tweezer")
maxrate = input(defval=150., title="Max Rate % Between Wick Sizes") / 100.
leveldiff = input(defval=20., title="Max Difference in level %") / 100.
prd = input(defval=5, title="Highest/Lowest Period")
apartprd = input.int(defval=12, title="Max Distance between Tweezers", minval=1)
colup = input(defval=color.lime, title="Color", inline="col")
coldn = input(defval=color.red, title="", inline="col")
topwick = high - math.max(close, open)
bottomwick = math.min(close, open) - low
body = math.abs(close - open)
ishb = ta.highestbars(prd) == 0
islb = ta.lowestbars(prd) == 0
aparttweezers_top(len) =>
ret = 0
if topwick > 0
for x = 1 to apartprd
if nz(topwick[x]) == 0
break
if math.max(topwick, topwick[x]) / math.min(topwick, topwick[x]) <= maxrate and math.abs(high - high[x]) < math.max(topwick, topwick[x]) * leveldiff and ishb[x]
ret := x
break
else if high[x] >= high
ret := 0
break
ret
aparttweezers_bottom(len) =>
ret = 0
if bottomwick > 0
for x = 1 to apartprd
if nz(bottomwick[x]) == 0
break
if math.max(bottomwick, bottomwick[x]) / math.min(bottomwick, bottomwick[x]) <= maxrate and math.abs(low - low[x]) < math.max(bottomwick, bottomwick[x]) * leveldiff and islb[x]
ret := x
break
else if low[x] <= low
ret := 0
break
ret
top_tweezer = enable_tweezer and aparttweezers_top(apartprd)
bottom_tweezer = enable_tweezer and aparttweezers_bottom(apartprd)
plotshape(top_tweezer, text="T", style=shape.labeldown, location=location.abovebar, color=coldn, textcolor=color.white)
plotshape(bottom_tweezer, text="T", style=shape.labelup, location=location.belowbar, color=colup, textcolor=color.black)
// KANGAROO TAIL
enable_kangaroo_tail = input(defval=true, title="Enable Kangaroo Tail")
prd1 = input.int(defval=20, title="Period for Room", minval=2, maxval=50)
prd2 = input.int(defval=8, title="Minimum Period for Room", minval=2, maxval=50)
atrmult = input.int(defval=5, title="ATR Factor for Room Height", minval=2, maxval=30)
wickmult = input.float(defval=3., title="Wick/Body Rate", minval=1)
wickmultavg = input.float(defval=2., title="Wick/Average_Wick Rate", minval=1)
float ph = ta.highestbars(high, prd1) == 0 ? high : na
float pl = ta.lowestbars(low, prd1) == 0 ? low : na
var dir = 0
dir := ph and na(pl) ? 1 : pl and na(ph) ? -1 : dir
var max_array_size = 4
var zigzag = array.new_float(4, 0.)
add_to_zigzag(value, bindex) =>
array.unshift(zigzag, bindex)
array.unshift(zigzag, value)
array.pop(zigzag)
array.pop(zigzag)
update_zigzag(value, bindex) =>
if array.size(zigzag) == 0
add_to_zigzag(value, bindex)
else
if dir == 1 and value > array.get(zigzag, 0) or dir == -1 and value < array.get(zigzag, 0)
array.set(zigzag, 0, value)
array.set(zigzag, 1, bindex)
0.
dirchanged = ta.change(dir)
if ph or pl
if dirchanged
add_to_zigzag(dir == 1 ? ph : pl, bar_index)
else
update_zigzag(dir == 1 ? ph : pl, bar_index)
averagetopwicksize = ta.sma(topwick, 50)
topkangaroo = enable_kangaroo_tail and dir == 1 and topwick >= body * wickmult and close <= low + (high - low) / 3 and open <= low + (high - low) / 3 and open < high[1] and open > low[1] and close < high[1] and close > low[1] and topwick >= wickmultavg * averagetopwicksize and body > 0 and ph and array.get(zigzag, 0) == high and array.get(zigzag, 0) - array.get(zigzag, 2) > ta.atr(50) * atrmult and array.get(zigzag, 1) - array.get(zigzag, 3) > prd2
bottomkangaroo = enable_kangaroo_tail and dir == -1 and bottomwick >= body * wickmult and close >= high - (high - low) / 3 and open >= high - (high - low) / 3 and open < high[1] and open > low[1] and close < high[1] and close > low[1] and bottomwick >= wickmultavg * averagetopwicksize and body > 0 and pl and array.get(zigzag, 0) == low and array.get(zigzag, 2) - array.get(zigzag, 0) > ta.atr(50) * atrmult and array.get(zigzag, 1) - array.get(zigzag, 3) > prd2
plotshape(topkangaroo, text="K", style=shape.labeldown, location=location.abovebar, color=coldn, textcolor=color.white)
plotshape(bottomkangaroo, text="K", style=shape.labelup, location=location.belowbar, color=colup, textcolor=color.black)
alertcondition(topkangaroo, title='Kangaroo Tail Bearish', message='Kangaroo Tail Bearish')
alertcondition(bottomkangaroo, title='Kangaroo Tail Bullish', message='Kangaroo Tail Bullish')
alertcondition(top_tweezer, title='Tweezers Bearish', message='Tweezers Bearish')
alertcondition(bottom_tweezer, title='Tweezers Bullish', message='Tweezers Bullish')
This file is under the Mozilla Public License 2.0; it is a port of the original by LonesomeTheBlue, with the original licence header kept and the changes made for FloScript noted in the file.
- v2
Library refresh 2026-10-14
- v1
Library refresh 2026-10-12
Disclaimer. Scripts are written and published by members, or ported by FloSignals from open-source originals, and are their authors' own work and opinion. FloSignals does not review them for correctness and nothing in a script is financial advice or a recommendation to buy or sell anything — read the Risk Disclaimer. Posting here is under the Community Rules; a script that is not the poster's to post can be reported as the Copyright & Takedowns page says.

Comments (0)
No comments yet. Members can leave one.