Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

JS-TechTrading- Supertrend-Strategy_Basic version

A Pine Script v5 strategy built on Supertrend (3.0, 10), EMA (close, 200) and RSI (close, 14). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 1% of equity and pays no commission. 16 settings; defaults include Type Of Strategy Pullback, ATR Length 10 and Factor 3.0.

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 JS-TechTrading- Supertrend-Strategy_Basic version repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
How did JS-TechTrading- Supertrend-Strategy_Basic version do on BTCUSDT 1D with default settings?
+0.08%
From 26 Jan 2024 to 21 Oct 2026, over 2 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does JS-TechTrading- Supertrend-Strategy_Basic version 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: 2 before, 2 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 JS-TechTrading- Supertrend-Strategy_Basic version use a stop loss?
Yes
strategy.exit sets a stop on line 78, 80.
Does JS-TechTrading- Supertrend-Strategy_Basic version run in Zeal Terminal?
Yes
It compiles in 28 ms and runs 1,000 bars in 71 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Up Trend
  • Down Trend
  • Long Fixed SL
  • Long Take Profit
  • 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 (16)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,000,830$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. Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 65, 67) so the engine trades the way the script says. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
Net profit
+0.08%
$833.89
Buy and hold
+102.5%
same period
Closed trades
2
2 won · 0 lost
Profitable
100.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
−$8.44

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 commission

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

  • 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
Type Of StrategyPullbackstring · options ['Pullback','Simple']buy_cond sell_cond
Supertrend Settings
ATR Length10intsupertrend direction
Factor3.0float · step 0.01supertrend direction
Ema Settings
Ema Condition On/Offtrueboolma_buy ma_sell
Ema Length200int · min 1ma_out
Ema Sourceclosesourcema_out
Rsi Settings
Rsi Condition On/Offtrueboolrsi_buy rsi_sell
RSI SourceclosesourcersiValue
RSI Length14intrsiValue
RSI BUY Level50intrsi_buy
RSI SELL Level50intrsi_sell
Backtest Period
Start calculations fromtimestamp('2005-01-01')timetime_cond
End calculationstimestamp('2045-03-01')timetime_cond
Trade Direction
Trade DirectionBothstring · options ['Long', 'Short', 'Both']longOK shortOK
Sl/Tp Settings
Stop Loss %1.0float · step 0.10longStop shortStop
Take Profit %1.0float · step 0.10shortTake longTake

What it calculates

  • SupertrendFactor (3.0), ATR Length (10)supertrend · line 19
  • SupertrendFactor (3.0), ATR Length (10)direction · line 19
  • EMAEma Source (close), Ema Length (200)ma_out · line 37
  • RSIRSI Source (close), RSI Length (14)rsiValue · line 48

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.

high · low · closehigh · low · closeprice datafactorFactorsetting · 3.0atrPeriodATR Lengthsetting · 10closecloseprice datama_lenEma Lengthsetting · 200rsiLengthRSI Lengthsetting · 14rsiOverboughtRSI BUY Levelsetting · 50rsiOversoldRSI SELL Levelsetting · 50option_chType Of Strategysetting · PullbackstopPerStop Loss %setting · 1.0takePerTake Profit %setting · 1.0timetimeprice datastartStart calculations fromsetting · timestamp('2005-01-…endEnd calculationssetting · timestamp('2045-03-…tradeDirectionTrade Directionsetting · Bothhighhighprice datalowlowprice dataopenopenprice datasupertrendSupertrend→ supertrenddirectionSupertrend→ directionma_outEMA→ ma_outrsiValueRSI→ rsiValuelong, shortlong · short2 valueslongposlongposvalueshortposshortposvaluema_buy, ma_sellma_buy · ma_sell2 valuesrsi_buyrsi_buyvaluersi_sellrsi_sellvaluebuy_condbuy_condvaluesell_condsell_condvaluelongStop, shortStoplongStop · shortStop2 valuesshortTake, longTakeshortTake · longTake2 valuestime_condtime_condconditionlongOKlongOKconditionshortOKshortOKconditionfin_pullbuy, fin_pullsellfin_pullbuy · fin_pulls…2 conditionsentry:longOpen longstrategy.entryentry:shortOpen shortstrategy.entryexit:Close Longexit Close Longstrategy.exitexit:Close Shortexit Close Shortstrategy.exitplot:20plotplotplot:21Up Trendplotplot:22Down Trendplotfill:23Fillfill × 2fill:24Fillfill × 2plot:82Long Fixed SLplotplot:83Short Fixed SLplotplot:84Long Take Profitplotplot:85Short Take Profitplot

Order rules

OrderFires whenBy defaultLine
Open long longbuy_cond and longOK and time_cond and strategy.position_size==0On65
Open short shortsell_cond and shortOK and time_cond and strategy.position_size==0On67
Exit Close Long stop and limitstrategy.position_size > 0On78
Exit Close Short stop and limitstrategy.position_size < 0On80

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.

1/1trades 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+0.1%+102.5%2100%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.0%+5.5%667%1.390.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.1%+9.8%1100%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%1100%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%10%0.000.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%475%2.970.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.1%+148.3%30%0.000.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%367%2.770.0%8 May 2026 – 21 Oct 2026

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

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market0—$0.00
Sideways market2100%$833.89
Falling market0—$0.00

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

How bad could the drawdown be?

0.0%

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

0%1%
All 2 trades
SideEntryExitBarsP&L
long12 Oct 2024 62,540.0013 Oct 2024 63,206.201$106.53
long21 Aug 2026 73,027.0022 Aug 2026 78,338.001$727.36

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
JS-TechTrading- Supertrend-Strategy_Basic version this page—v5 strategy+0.1%20.0%
RSI Cross [xaurr] by livetrendrsi emav4 strategy+24.4%5335.3%
Supertrend + RSI Strategy [Alose] by alorsesupertrend rsiv5 strategy−6.1%148.6%
Bitpanda Coinrule Template by joshuajcoop01rsi emav5 strategy−2.8%44.6%
RSI with Slow and Fast MA Crossing Strategy (by Coinrule) by Coinrulersi emav5 strategy−2.8%44.6%
RSI of VWAP by mohaneersi emav4 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.

  • 5 settings use the untyped input() (line 17, 43, 44, 45, 46). 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 2 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 17: input() → input.int()
  • Line 43: input() → input.source()
  • Line 44: input() → input.int()
  • Line 45: input() → input.int()
  • Line 46: input() → input.int()
⋯//atr period input supertrend -atrPeriod = input(10, "ATR Length",group = group_text0)+atrPeriod = input.int(10, "ATR Length",group = group_text0)factor = input.float(3.0, "Factor", step = 0.01,group=group_text0)⋯en_rsi    = input.bool(true,"Rsi Condition On/Off",group = group_text00)-rsiSource = input(title='RSI Source', defval=close,group = group_text00)+rsiSource = input.source(title='RSI Source', defval=close,group = group_text00)-rsiLength = input(title='RSI Length', defval=14,group = group_text00)+rsiLength = input.int(title='RSI Length', defval=14,group = group_text00)-rsiOverbought = input(title='RSI BUY Level', defval=50,group = group_text00)+rsiOverbought = input.int(title='RSI BUY Level', defval=50,group = group_text00)-rsiOversold   = input(title='RSI SELL Level', defval=50,group = group_text00)+rsiOversold   = input.int(title='RSI SELL Level', defval=50,group = group_text00)// Get RSI value⋯

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: 2 before, 2 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.

⋯// © JS_TechTrading-//@version=5+//@version=6strategy("Supertrend", overlay=true,default_qty_type =strategy.percent_of_equity,default_qty_value = 1,process_orders_on_close = false)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 28 msWith a workaround 1,000 bars in 71 msNot measured
PineTSNot testedNot testedNot measured

Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 65, 67) so the engine trades the way the script says. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

“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/// © JS_TechTrading//@version=5strategy("Supertrend", overlay=true,default_qty_type =strategy.percent_of_equity,default_qty_value = 1,process_orders_on_close = false)// group string////var string group_text000="Choose Strategy"var string group_text0="Supertrend Settings"var string group_text0000="Ema Settings"var string group_text00="Rsi Settings"var string group_text1="Backtest Period"var string group_text2="Trade Direction"// var string group_text3="Quantity Settings"var string group_text4="Sl/Tp Settings"////////////////////option_ch=input.string('Pullback',title = "Type Of Strategy",options =['Pullback','Simple'])//atr period input supertrend atrPeriod = input(10, "ATR Length",group = group_text0)factor = input.float(3.0, "Factor", step = 0.01,group=group_text0)[supertrend, direction] = ta.supertrend(factor, atrPeriod)bodyMiddle = plot((open + close) / 2, display=display.none)upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_linebr)downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_linebr)fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)long=direction < 0 ? supertrend : nashort=direction < 0? na : supertrendlongpos=falseshortpos=falselongpos :=long?true :short?false:longpos[1]shortpos:=short?true:long?false:shortpos[1]fin_pullbuy= (ta.crossunder(low[1],long) and long and high>high[1])fin_pullsell=(ta.crossover(high[1],short) and short and low<low[1]) //Ema 1on_ma=input.bool(true,"Ema Condition On/Off",group=group_text0000)ma_len= input.int(200, minval=1, title="Ema Length",group = group_text0000)ma_src = input.source(close, title="Ema Source",group = group_text0000)ma_out = ta.ema(ma_src, ma_len)ma_buy=on_ma?close>ma_out?true:false:truema_sell=on_ma?close<ma_out?true:false:true// rsi indicator and condition// Get user inputen_rsi    = input.bool(true,"Rsi Condition On/Off",group = group_text00)rsiSource = input(title='RSI Source', defval=close,group = group_text00)rsiLength = input(title='RSI Length', defval=14,group = group_text00)rsiOverbought = input(title='RSI BUY Level', defval=50,group = group_text00)rsiOversold   = input(title='RSI SELL Level', defval=50,group = group_text00)// Get RSI valuersiValue = ta.rsi(rsiSource, rsiLength)rsi_buy=en_rsi?rsiValue>=rsiOverbought ?true:false:truersi_sell=en_rsi?rsiValue<=rsiOversold?true:false:true// final conditionbuy_cond=option_ch=='Simple'?long and not(longpos[1]) and rsi_buy and ma_buy:option_ch=='Pullback'?fin_pullbuy and rsi_buy and ma_buy:nasell_cond=option_ch=='Simple'?short and not(shortpos[1]) and rsi_sell and ma_sell:option_ch=='Pullback'?fin_pullsell and rsi_sell and ma_sell:na//backtest enginestart = input.time(timestamp('2005-01-01'), title='Start calculations from',group=group_text1)end=input.time(timestamp('2045-03-01'), title='End calculations',group=group_text1)time_cond = time >= start and time<=end// Make input option to configure trade directiontradeDirection = input.string(title='Trade Direction', options=['Long', 'Short', 'Both'], defval='Both',group = group_text2)// Translate input into trading conditionslongOK  = (tradeDirection == "Long") or (tradeDirection == "Both")shortOK = (tradeDirection == "Short") or (tradeDirection == "Both")// strategy startif buy_cond and longOK and time_cond and strategy.position_size==0    strategy.entry('long',direction = strategy.long)if sell_cond and shortOK and time_cond and strategy.position_size==0    strategy.entry('short',direction =strategy.short)// fixed percentage based stop loss and take profit // User Options to Change Inputs (%)stopPer = input.float(1.0,step=0.10, title='Stop Loss %',group =group_text4) / 100takePer = input.float(1.0,step =0.10, title='Take Profit %',group =group_text4) / 100// Determine where you've entered and in what directionlongStop  = strategy.position_avg_price * (1 - stopPer)shortStop = strategy.position_avg_price * (1 + stopPer)shortTake = strategy.position_avg_price * (1 - takePer)longTake  = strategy.position_avg_price * (1 + takePer)if strategy.position_size > 0    strategy.exit(id='Close Long',stop=longStop, limit=longTake)if strategy.position_size < 0    strategy.exit(id='Close Short',stop=shortStop, limit=shortTake)//PLOT FIXED SLTP LINEplot(strategy.position_size > 0 ? longStop : na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Long Fixed SL')plot(strategy.position_size < 0 ? shortStop :na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Short Fixed SL')plot(strategy.position_size > 0 ? longTake : na, style=plot.style_linebr, color=color.new(color.green, 0), linewidth=1, title='Long Take Profit')plot(strategy.position_size < 0 ? shortTake : na, style=plot.style_linebr, color=color.new(color.green, 0), linewidth=1, title='Short Take Profit')//