1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.
Source Code
98 lines of Pine Script v6 from katana.pinescript, published under BSD-3-Clause. Keep the author's credit and licence lines when you reuse it.
katana.pinescript
//@version=6
strategy("SHODAN9 Katana", overlay=true, pyramiding=0,process_orders_on_close=true)
// --- parametry SAR (do podglądu na wykresie)
start = input.float(0.02, "SAR start")
increment = input.float(0.24, "SAR increment")
maximum = input.float(0.24, "SAR max")
// --- Parabolic SAR (dla wizualizacji)
var bool uptrend = false
var float EP = na
var float SAR = na
var float AF = start
var float nextBarSAR = na
if bar_index > 0
firstTrendBar = false
SAR := nextBarSAR
if bar_index == 1
float prevSAR = na
float prevEP = na
lowPrev = low[1]
highPrev = high[1]
closeCur = close
closePrev = close[1]
if closeCur > closePrev
uptrend := true
EP := high
prevSAR := lowPrev
prevEP := high
else
uptrend := false
EP := low
prevSAR := highPrev
prevEP := low
firstTrendBar := true
SAR := prevSAR + start * (prevEP - prevSAR)
if uptrend
if SAR > low
firstTrendBar := true
uptrend := false
SAR := math.max(EP, high)
EP := low
AF := start
else
if SAR < high
firstTrendBar := true
uptrend := true
SAR := math.min(EP, low)
EP := high
AF := start
if not firstTrendBar
if uptrend
if high > EP
EP := high
AF := math.min(AF + increment, maximum)
else
if low < EP
EP := low
AF := math.min(AF + increment, maximum)
if uptrend
SAR := math.min(SAR, low[1])
if bar_index > 1
SAR := math.min(SAR, low[2])
else
SAR := math.max(SAR, high[1])
if bar_index > 1
SAR := math.max(SAR, high[2])
nextBarSAR := SAR + AF * (EP - SAR)
// --- Heiken-Ashi z regularnych świec
haSym = ticker.heikinashi(syminfo.tickerid)
[haO, haH, haL, haC] = request.security(haSym, timeframe.period, [open, high, low, close])
haBull = haC >= haO
haBear = haC < haO
firstGreen = haBull and not haBull[1] // pierwsza zielona po czerwonych
firstRed = haBear and not haBear[1] // pierwsza czerwona po zielonych
// --- Wejścia/wyjścia
if barstate.isconfirmed
if firstGreen
// zamknij short, jeśli otwarty
if strategy.position_size < 0
strategy.cancel("Short")
// otwórz long
strategy.entry("Long", strategy.long)
if firstRed
// zamknij long, jeśli otwarty
if strategy.position_size > 0
strategy.cancel("Long")
// otwórz short
strategy.entry("Short", strategy.short)
// --- Rysowanie SAR
plot(SAR, "SAR", style=plot.style_cross, linewidth=3, color=color.orange)
plot(nextBarSAR, "Next bar SAR", style=plot.style_cross, linewidth=3, color=color.aqua)
Overview
SHODAN9 Katana enters long positions on the first green Heikin-Ashi candle after a series of red candles and enters short positions on the first red candle following green ones, closing opposing trades upon reversal. The script calculates and plots custom Parabolic SAR levels directly on the price chart. Users can adjust the SAR start, increment, and maximum values. The strategy does not include defined stop loss or take profit rules.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
SAR start
float
0.02
start
SAR increment
float
0.24
increment
SAR max
float
0.24
maximum
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.
This strategy trades price action pin bar patterns aligned with moving average trend alignment on the main price chart. It defines uptrends or downtrends using a fan arrangement of three moving averages (6 EMA, 18 EMA, and 50 SMA). Entry conditions require a b
Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish
ESU2023-10M - V1 is an intraday trend-reversal strategy designed for index futures contracts on the price chart. It calculates a 3-period moving average of candle highs and lows alongside specific three-bar price action patterns to detect short-term swing high
This strategy trades the three-candle strike pattern filtered by trend direction and time sessions. It calculates market regime using linear regression and exponential or smoothed moving averages to distinguish between ranging and trending conditions. Risk man
This strategy tracks consecutive bullish and bearish candlestick closes relative to the preceding bar. It enters a long position when price closes higher for a specified number of consecutive bars, and enters a short position when price closes lower for a desi
This strategy executes trades based on candlestick engulfing patterns aligned with a 200-period exponential moving average trend filter. It enters long positions when a bullish engulfing candle follows three consecutive bearish candles while price trades above