Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Best TradingView Strategy - For NASDAQ and DOW30 and other Index

A Pine Script v5 strategy built on SMA (source1, 9), Stdev (source1, 9) and RMA or Change (14). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade is one contract and pays no commission. 9 settings; defaults include Length1 9, Mult1 2.0 and RSI Length 14.

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 Best TradingView Strategy - For NASDAQ and DOW30 and other Index repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 4 of 4 trades.
How did Best TradingView Strategy - For NASDAQ and DOW30 and other Index do on BTCUSDT 1D with default settings?
+2.25%
From 26 Jan 2024 to 21 Oct 2026, over 17 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Best TradingView Strategy - For NASDAQ and DOW30 and other Index 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: 17 before, 17 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 Best TradingView Strategy - For NASDAQ and DOW30 and other Index use a stop loss?
Yes
strategy.exit sets a stop on line 76, 77.
Does Best TradingView Strategy - For NASDAQ and DOW30 and other Index run in Zeal Terminal?
Yes
It compiles in 30 ms and runs 1,000 bars in 67 ms, in the browser.

BTCUSDT · 1D · default settings

  • RSI Upper Band
  • RSI Middle Band
  • RSI Lower Band
  • Plot
  • Plot
  • 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 (9)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$1,024,550$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
+2.25%
$22,480.70
Buy and hold
+102.5%
same period
Closed trades
17
10 won · 7 lost
Profitable
58.8%
of closed trades
Profit factor
1.41
gross profit ÷ gross loss
Max drawdown
3.40%
−$33,986.30

One run with the author's default settings, $1,000,000 starting capital, commission as the script sets it. A long position was still open at the last bar. 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.

  • Likely bug

    ta.sma(close, 14) ignores the settings line 60

    Line 60 hard-codes 14 where line 9 uses “Length1”. Changing those settings moves one band but not this one.

    ta.sma(close,14)ta.sma(close, length1)
  • Likely bug

    ta.sma(close, 42) ignores the settings line 61

    Line 61 hard-codes 42 where line 9 uses “Length1”. Changing those settings moves one band but not this one.

    ta.sma(close,42)ta.sma(close, length1)
  • Likely bug

    ta.change(high) ignores the settings line 47

    Line 47 hard-codes high where line 29 uses “Source”. Changing those settings moves one band but not this one.

    ta.change(high)ta.change(rsiSourceInput)
  • Likely bug

    ta.change(low) ignores the settings line 48

    Line 48 hard-codes low where line 29 uses “Source”. Changing those settings moves one band but not this one.

    ta.change(low)ta.change(rsiSourceInput)
  • Check

    No commission

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

  • Note

    2 settings have no label

    In the settings dialog length1 (line 7), mult1 (line 8) 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.

  • Note

    Uses an argument v6 removed

    when = on line 76, 77. The upgraded version below moves each call inside an if block.

Settings

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

SettingDefaultType and rangeFeeds
Length1 (no label in the script)9int · min 1basis1 dev1
Mult1 (no label in the script)2.0float · min 0.001 · max 50dev1
ADX Smoothing14intadx sig
DI Length14intplus minus sig
RSI Settings
RSI Length14int · min 1up down
Sourceclosesourceup down
MA Settings
MA TypeSMAstring · options ["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"]rsiMA isBB
MA Length14intrsiMA Upper Bollinger Band Lower Bollinger Band
BB StdDev2.0float · min 0.001 · max 50Upper Bollinger Band Lower Bollinger Band

What it calculates

  • SMAsource1, Length1 (9)basis1 · line 9
  • Stdevsource1, Length1 (9)dev1 · line 10
  • RMA / Changemath.max(ta.change(rsiSourceInput), 0), RSI Length (14)up · line 29
  • RMA / Change-math.min(ta.change(rsiSourceInput), 0), RSI Length (14)down · line 30
  • Changehighup1 · line 47
  • Changelowdown1 · line 48
  • RMAta.tr, lentruerange · line 51
  • RMAmath.abs(plus - minus) / (sum == 0 ? 1 : sum), ADX Smoothing (14)adx · line 58
  • SMAclose, 14out · line 60
  • SMAclose, 42sma1 · line 61
  • EMAclose, 200ema200 · line 62

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.

length1Length1setting · 9mult1Mult1setting · 2.0closecloseprice datarsiLengthInputRSI Lengthsetting · 14highhighprice datalowlowprice datahigh · low · closehigh · low · closeprice dataadxlenADX Smoothingsetting · 14maLengthInputMA Lengthsetting · 14maTypeInputMA Typesetting · SMAdilenDI Lengthsetting · 14bbMultInputBB StdDevsetting · 2.0basis1SMA→ basis1dev1Stdev→ dev1upRMA / Change→ updownRMA / Change→ downup1Change→ up1down1Change→ down1truerangeRMA→ truerangeadxRMA→ adxoutSMA→ outsma1SMA→ sma1ema200EMA→ ema200source1source1valueupper1, lower1upper1 · lower12 valuesrsirsivaluersiMArsiMAvalueplusDM, minusDMplusDM · minusDM2 valuesplus, minusplus · minus2 valuessumsumvaluesigsigvaluestopl, tptgt, stopshort, tptgtshortstopl · tptgt +24 valueslongConditionlongConditionconditionshortConditionshortConditionconditionisBBisBBconditionentry:longOpen longstrategy.entryentry:shortOpen shortstrategy.entryexit:longcloseexit longclosestrategy.exitexit:shortcloseexit shortclosestrategy.exithline:36hlinehlinehline:37hlinehlinehline:38hlinehlinefill:RSI Background FillRSI Background Fillfillplot:40Upper Bollinger Bandplotplot:41Lower Bollinger Bandplotfill:Bollinger Bands Background FillBollinger Bands Backgro…fillplot:82plotplotplot:83plotplot

Order rules

OrderFires whenBy defaultLine
Open long long(longCondition )On65
Open short short(shortCondition )On69
Exit longclose stopta.crossover(sma1,out)On76
Exit shortclose stopta.crossover(out,sma1)On77

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.

4/4trades 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+2.2%+102.5%1759%1.413.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.9%+5.5%1850%0.712.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.2%+9.8%1669%1.770.2%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%1580%1.310.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%1567%2.470.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.0%+21.5%1833%0.360.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.0%+148.3%1681%0.990.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.0%+17.1%1765%0.620.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 market540%−$17,868.60
Sideways market875%$33,556.40
Falling market450%$6,792.84

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

How bad could the drawdown be?

4.2%

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

0%5%
All 17 trades
SideEntryExitBarsP&L
long21 Mar 2024 67,840.501 May 2024 60,672.0041−$7,168.50
short1 May 2024 60,672.0013 Jun 2024 68,264.0043−$7,591.97
long13 Jun 2024 68,264.0025 Jun 2024 60,293.3012−$7,970.68
short25 Jun 2024 60,293.303 Aug 2024 59,850.5039$442.80
long4 Aug 2024 60,698.0010 Aug 2024 60,837.506$139.50
short6 Sep 2024 56,180.003 Oct 2024 60,649.3027−$4,469.27
long3 Oct 2024 60,649.3031 Dec 2024 92,791.6089$32,142.30
long4 Feb 2025 101,329.0025 Feb 2025 91,552.9021−$9,775.63
short25 Feb 2025 91,552.907 Jun 2025 104,288.00102−$12,735.50
long7 Jun 2025 104,288.0023 Jun 2025 106,074.0016$1,785.27
long3 Aug 2025 112,546.0022 Aug 2025 117,429.0019$4,882.20
long24 Sep 2025 111,999.0021 Oct 2025 114,000.0027$2,000.70
short5 Nov 2025 101,497.008 Jan 2026 91,364.7064$10,132.60
long22 Jan 2026 89,454.7030 Jan 2026 84,650.208−$4,804.57
short30 Jan 2026 84,650.2015 Mar 2026 70,859.3044$13,790.80
long29 Mar 2026 66,377.002 Apr 2026 68,652.904$2,275.84
short28 May 2026 74,449.3015 Jul 2026 65,044.5048$9,404.82

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
Best TradingView Strategy - For NASDAQ and DOW30 and other Index this page—v5 strategy+2.2%173.4%
Contrarian Scalping Counter Trend Bb Envelope Adx and Stochastic by exlux99sma stdev ema rmav5 strategy+1.9%153.2%
Strategy Myth-Busting #3 - BB_BUY+SuperTrend - [MYN] by myncryptoema sma stdev rmav5 strategy−115.1%6123.3%
Volume Weighted Bollinger Bands Strategy by Ankit_1618ema sma stdevv4 strategy+10.0%1527.5%
BB21_MA200_Strategy by mohaneeema sma stdevv4 strategyNo trades on this market
Optimized Keltner Channels SL-TP Strategy for BTC by chanu_lev10ksma ema rmav4 strategy−19.4%3670.0%

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.

  • 2 strategy calls use the when = argument (line 76, 77). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 2 settings use the untyped input() (line 44, 45). 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 17 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 44: input() → input.int()
  • Line 45: input() → input.int()
  • Line 76: when = ta.crossover(sma1,out) → if block
  • Line 77: when = ta.crossover(out,sma1) → if block
⋯//ADX-adxlen = input(14, title="ADX Smoothing")+adxlen = input.int(14, title="ADX Smoothing")-dilen = input(14, title="DI Length")+dilen = input.int(14, title="DI Length")dirmov(len) =>⋯tptgtshort=strategy.position_avg_price-100-strategy.exit("longclose","long",trail_offset=50,trail_points=200,when=ta.crossover(sma1,out))+if ta.crossover(sma1,out)+    strategy.exit("longclose","long",trail_offset=50,trail_points=200)-strategy.exit("shortclose","short",trail_offset=50,trail_points=200,when=ta.crossover(out,sma1))+if ta.crossover(out,sma1)+    strategy.exit("shortclose","short",trail_offset=50,trail_points=200)    ⋯

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

⋯// © The_Bigger_Bull-//@version=5+//@version=6strategy("Best TradingView Strategy", overlay=true, margin_long=0, margin_short=0)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 30 msYes 1,000 bars in 67 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/// © The_Bigger_Bull//@version=5strategy("Best TradingView Strategy", overlay=true, margin_long=0, margin_short=0)//Bollinger Bandssource1 = closelength1 = input.int(9, minval=1)mult1 = input.float(2.0, minval=0.001, maxval=50)basis1 = ta.sma(source1, length1)dev1 = mult1 * ta.stdev(source1, length1)upper1 = basis1 + dev1lower1 = basis1 - dev1//buyEntry = ta.crossover(source1, lower1)//sellEntry = ta.crossunder(source1, upper1)//RSIma(source, length, type) =>    switch type        "SMA" => ta.sma(source, length)        "Bollinger Bands" => ta.sma(source, length)        "EMA" => ta.ema(source, length)        "SMMA (RMA)" => ta.rma(source, length)        "WMA" => ta.wma(source, length)        "VWMA" => ta.vwma(source, length)rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")rsiSourceInput = input.source(close, "Source", group="RSI Settings")maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings")maLengthInput = input.int(14, title="MA Length", group="MA Settings")bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="MA Settings")up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))rsiMA = ma(rsi, maLengthInput, maTypeInput)isBB = maTypeInput == "Bollinger Bands"//plot(rsi, "RSI", color=#7E57C2)//plot(rsiMA, "RSI-based MA", color=color.yellow)rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86)hline(50, "RSI Middle Band", color=color.new(#787B86, 50))rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86)fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill")bbUpperBand = plot(isBB ? rsiMA + ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Upper Bollinger Band", color=color.green)bbLowerBand = plot(isBB ? rsiMA - ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Lower Bollinger Band", color=color.green)fill(bbUpperBand, bbLowerBand, color= isBB ? color.new(color.green, 90) : na, title="Bollinger Bands Background Fill")//ADXadxlen = input(14, title="ADX Smoothing")dilen = input(14, title="DI Length")dirmov(len) =>    up1 = ta.change(high)    down1 = -ta.change(low)    plusDM = na(up1) ? na : (up1 > down1 and up1 > 0 ? up1 : 0)    minusDM = na(down1) ? na : (down1 > up1 and down1 > 0 ? down1 : 0)    truerange = ta.rma(ta.tr, len)    plus = fixnan(100 * ta.rma(plusDM, len) / truerange)    minus = fixnan(100 * ta.rma(minusDM, len) / truerange)    [plus, minus]adx(dilen, adxlen) =>    [plus, minus] = dirmov(dilen)    sum = plus + minus    adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)sig = adx(dilen, adxlen)out = ta.sma(close,14)sma1=ta.sma(close,42)ema200=ta.ema(close,200)longCondition = (out>sma1) and ta.crossover(source1, lower1) if (longCondition )    strategy.entry("long", strategy.long)    shortCondition = (out<sma1) and ta.crossunder(source1, lower1) if (shortCondition )    strategy.entry("short", strategy.short)        stopl=strategy.position_avg_price-50tptgt=strategy.position_avg_price+100stopshort=strategy.position_avg_price+50tptgtshort=strategy.position_avg_price-100strategy.exit("longclose","long",trail_offset=50,trail_points=200,when=ta.crossover(sma1,out))strategy.exit("shortclose","short",trail_offset=50,trail_points=200,when=ta.crossover(out,sma1))    //if strategy.position_avg_price<0        plot(sma1 , color=color.blue)plot(out, color=color.green)//plot(ema200,color=color.red)