Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Bull Trend Filtered StochRSI (BTFS)

A Pine Script v5 strategy built on Highest or EMA (high,filter_ema_len, 30), RSI (close, 14) and SMA or Stoch (7). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays no commission. 8 settings; defaults include Filter ema len 6, EMA donchian len 30 and K 7.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does Bull Trend Filtered StochRSI (BTFS) repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 6 of 6 trades.
How did Bull Trend Filtered StochRSI (BTFS) do on BTCUSDT 1D with default settings?
+36.89%
From 26 Jan 2024 to 21 Oct 2026, over 21 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Bull Trend Filtered StochRSI (BTFS) run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 21 before, 20 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does Bull Trend Filtered StochRSI (BTFS) use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Bull Trend Filtered StochRSI (BTFS) run in Zeal Terminal?
Yes
It compiles in 16 ms and runs 1,000 bars in 39 ms, in the browser.

BTCUSDT · 1D · default settings

  • K
  • D
  • Upper Band
  • Middle Band
  • Lower Band
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (8)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctK$1,368,860$2,025,273Equity from $1,000,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots.
Net profit
+36.89%
$368,864.00
Buy and hold
+102.5%
same period
Closed trades
21
9 won · 12 lost
Profitable
42.9%
of closed trades
Profit factor
1.59
gross profit ÷ gross loss
Max drawdown
21.54%
−$281,976.00

One run with the author's default settings, $1,000,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    3 settings have no label

    In the settings dialog filter_ema_len (line 6), ema_donchian_len (line 7), lowerband (line 22) show an empty name. The labels on this page come from the variable names.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Filter ema len (no label in the script)6intema
EMA donchian len (no label in the script)30intema
K7int · min 1k
D4int · min 1d
RSI Length14int · min 1rsi1
Stochastic Length14int · min 1k
RSI Sourceclosesourcersi1
Lowerband (no label in the script)35inth11 longCondition shortCondition hline

What it calculates

  • Highest / EMAta.ema(high,filter_ema_len), EMA donchian len (30)ema · line 8
  • RSIRSI Source (close), RSI Length (14)rsi1 · line 15
  • SMA / Stochta.stoch(rsi1, rsi1, rsi1, lengthStoch), K (7)k · line 16
  • SMAk, D (4)d · line 17
  • Crossunderk, Lowerband (35)shortCondition · line 30

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

highhighprice datafilter_ema_lenFilter ema lensetting · 6ema_donchian_lenEMA donchian lensetting · 30closecloseprice datalengthRSIRSI Lengthsetting · 14lengthStochStochastic Lengthsetting · 14smoothKKsetting · 7smoothDDsetting · 4lowerbandLowerbandsetting · 35emaHighest / EMA→ emarsi1RSI→ rsi1kSMA / Stoch→ kdSMA→ dshortConditionCrossunder→ shortConditionematrendematrendvaluelongConditionlongConditionconditionentry:UpOpen Upstrategy.entryclose:UpClose Upstrategy.closeplot:18Kplotplot:19Dplothline:20hlinehlinehline:21hlinehlinehline:23hlinehlinefill:BackgroundBackgroundfillbgcolor:26bgcolorbgcolor

Order rules

OrderFires whenBy defaultLine
Open Up long(longCondition)On29
Close Up(shortCondition)On32

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

6/6trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+36.9%+102.5%2143%1.5921.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+11.0%+5.5%1631%1.658.8%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+75.5%+9.8%1759%1.8629.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+24.6%+8.4%1429%2.039.2%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+55.9%+16.7%1747%1.6528.6%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+28.5%+21.5%1338%2.417.7%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−19.0%+148.3%2438%0.7745.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+9.0%+17.1%1839%1.5410.3%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

Settings heatmap

Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (Filter ema len 7, EMA donchian len 30) made +22.1% before 26 Dec 2025 and +17.2% after it, against +16.9% for the defaults. 59% of the 56 combinations made money in-sample and 100% out-of-sample.

Before 26 Dec 2025 · in-sample
EMA donchian len ↓ · Filter ema len →34567810
15−11%−8%−11%−9%−9%−15%−14%
18−9%+3%−3%+0%+0%−4%+6%
21−3%−1%−6%−4%−4%+0%+1%
26+8%+7%+1%+12%+13%+0%+2%
30+15%+11%−0%+20%+22%+8%+11%
36+7%+4%+0%+9%+10%−1%+1%
42+14%−7%−10%+0%+1%−10%−2%
51+16%+5%+1%+3%+3%−9%−3%
From 26 Dec 2025 · out-of-sample
EMA donchian len ↓ · Filter ema len →34567810
15+20%+23%+23%+23%+22%+21%+21%
18+21%+22%+21%+23%+23%+21%+21%
21+17%+20%+19%+19%+19%+17%+20%
26+13%+15%+14%+16%+16%+14%+18%
30+7%+11%+14%+17%+17%+15%+16%
36+11%+5%+9%+10%+10%+9%+16%
42+16%+11%+14%+16%+16%+14%+15%
51+16%+15%+18%+19%+19%+17%+18%

Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market1050%$218,021.00
Sideways market933%$161,890.00
Falling market250%−$11,047.50

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

31.3%

The 95th percentile of the worst drawdown when the same 21 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 14.0% to 31.3%; the tick is what actually happened, 18.6%. Order luck alone moves it this much.

0%36%
All 21 trades
SideEntryExitBarsP&L
long29 Feb 2024 62,432.1011 Mar 2024 68,955.9011$104,494.00
long14 Mar 2024 73,072.4016 Mar 2024 69,499.802−$53,999.50
long18 May 2024 67,024.001 Jun 2024 67,540.0014$8,087.63
long6 Jun 2024 71,108.0013 Jun 2024 68,264.007−$42,338.80
long21 Jul 2024 67,140.003 Aug 2024 61,498.3013−$85,392.80
long25 Sep 2024 64,262.705 Oct 2024 62,086.0010−$31,529.70
long15 Oct 2024 66,084.005 Nov 2024 67,850.0021$24,033.20
long9 Nov 2024 76,509.8029 Nov 2024 95,644.0020$230,920.00
long14 Dec 2024 101,424.0023 Dec 2024 95,186.309−$70,992.10
long19 Jan 2025 104,556.001 Feb 2025 102,430.0013−$22,033.90
long22 Apr 2025 87,516.2029 May 2025 107,782.0037$245,746.00
long11 Jun 2025 110,274.0020 Jun 2025 104,659.009−$66,559.60
long4 Jul 2025 109,585.0025 Jul 2025 118,341.0021$99,115.10
long13 Aug 2025 120,134.0020 Aug 2025 112,873.007−$80,965.00
long2 Oct 2025 118,595.0015 Oct 2025 113,028.0013−$59,078.10
long6 Jan 2026 93,859.7022 Jan 2026 89,454.7016−$56,294.70
long16 Mar 2026 72,815.3025 Mar 2026 70,556.709−$35,459.00
long14 Apr 2026 74,418.0018 May 2026 77,457.7034$45,247.20
long21 Jul 2026 65,255.5030 Jul 2026 63,984.309−$22,461.20
long20 Aug 2026 69,334.805 Sep 2026 79,660.8016$168,371.00
long21 Sep 2026 81,178.007 Oct 2026 85,549.9016$69,954.20

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
Bull Trend Filtered StochRSI (BTFS) this page—v5 strategy+36.9%2121.5%
Bear & Bull Zone Signal Strategy by Solutions1978rsi ema highest stoch smav4 strategyNo trades on this market
sma RSI & sudden buy and sell Strategy v1 by samwillingtonema rsi highest smav5 strategy+7.6%153.7%
RSI Mean Reversion Bot Strategy by Solutions1978rsi ema stoch smav4 strategyNo trades on this market
All in One Strategy no RSI Label - For higher dollar crypto by Solutions1978rsi ema highest stoch smav4 strategyNo trades on this market
All in One Strategy by Solutions1978rsi ema highest stoch smav4 strategyNo trades on this market

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 4 settings use the untyped input() (line 6, 7, 14, 22). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

Same 21 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 14: input() → input.source()
  • Line 22: input() → input.int()
⋯/////high filter...upper donchian channel of ema... or highest ema for a given amount of candles-filter_ema_len= input(6)+filter_ema_len= input.int(6)-ema_donchian_len = input(30)+ema_donchian_len = input.int(30)ema=ta.highest(ta.ema(high,filter_ema_len),ema_donchian_len)⋯lengthStoch = input.int(14, "Stochastic Length", minval=1)-src = input(close, title="RSI Source")+src = input.source(close, title="RSI Source")rsi1 = ta.rsi(src, lengthRSI)⋯hline(50, "Middle Band", color=color.new(#787B86, 50))-lowerband=input(35)+lowerband=input.int(35)h11 = hline(lowerband, "Lower Band", color=#787B86)⋯

Does it run in Pine Script v6?

No

The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 21 before, 20 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © SnarkyPuppy-//@version=5+//@version=6strategy("Filtered Stoch", overlay=false, default_qty_value = 100, default_qty_type=strategy.percent_of_equity)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 16 msYes 1,000 bars in 39 msNot measured
PineTSNot testedNot testedNot measured

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © SnarkyPuppy//@version=5strategy("Filtered Stoch", overlay=false, default_qty_value = 100, default_qty_type=strategy.percent_of_equity)/////high filter...upper donchian channel of ema... or highest ema for a given amount of candlesfilter_ema_len= input(6)ema_donchian_len = input(30)ema=ta.highest(ta.ema(high,filter_ema_len),ema_donchian_len)////////////////////////basic stoch rsi with max val 100 and min val 0.. entry above lowerband preset 35smoothK = input.int(7, "K", minval=1)smoothD = input.int(4, "D", minval=1)lengthRSI = input.int(14, "RSI Length", minval=1)lengthStoch = input.int(14, "Stochastic Length", minval=1)src = input(close, title="RSI Source")rsi1 = ta.rsi(src, lengthRSI)k = math.min(100, math.max(0,ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)))d = math.max(math.min(ta.sma(k, smoothD),80),35)plot(k, "K", color=#2962FF)plot(d, "D", color=#FF6D00)h0 = hline(80, "Upper Band", color=#787B86)hline(50, "Middle Band", color=color.new(#787B86, 50))lowerband=input(35)h11 = hline(lowerband, "Lower Band", color=#787B86)fill(h0, h11, color=color.rgb(33, 150, 243, 90), title="Background")ematrend= close>ema ? 1 : 0bgcolor(ematrend==1?color.rgb(76, 175, 79, 80):na)longCondition = k>lowerband and ematrend==1if (longCondition)    strategy.entry("Up", strategy.long)shortCondition =  ta.crossunder(k,lowerband)if (shortCondition)    strategy.close("Up", shortCondition)