Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Boftei's Strategy

A Pine Script v5 strategy built on Crossover (y, 0), Crossunder (y, 0.0065) and EMA (close, 21). It has 16 order rules, 4 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays no commission. 15 settings; defaults include strategy direction all, Backtest Start Year 2005 and Backtest Start Month 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 Boftei's Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 2 of 2 trades.
How did Boftei's Strategy do on BTCUSDT 1D with default settings?
−32.18%
From 26 Jan 2024 to 21 Oct 2026, over 30 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Boftei's Strategy run in Pine Script v6?
Yes
Same 30 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does Boftei's Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Boftei's Strategy run in Zeal Terminal?
Yes
It compiles in 52 ms and runs 1,000 bars in 87 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • Plot
  • buy
  • zero
  • sell
  • long retry
  • overbought
  • oversold
  • short retry
  • too low to short - an asset may die
  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (15)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctPlot$27$81Equity from $40
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
−32.18%
−$12.87
Buy and hold
+102.5%
same period
Closed trades
30
5 won · 25 lost
Profitable
16.7%
of closed trades
Profit factor
0.37
gross profit ÷ gross loss
Max drawdown
38.32%
−$15.65

One run with the author's default settings, $40 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.

Settings

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

SettingDefaultType and rangeFeeds
strategy directionallstring · options ["long", "short", "all"]strat_dir_value
Backtest Start Year2005inttestPeriodStart
Backtest Start Month7inttestPeriodStart
Backtest Start Day16inttestPeriodStart
Backtest Stop Year2030inttestPeriodStop
Backtest Stop Month12inttestPeriodStop
Backtest Stop Day30inttestPeriodStop
sell level0.0065floatcu sell
buy level0floatco buy
long retry - too low-0.493floatretry_long long retry
long close up2.2floatdeadline_long_up overbought
long close down-1.5floatdeadline_long_down oversold
short retry - too high0.8floatretry_short short retry
dead - close the short-5floatdeadline_short too low to short - an asset may die
Histogram Period60inty

What it calculates

  • Crossovery, buy level (0)co · line 44
  • Crossundery, sell level (0.0065)cu · line 45
  • Crossundery, long retry - too low (-0.493)retry_long · line 46
  • Crossovery, long close up (2.2)deadline_long_up · line 47
  • Crossundery, long close down (-1.5)deadline_long_down · line 48
  • Crossovery, short retry - too high (0.8)retry_short · line 49
  • Crossundery, dead - close the short (-5)deadline_short · line 50
  • EMAclose, 21ema_21 · line 60
  • EMAclose, 55ema_55 · line 61
  • EMAclose, 89ema_89 · line 62
  • EMAclose, 144ema_144 · line 63
  • EMAclose, 233ema_233 · line 64

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.

The script has 64 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Close OH BRO(co and testPeriod() and (g_v == 3 or y_v == 2))On82
Close OH DUDE(co and testPeriod() and (g_v == 3 or y_v == 2))On83
Open OH DAMN long(co and testPeriod() and (g_v == 3 or y_v == 2))On84
Close OH DAMN(retry_long and testPeriod() and (g_v == 3 or y_v == 2))On86
Open OH BRUH long(retry_long and testPeriod() and (g_v == 3 or y_v == 2))On87
Close OH DAMN(cu and testPeriod() and (r_v == -2 or y_v == 2))On90
Close OH BRUH(cu and testPeriod() and (r_v == -2 or y_v == 2))On91
Open OH BRO short(cu and testPeriod() and (r_v == -2 or y_v == 2))On92
Close OH BRO(retry_short and testPeriod() and (r_v == -2 or y_v == 2))On94
Open OH DUDE short(retry_short and testPeriod() and (r_v == -2 or y_v == 2))On95
Close OH DAMN(deadline_long_up and testPeriod() or r_v == -2 and testPeriod())On99
Close OH BRUH(deadline_long_up and testPeriod() or r_v == -2 and testPeriod())On100
Close OH DAMN(deadline_long_down and testPeriod())On102
Close OH BRUH(deadline_long_down and testPeriod())On103
Close OH BRO(deadline_short and testPeriod() or g_v == 3 and testPeriod())On105
Close OH DUDE(deadline_short and testPeriod() or g_v == 3 and testPeriod())On106

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.

2/2trades 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−32.2%+102.5%3017%0.3738.3%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+6.2%+5.5%1822%1.726.9%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+18.0%+9.8%2119%1.5019.4%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+2.8%+8.4%825%1.444.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−76.0%+16.7%4418%0.3077.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−7.1%+21.5%1118%0.2924.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+3.7%+148.3%349%1.0625.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−7.0%+17.1%1513%0.3810.5%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 market714%−$7.30
Sideways market1817%−$5.75
Falling market520%$0.18

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

How bad could the drawdown be?

42.7%

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

0%49%
All 30 trades
SideEntryExitBarsP&L
long5 May 2024 63,892.0017 May 2024 65,235.2012$0.84
short17 May 2024 65,235.2017 May 2024 67,451.200−$1.39
long19 May 2024 66,915.2020 May 2024 66,274.001−$0.38
short20 May 2024 66,274.0020 May 2024 71,515.600−$3.09
long21 May 2024 71,446.6025 May 2024 68,550.004−$1.46
short25 May 2024 68,550.0025 May 2024 69,610.000−$0.53
long2 Jun 2024 67,766.804 Jun 2024 68,809.902$0.52
short4 Jun 2024 68,809.904 Jun 2024 71,063.400−$1.13
short8 Jun 2024 69,355.608 Jun 2024 69,582.200−$0.11
long9 Jun 2024 69,310.5020 Jun 2024 64,974.4011−$2.08
short20 Jun 2024 64,974.4020 Jun 2024 66,482.900−$0.72
long30 Jun 2024 60,986.703 Jul 2024 62,135.503$0.57
short3 Jul 2024 62,135.503 Jul 2024 62,285.900−$0.08
long29 Jul 2024 68,249.9030 Jul 2024 66,784.701−$0.66
short30 Jul 2024 66,784.7030 Jul 2024 67,000.000−$0.10
long24 Aug 2024 64,037.2028 Aug 2024 59,415.004−$2.18
short28 Aug 2024 59,415.0028 Aug 2024 60,235.000−$0.39
long3 Sep 2024 59,132.105 Sep 2024 57,970.902−$0.54
short5 Sep 2024 57,970.905 Sep 2024 58,327.100−$0.17
long6 Sep 2024 56,180.0015 Sep 2024 59,993.009$1.83
long30 Sep 2024 65,602.001 Oct 2024 63,327.601−$1.00
short10 Oct 2024 60,636.0010 Oct 2024 61,321.700−$0.31
long4 Feb 2025 101,329.0023 Feb 2025 96,551.0019−$1.29
short23 Feb 2025 96,551.0023 Feb 2025 96,650.000−$0.03
long26 Apr 2025 94,638.701 Sep 2025 108,246.00128$3.76
long3 Sep 2025 111,240.008 Sep 2025 111,137.005−$0.03
short26 Oct 2025 111,646.0026 Oct 2025 115,467.000−$1.02
short31 Oct 2025 108,323.0031 Oct 2025 111,190.000−$0.76
short26 Jan 2026 86,670.4026 Jan 2026 88,860.000−$0.71
short11 Aug 2026 63,970.0011 Aug 2026 64,515.400−$0.23

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
Boftei's Strategy this page—v5 strategy−32.2%3038.3%
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.

  • 7 settings use the untyped input() (line 10, 11, 12, 15, 16, 17, 30). 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 30 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 10: input() → input.int()
  • Line 11: input() → input.int()
  • Line 12: input() → input.int()
  • Line 15: input() → input.int()
  • Line 16: input() → input.int()
  • Line 17: input() → input.int()
  • Line 30: input() → input.int()
⋯//DATA-testStartYear = input(2005, "Backtest Start Year")+testStartYear = input.int(2005, "Backtest Start Year")-testStartMonth = input(7, "Backtest Start Month")+testStartMonth = input.int(7, "Backtest Start Month")-testStartDay = input(16, "Backtest Start Day")+testStartDay = input.int(16, "Backtest Start Day")testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)//Stop date if you want to use a specific range of dates-testStopYear = input(2030, "Backtest Stop Year")+testStopYear = input.int(2030, "Backtest Stop Year")-testStopMonth = input(12, "Backtest Stop Month")+testStopMonth = input.int(12, "Backtest Stop Month")-testStopDay = input(30, "Backtest Stop Day")+testStopDay = input.int(30, "Backtest Stop Day")testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)⋯///< botvenko script-nn = input(60, "Histogram Period")+nn = input.int(60, "Histogram Period")float x = 0⋯

Does it run in Pine Script v6?

Yes

Same 30 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © boftei-//@version=5+//@version=6strategy("Boftei's Strategy", overlay=false, pyramiding=1, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, margin_long = 100, margin_short = 100, slippage=0, commission_type=strategy.commission.percent, commission_value = 0, initial_capital = 40, precision = 6)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 52 msYes 1,000 bars in 87 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/// © boftei//@version=5strategy("Boftei's Strategy", overlay=false, pyramiding=1, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, margin_long = 100, margin_short = 100, slippage=0, commission_type=strategy.commission.percent, commission_value = 0, initial_capital = 40, precision = 6)strat_dir_input = input.string("all", "strategy direction", options=["long", "short", "all"])strat_dir_value = strat_dir_input == "long" ? strategy.direction.long : strat_dir_input == "short" ? strategy.direction.short : strategy.direction.allstrategy.risk.allow_entry_in(strat_dir_value)////////////////////////////////////////////////////////////////////////DATAtestStartYear = input(2005, "Backtest Start Year")testStartMonth = input(7, "Backtest Start Month")testStartDay = input(16, "Backtest Start Day")testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)//Stop date if you want to use a specific range of datestestStopYear = input(2030, "Backtest Stop Year")testStopMonth = input(12, "Backtest Stop Month")testStopDay = input(30, "Backtest Stop Day")testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)testPeriod() =>    time >= testPeriodStart and time <= testPeriodStop ? true : false//////////////////////////////////////////////////////////////////////sell = input.float(0.0065, "sell level")buy = input.float(0, "buy level")long1 = input.float(-0.493, "long retry - too low")long2 = input.float(2.2, "long close up")long3 = input.float(-1.5, "long close down")short1 = input.float(0.8, "short retry - too high")short2 = input.float(-5, "dead - close the short")///< botvenko scriptnn = input(60, "Histogram Period")float x = 0float z = 0float k = 0y = math.log(close[0]) - math.log(close[nn])if y>0    x := yelse    k := y//---------------------------------------------        plot(y > 0 ? x: 0, color = color.green, linewidth = 4)plot(y <= 0 ? k: 0, color = color.maroon, linewidth = 4)plot(y, color = color.yellow, linewidth = 1)co = ta.crossover(y, buy)cu = ta.crossunder(y, sell)retry_long = ta.crossunder(y, long1)deadline_long_up = ta.crossover(y, long2)deadline_long_down = ta.crossunder(y, long3)retry_short = ta.crossover(y, short1)deadline_short = ta.crossunder(y, short2)hline(buy, title='buy', color=color.green, linestyle=hline.style_dotted, linewidth=2)hline(0, title='zero', color=color.white, linestyle=hline.style_dotted, linewidth=1)hline(sell, title='sell', color=color.red, linestyle=hline.style_dotted, linewidth=2)hline(long1, title='long retry', color=color.blue, linestyle=hline.style_dotted, linewidth=2)hline(long2, title='overbought', color=color.teal, linestyle=hline.style_dotted, linewidth=2)hline(long3, title='oversold', color=color.maroon, linestyle=hline.style_dotted, linewidth=2)hline(short1, title='short retry', color=color.purple, linestyle=hline.style_dotted, linewidth=2)hline(short2, title='too low to short - an asset may die', color=color.navy, linestyle=hline.style_dotted, linewidth=2)////////////////////////////////////////////////////////////EMAprotectionBLOCKema_21 = ta.ema(close, 21)ema_55 = ta.ema(close, 55)ema_89 = ta.ema(close, 89)ema_144 = ta.ema(close, 144)ema_233 = ta.ema(close, 233)//ema_377 = ta.ema(close, 377)long_st = ema_21>ema_55 and ema_55>ema_89 and ema_89>ema_144 and ema_144>ema_233// and ema_233>ema_377short_st = ema_21<ema_55 and ema_55<ema_89 and ema_89<ema_144 and ema_144<ema_233// and ema_233<ema_377 g_v = long_st == true?3:0r_v = short_st == true?-2:0y_v = long_st != true and short_st != true?2:0plot(math.log(ema_21), color = color.new(#ffaf5e, 50))plot(math.log(ema_55), color = color.new(#b9ff5e, 50))plot(math.log(ema_89), color = color.new(#5eff81, 50))plot(math.log(ema_144), color = color.new(#5effe4, 50))plot(math.log(ema_233), color = color.new(#5e9fff, 50))//plot(math.log(ema_377), color = color.new(#af5eff, 50))plot(long_st == true?3:0, color = color.new(color.green, 65), linewidth = 5)plot(short_st == true?-2:0, color = color.new(color.red, 65), linewidth = 5)plot(long_st != true and short_st != true?2:0, color = color.new(color.yellow, 65), linewidth = 5)////////////////////////////////////////////////////////////EMAprotectionBLOCKif (co and testPeriod() and (g_v == 3 or y_v == 2))    strategy.close("OH BRO", comment = "EXIT-SHORT")    strategy.close("OH DUDE", comment = "EXIT-SHORT")    strategy.entry("OH DAMN", strategy.long, comment="ENTER-LONG 'co'")if (retry_long and testPeriod() and (g_v == 3 or y_v == 2))    strategy.close("OH DAMN", comment = "EXIT-LONG")    strategy.entry("OH BRUH", strategy.long, comment="ENTER-LONG 'retry_long'")    if (cu and testPeriod() and (r_v == -2 or y_v == 2))    strategy.close("OH DAMN", comment = "EXIT-LONG")    strategy.close("OH BRUH", comment = "EXIT-LONG")    strategy.entry("OH BRO", strategy.short, comment="ENTER-SHORT 'cu'")if (retry_short and testPeriod() and (r_v == -2 or y_v == 2))    strategy.close("OH BRO", comment = "EXIT-SHORT")    strategy.entry("OH DUDE", strategy.short, comment="ENTER-SHORT 'retry_short'")        if (deadline_long_up and testPeriod() or r_v == -2 and testPeriod())    strategy.close("OH DAMN", comment = "EXIT-LONG 'deadline_long_up'")    strategy.close("OH BRUH", comment = "EXIT-LONG 'deadline_long_up'")if (deadline_long_down and testPeriod())    strategy.close("OH DAMN", comment = "EXIT-LONG 'deadline_long_down'")    strategy.close("OH BRUH", comment = "EXIT-LONG 'deadline_long_down'")if (deadline_short and testPeriod() or g_v == 3 and testPeriod())    strategy.close("OH BRO", comment = "EXIT-SHORT 'deadline_short'")    strategy.close("OH DUDE", comment = "EXIT-SHORT 'deadline_short'")    // (you can use strategy.close_all(comment = "close all entries") here)