Indicator · Pine Script v6 · On the chart

KatanaFlow

by 7mertyavuz

KatanaFlow is a trend-following overlay indicator that combines a Twin Range Filter with a smoothed moving average line to identify market direction and signal reversals.

View on GitHub

GitHub stars3on the repository
Pine versionv6current
Lines of code103
Settings19inputs
LicenceMIT
Last update3 months ago23 Jul 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

103 lines of Pine Script v6 from KatanaFlow.pine.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.

KatanaFlow.pine.txt
// KatanaFlow v1.0.1
// Geliştirici: Mert Yavuz
// Güncelleme: 2025-08-08 19:23:58
//@version=6
indicator("KatanaFlow", overlay=true)

// === Kullanıcı Modu Ayarı ===
mod = input.string("Temel", title="Kullanıcı Modu", options=["Temel", "Uzman"])

// === TRF (Twin Range Filter) ===
source = input.source(close, title="Veri Kaynağı (TRF)")
per1 = input.int(12, minval=1, title="Hızlı Periyot")
mult1 = input.float(1.0, minval=0.1, title="Hızlı Aralık Katsayısı")
per2 = input.int(4, minval=1, title="Yavaş Periyot")
mult2 = input.float(2.0, minval=0.1, title="Yavaş Aralık Katsayısı")

smoothrng(x, t, m) =>
    wper = t * 2 - 1
    avrng = ta.ema(math.abs(x - x[1]), t)
    ta.ema(avrng, wper) * m

smrng1 = smoothrng(source, per1, mult1)
smrng2 = smoothrng(source, per2, mult2)
smrng = (smrng1 + smrng2) / 2

var float filt = source
filt := source > filt[1] ? (source - smrng < filt[1] ? filt[1] : source - smrng) : (source + smrng > filt[1] ? filt[1] : source + smrng)

var float upward = 0.0
var float downward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])

hband = filt + smrng
lband = filt - smrng

longCond = (source > filt and upward > 0)
shortCond = (source < filt and downward > 0)

var int CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]

long = longCond and CondIni[1] == -1
short = shortCond and CondIni[1] == 1

plotshape(long, title="KATA Long", text="KATA Long", style=shape.labelup, textcolor=color.black, size=size.tiny, location=location.belowbar, color=color.lime)
plotshape(short, title="KATA Short", text="KATA Short", style=shape.labeldown, textcolor=color.white, size=size.tiny, location=location.abovebar, color=color.red)

alertcondition(long, title="KATA Long", message="📈 KATA Long sinyali")
alertcondition(short, title="KATA Short", message="📉 KATA Short sinyali")

plot(mod == "Uzman" ? filt : na, title="TRF Filtresi", color=color.gray)
plot(mod == "Uzman" ? hband : na, title="TRF Üst Bant", color=color.red)
plot(mod == "Uzman" ? lband : na, title="TRF Alt Bant", color=color.green)

// === REMA (KATA Trend) ===
price = input.source(close, 'Veri Kaynağı (KATA)', group='KATA Trend Ayarları')
length = input.int(45, minval=1, group='KATA Trend Ayarları')
smooth = input.int(1, minval=1, group='KATA Trend Ayarları')
mult = input.float(0.3, minval=0.05, maxval=3, step=0.05, title='Genişlik', inline='SD Kanal', group='KATA Trend Ayarları')
sd_len = input.int(5, minval=1, title='Periyot', inline='SD Kanal', group='KATA Trend Ayarları')

baseline = ta.wma(price, sd_len)
dev = mult * ta.stdev(price, sd_len)
upper = baseline + dev
lower = baseline - dev
cprice = price > upper ? upper : price < lower ? lower : price
REMA = ta.wma(ta.wma(cprice, length), smooth)
REMA_up = REMA > REMA[1]
plot(REMA, title='KATA Trend Çizgisi', color=REMA_up ? color.green : color.red, linewidth=3)

SwingDn = REMA_up[1] and not REMA_up
SwingUp = REMA_up and not REMA_up[1]
alertcondition(SwingUp, title="KATA Swing Up", message="📊 KatanaFlow trend yukarı döndü")
alertcondition(SwingDn, title="KATA Swing Down", message="📊 KatanaFlow trend aşağı döndü")
alertcondition(SwingUp or SwingDn, title="KATA Trend Değişimi", message="📊 KatanaFlow trend yön değiştirdi.")

// === Opsiyonel MA'lar (Uzman modda açılır) ===
f_ma(source, length, mtype) =>
    switch mtype
        'SMA' => ta.sma(source, length)
        'EMA' => ta.ema(source, length)
        => ta.wma(source, length)

gr_ma = 'Opsiyonel MA\'lar'
t_ma1 = 'MA #1'
t_ma2 = 'MA #2'

show_ma1 = input.bool(false, t_ma1, inline=t_ma1, group=gr_ma)
ma1_type = input.string('SMA', '', options=['SMA', 'EMA', 'WMA'], inline=t_ma1, group=gr_ma)
ma1_source = input.source(close, '', inline=t_ma1, group=gr_ma)
ma1_length = input.int(50, '', minval=1, inline=t_ma1, group=gr_ma)
ma1_color = #9c27b0
ma1 = f_ma(ma1_source, ma1_length, ma1_type)
plot(mod == "Uzman" and show_ma1 ? ma1 : na, color=color.new(ma1_color, 0), title=t_ma1, linewidth=1)

show_ma2 = input.bool(false, t_ma2, inline=t_ma2, group=gr_ma)
ma2_type = input.string('SMA', '', options=['SMA', 'EMA', 'WMA'], inline=t_ma2, group=gr_ma)
ma2_source = input.source(close, '', inline=t_ma2, group=gr_ma)
ma2_length = input.int(100, '', minval=1, inline=t_ma2, group=gr_ma)
ma2_color = #1163f6
ma2 = f_ma(ma2_source, ma2_length, ma2_type)
plot(mod == "Uzman" and show_ma2 ? ma2 : na, color=color.new(ma2_color, 0), title=t_ma2, linewidth=1)

Overview

KatanaFlow calculates adaptive volatility bands using dual-period range smoothing to filter out price noise and plots buy and sell signal labels on the price chart. In Expert mode, the indicator displays filter bands and dynamic support-resistance lines. User settings allow customization of fast and slow filter periods, range multipliers, and trend length. It plots directly on the price chart pane.

Details

Published by

7mertyavuz 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
Kullanıcı ModustringTemelmod
Veri Kaynağı (TRF)sourceclosesource
Hızlı Periyotint12per1
Hızlı Aralık Katsayısıfloat1.0mult1
Yavaş Periyotint4per2
Yavaş Aralık Katsayısıfloat2.0mult2
Veri Kaynağı (KATA)sourcecloseprice
lengthint45length
smoothint1smooth
Genişlikfloat0.3mult
Periyotint5sd_len
show_ma1boolfalseshow_ma1
Show all 19 settings
SettingTypeDefaultVariable
ma1_typestringSMAma1_type
ma1_sourcesourceclosema1_source
ma1_lengthint50ma1_length
show_ma2boolfalseshow_ma2
ma2_typestringSMAma2_type
ma2_sourcesourceclosema2_source
ma2_lengthint100ma2_length
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

[RS]Donchian Fans

by ricardosantos79
261 stars

This indicator plots Donchian Channel boundary lines along with dynamic fan projections directly on the price chart. It calculates the highest high, lowest low, and median price over a customizable lookback period. Whenever price establishes a new channel high

Indicator v4 Support & resistanceTrend
Updated 4 years ago · None stated GitHub repository of [RS]Donchian Fans

Dynamic Linear Regression

by TradersPost
228 stars

Dynamic Linear Regression calculates and plots linear regression trendlines and standard deviation channels directly on the price chart over a user-selected time period. Traders can configure static channels locked at the end time, dynamic channels that contin

Indicator v6 TrendSupport & resistance
Updated 3 months ago · None stated GitHub repository of Dynamic Linear Regression

ATR Trailing Stop

by mihakralj
99 stars

Calculates an ATR-based trailing stop overlaid on the price chart to assist with trend identification and stop placement. Using a specified ATR period and multiplier, it projects upper and lower bounds around the closing price. The stop line ratchets up during

Indicator v5 TrendVolatility & bands
Updated 4 weeks ago · Apache-2.0 GitHub repository of ATR Trailing Stop

Moon Dev Lunar Sniper

by moondevonyt
92 stars

Moon Dev Lunar Sniper is a multi-indicator overlay that scores confluence across fast and slow EMAs, RSI, MACD, DMI, and BB width to fire signals only when score meets the minimum threshold. It plots buy and sell signals on the price chart, highlights cosmic b

Indicator v6 TrendOscillators & momentum Repaints
Updated 2 months ago · Custom licence GitHub repository of Moon Dev Lunar Sniper

SuperTrend & Pivots

by dcaoyuan
55 stars

This overlay indicator plots a SuperTrend line on the price chart using a fixed ATR length of 10 and a factor of 3. When the trend direction is up it draws a green line and a light green fill toward the candle midpoint; when down it draws a red line and a ligh

Indicator v6 TrendVolatility & bands
Updated 6 months ago · Apache-2.0 GitHub repository of SuperTrend & Pivots

More Trend 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