Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Swing Trades Validator - The One Trader

A Pine Script v5 strategy built on EMA (close, 8). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 3 settings; defaults include Profit Target % 10 and Stop Loss % 10.

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 Swing Trades Validator - The One Trader repaint?
Yes
At least one pattern in the source can repaint: higher-timeframe data.
How did Swing Trades Validator - The One Trader do on BTCUSDT 1D with default settings?
+0.68%
From 26 Jan 2024 to 21 Oct 2026, over 5 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Swing Trades Validator - The One Trader 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: 5 before, 4 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 Swing Trades Validator - The One Trader use a stop loss?
Yes
strategy.exit sets a stop on line 75.
Does Swing Trades Validator - The One Trader run in Zeal Terminal?
Yes
It compiles in 19 ms and runs 1,000 bars in 191 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • EMA
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,006,760$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. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. 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. The live re-run is not offered here: the script requests BINANCE:BTCUSDT M, BINANCE:BTCUSDT W, which this page cannot load in your browser.
Net profit
+0.68%
$6,755.03
Buy and hold
+102.5%
same period
Closed trades
5
3 won · 2 lost
Profitable
60.0%
of closed trades
Profit factor
1.30
gross profit ÷ gross loss
Max drawdown
1.17%
−$11,941.60

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
Profit Target %10float · min 1 · step 0.05ProfitTarget
Stop Loss %10float · min 1 · step 0.05StopLoss
Enhanced Entry Rulestrueboolpullback

What it calculates

  • EMAclose, 8emaH · line 11
  • EMAclose[1], 8emaHyest · line 12
  • EMAclose[2], 8emaHyest1 · line 13
  • EMAclose[3], 8emaHyest2 · line 14
  • EMAclose, 21emaL · line 15
  • EMAclose[1], 21emaLyest · line 16
  • EMAclose[2], 21emaLyest1 · line 17
  • EMAclose[3], 21emaLyest2 · line 18
  • EMAclose, 50emaf · line 19
  • EMAclose, 200emath · line 20
  • EMAhigh, 200emathhigh · line 21
  • EMAlow, 200emathlow · line 22

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.

closecloseprice datahighhighprice datalowlowprice dataopenopenprice dataTakeProfitPercentProfit Target %setting · 10StopLossPercentStop Loss %setting · 10emaHEMA→ emaHemaHyestEMA→ emaHyestemaHyest1EMA→ emaHyest1emaHyest2EMA→ emaHyest2emaLEMA→ emaLemaLyestEMA→ emaLyestemaLyest1EMA→ emaLyest1emaLyest2EMA→ emaLyest2emafEMA→ emafemathEMA→ emathemathhighEMA→ emathhighemathlowEMA→ emathlowemaslowmonthly, emaslowweekly, emaslowdailyemaslowmonthly · emaslo…3 valuesemafastmonthly, emafastweekly, emafastdailyemafastmonthly · emafas…3 valuesemafdailyemafdailyvalueemathdailyemathdailyvalueemathdailyhighemathdailyhighvalueemathdailylowemathdailylowvalueema21yestema21yestvalueema21yest1ema21yest1valueema21yest2ema21yest2valueema8yestema8yestvalueema8yest1ema8yest1valueema8yest2ema8yest2valuemonthopen, weekopen, dayopenmonthopen · weekopen +13 valuesmonthclose, weekclose, dayclosemonthclose · weekclose …3 valuesthreedayhigh, twodayhigh, yesthighthreedayhigh · twodayhi…3 valuesyestlowyestlowvaluepullbackpullbackvalueProfitTargetProfitTargetvalueStopLossStopLossvaluelongConditionlongConditionconditionmonthlybullish, weeklybullish, dailybullish2monthlybullish · weekly…3 conditionsmonthlybullishprice, weeklybullishprice, dailybullishpricemonthlybullishprice · w…3 conditionsmonthlybullishcandle, weeklybullishcandle, dailybullishcandlemonthlybullishcandle · …3 conditionsrealbullishrealbullishconditiongoldencrossgoldencrossconditiondailybullish1dailybullish1conditionringlowringlowconditionaggropullbackaggropullbackconditionpullbackfailurepullbackfailureconditionemasetupemasetupconditionentry:LongOpen Longstrategy.entryexit:Exitexit Exitstrategy.exit

Order rules

OrderFires whenBy defaultLine
Open Long long(longCondition)On74
Exit Exit stop and limit(longCondition)On75

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

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • CheckHigher-timeframe data10 request.security call(s) use lookahead_on (line 40, 41, 42, 43, 44, 45, 46, 47, 48, 49). Without a [1] offset this reads future bars in history.
  • 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.7%+102.5%560%1.301.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.1%+9.8%2100%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%667%1.740.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%1060%1.360.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—0.0%8 May 2026 – 21 Oct 2026

Higher-timeframe data for request.security(): BINANCE:BTCUSDT M (Binance BTCUSDT 1M), BINANCE:BTCUSDT W (Binance BTCUSDT 1w), fetched from Binance's public market data for each market.

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

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market333%−$10,827.60
Sideways market2100%$17,582.60
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?

2.2%

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

0%3%
All 5 trades
SideEntryExitBarsP&L
long29 Oct 2024 69,962.208 Nov 2024 76,899.4010$6,937.21
long21 Jan 2025 102,260.003 Feb 2025 91,772.9013−$10,487.10
long7 May 2025 96,834.0021 May 2025 107,479.0014$10,645.40
long26 May 2025 109,004.0014 Jul 2025 120,605.0049$11,601.00
long28 Jul 2025 119,416.0029 Aug 2025 107,474.0032−$11,941.60

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
Swing Trades Validator - The One Trader this page—v5 strategy+0.7%51.2%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

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.

  • No v6-only features. v6 is not needed to run this script.

Clean v5

Verified

Nothing to change.

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: 5 before, 4 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_daily_trader-//@version=5+//@version=6// ---------------------        Start of Code        ---------------------⋯

Where it runs

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

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/// © the_daily_trader//@version=5// ---------------------        Start of Code        ---------------------strategy("Swing Trades Validator", overlay=true, margin_long=100, pyramiding = 0)// Indicator Display ChecksTakeProfitPercent       = input.float(title="Profit Target %", defval=10, minval=1, step=0.05)StopLossPercent         = input.float(title="Stop Loss %", defval=10, minval=1, step=0.05)pullbackchoice          = input.bool(true, "Enhanced Entry Rules")// EMAsemaH            = ta.ema(close, 8)emaHyest        = ta.ema(close[1], 8)emaHyest1       = ta.ema(close[2], 8)emaHyest2       = ta.ema(close[3], 8)emaL            = ta.ema(close, 21)emaLyest        = ta.ema(close[1], 21)emaLyest1       = ta.ema(close[2], 21)emaLyest2       = ta.ema(close[3], 21)emaf            = ta.ema(close, 50)emath           = ta.ema(close, 200)emathhigh       = ta.ema(high, 200)emathlow        = ta.ema(low, 200)emaslowmonthly  = request.security(syminfo.tickerid, "M", emaL) // Monthly 21emaemafastmonthly  = request.security(syminfo.tickerid, "M", emaH) // Monthly 8emaemaslowweekly   = request.security(syminfo.tickerid, "W", emaL) // Weekly 21emaemafastweekly   = request.security(syminfo.tickerid, "W", emaH) // Weekly 8emaemaslowdaily    = request.security(syminfo.tickerid, "D", emaL) // Daily 21emaemafastdaily    = request.security(syminfo.tickerid, "D", emaH) // Daily 8emaemafdaily       = request.security(syminfo.tickerid, "D", emaf) // Daily 50emaemathdaily      = request.security(syminfo.tickerid, "D", emath) // Daily emaemathdailyhigh  = request.security(syminfo.tickerid, "D", emathhigh) // Daily ema Highemathdailylow   = request.security(syminfo.tickerid, "D", emathlow) // Daily ema Lowema21yest       = request.security(syminfo.tickerid, "D", emaLyest) // Daily 21ema 1 day agoema21yest1      = request.security(syminfo.tickerid, "D", emaLyest1) // Daily 21ema 2 days agoema21yest2      = request.security(syminfo.tickerid, "D", emaLyest2) // Daily 21ema 3 days agoema8yest        = request.security(syminfo.tickerid, "D", emaHyest) // Daily 8ema 1 day agoema8yest1       = request.security(syminfo.tickerid, "D", emaHyest1) // Daily 8ema 2 days agoema8yest2       = request.security(syminfo.tickerid, "D", emaHyest2) // Daily 8ema 3 days ago// Pricesmonthopen       = request.security(syminfo.tickerid, 'M', open, barmerge.gaps_off, barmerge.lookahead_on)monthclose      = request.security(syminfo.tickerid, 'M', close, barmerge.gaps_off, barmerge.lookahead_on)weekopen        = request.security(syminfo.tickerid, 'W', open, barmerge.gaps_off, barmerge.lookahead_on)weekclose       = request.security(syminfo.tickerid, 'W', close, barmerge.gaps_off, barmerge.lookahead_on)dayopen         = request.security(syminfo.tickerid, 'D', open, barmerge.gaps_off, barmerge.lookahead_on)dayclose        = request.security(syminfo.tickerid, 'D', close, barmerge.gaps_off, barmerge.lookahead_on)threedayhigh    = request.security(syminfo.tickerid, 'D', high[3], barmerge.gaps_off, barmerge.lookahead_on)twodayhigh      = request.security(syminfo.tickerid, 'D', high[2], barmerge.gaps_off, barmerge.lookahead_on)yesthigh        = request.security(syminfo.tickerid, 'D', high[1], barmerge.gaps_off, barmerge.lookahead_on)yestlow         = request.security(syminfo.tickerid, 'D', low[1], barmerge.gaps_off, barmerge.lookahead_on)// Conditions monthlybullish          = emafastmonthly > emaslowmonthlymonthlybullishprice     = close > emafastmonthlymonthlybullishcandle    = monthclose > monthopenweeklybullish           = emafastweekly > emaslowweeklyweeklybullishprice      = close > emafastweeklyweeklybullishcandle     = weekclose > weekopenrealbullish             = dayclose > emathdailyhighgoldencross             = emafdaily > emathdailyhighdailybullish1           = emafdaily > emathdailydailybullish2           = emafastdaily > emaslowdailydailybullishprice       = close > emafastdailydailybullishcandle      = dayclose > dayopenringlow                 = yestlow <= ema8yestaggropullback           = twodayhigh < threedayhighpullback                = (pullbackchoice ? aggropullback : 0)pullbackfailure         = dayclose > yesthigh and yesthigh < twodayhigh or pullbackemasetup                = ema8yest > ema21yest and ema8yest1 > ema21yest1 and ema8yest2 > ema21yest2// Target Profit and Stop Loss Inputs// Input parameters can be found at the beginning of the codeProfitTarget        = (close * (TakeProfitPercent / 100)) / syminfo.mintickStopLoss            = (close * (StopLossPercent / 100)) / syminfo.minticklongCondition = monthlybullish and monthlybullishprice and monthlybullishcandle and weeklybullish and weeklybullishprice and weeklybullishcandle and dailybullish1 and dailybullish2 and dailybullishprice and dailybullishcandle and ringlow and pullbackfailure and emasetup and realbullish and goldencrossif (longCondition)    strategy.entry("Long", strategy.long)    strategy.exit ("Exit", "Long", profit = ProfitTarget, loss = StopLoss)// -----------xxxxxxxxxxx-------------    End of Code     -----------xxxxxxxxxxx---------------