Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Take Profit On Trend (by BHD_Trade_Bot)

A Pine Script v4 strategy built on EMA (close, 50), RSI (close, 200) and Stdev (close, 50). 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 15 in cash and pays 0.1% commission. It has no settings.

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 Take Profit On Trend (by BHD_Trade_Bot) repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Take Profit On Trend (by BHD_Trade_Bot) do on BTCUSDT 1D with default settings?
+54.77%
From 26 Jan 2024 to 21 Oct 2026, over 9 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Take Profit On Trend (by BHD_Trade_Bot) be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does Take Profit On Trend (by BHD_Trade_Bot) use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Take Profit On Trend (by BHD_Trade_Bot) run in Zeal Terminal?
Yes
It compiles in 15 ms and runs 1,000 bars in 31 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • 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 (0)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$23$30Equity from $15
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
+54.77%
$8.22
Buy and hold
+102.5%
same period
Closed trades
9
7 won · 2 lost
Profitable
77.8%
of closed trades
Profit factor
2.62
gross profit ÷ gross loss
Max drawdown
13.08%
−$3.22

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

  • Check

    No stop loss

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

  • Note

    No slippage

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

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames ema → ta.ema, rsi → ta.rsi, stdev → ta.stdev, sma → ta.sma.

v4 → v5

VerifiedDownload the v5 script

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

  • Line 1: //@version=4 → //@version=5
  • Line 26: ema → ta.ema
  • Line 27: ema → ta.ema
  • Line 29: rsi → ta.rsi
  • Line 31: stdev → ta.stdev
  • Line 33: sma → ta.sma
-// @version=4+// @version=5// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯// EMA-ema50 = ema(close, 50)+ema50 = ta.ema(close, 50)-ema200 = ema(close, 200)+ema200 = ta.ema(close, 200)// RSI length 200-rsi200 = rsi(close, 200)+rsi200 = ta.rsi(close, 200)// Bollinger Bands length 50-bb50 = 2 * stdev(close, 50)+bb50 = 2 * ta.stdev(close, 50)// BHD Unit-bhd_unit = sma(bb50, 100)+bhd_unit = ta.sma(bb50, 100)bb50_upper = ema50 + bhd_unit⋯

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

-// @version=5+// @version=6// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯

Settings

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

The script declares no settings.

What it calculates

  • EMA (ema, ta.ema in v5)close, 50ema50 · line 26
  • EMA (ema, ta.ema in v5)close, 200ema200 · line 27
  • RSI (rsi, ta.rsi in v5)close, 200rsi200 · line 29
  • Stdev (stdev, ta.stdev in v5)close, 50bb50 · line 31
  • SMA (sma, ta.sma in v5)bb50, 100bhd_unit · line 33

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 datatimetimeprice dataema50EMA→ ema50ema200EMA→ ema200rsi200RSI→ rsi200bb50Stdev→ bb50bhd_unitSMA→ bhd_unitstart_time, end_timestart_time · end_time2 valuesbb50_upper, bb50_lowerbb50_upper · bb50_lower2 valuesh1_last_barh1_last_barconditionENTRY_CONDITIONENTRY_CONDITIONconditionCLOSE_CONDITIONCLOSE_CONDITIONconditionentry_condition1entry_condition1conditionTAKE_PROFIT, STOP_LOSSTAKE_PROFIT · STOP_LOSS2 conditionsentry:entryOpen entrystrategy.entryclose:entryClose entrystrategy.closeplot:61plotplotplot:62plotplotplot:63plotplotplot:64plotplot

Order rules

OrderFires whenBy defaultLine
Open entry long(ENTRY_CONDITION and is_back_test_time())On51
Close entry(CLOSE_CONDITION or h1_last_bar)On59

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.

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.
  • 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+54.8%+102.5%978%2.6213.1%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+5.9%+5.5%475%2.116.8%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−21.4%+9.8%560%0.7050.7%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+1.9%+8.4%475%1.1817.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+8.9%+16.7%771%1.1154.9%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+5.1%+21.5%667%1.2417.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+39.8%+148.3%1275%1.5230.9%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+6.6%+17.1%580%1.7511.7%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 market450%−$1.68
Sideways market5100%$9.91
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?

19.3%

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

0%22%
All 9 trades
SideEntryExitBarsP&L
long16 Aug 2024 57,541.1027 Sep 2024 65,174.0042$1.96
long1 Oct 2024 63,327.6030 Oct 2024 72,736.4029$2.20
long1 Nov 2024 70,292.0011 Nov 2024 80,370.0010$2.12
long18 Nov 2024 89,856.0022 Nov 2024 98,317.104$1.38
long27 Nov 2024 91,965.2016 Dec 2024 104,464.0019$2.01
long20 Dec 2024 97,461.907 Apr 2025 78,430.00108−$2.96
long28 Apr 2025 93,749.3011 May 2025 104,810.0013$1.74
long13 May 2025 102,791.0011 Jul 2025 116,010.0059$1.90
long20 Jul 2025 117,840.005 Nov 2025 101,497.00108−$2.11

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
Take Profit On Trend (by BHD_Trade_Bot) this page—v4 strategy+54.8%913.1%
5 Minute Scalping Strategy by Coachman0912sma ema stdev rsiv5 strategyNo trades on this market
Bollinger Band + RSI + ADX + MACD + Heikinashi by TradeUsingPivotssma stdev rsi emav4 strategyNo trades on this market
RSI Rising Crypto Trending Strategy by exlux99sma stdev ema rsiv4 strategyNo trades on this market
[KL] Bollinger bands + RSI Strategy by DojiEmojisma stdev ema rsiv4 strategy+28.2%3014.7%
[KL] Bollinger Bands Consolidation Strategy by DojiEmojisma stdev ema rsiv4 strategy+39.1%3319.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 15 msYes 1,000 bars in 31 msNot measured
PineTSNo v5 and v6 only—Not 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. PineTS runs Pine Script v5 and v6 only.

Source

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

// @version=4// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © BHD_Trade_Botstrategy(shorttitle='Take Profit On Trend', title='Take Profit On Trend (by BHD_Trade_Bot)', overlay=true, initial_capital = 15, default_qty_type = strategy.cash, default_qty_value = 15, commission_type=strategy.commission.percent, commission_value=0.1)//Backtest Timestart_day = 1start_month = 1start_year = 2021end_day = 1end_month = 1end_year = 2050start_time = timestamp(start_year, start_month, start_day, 00, 00)end_time = timestamp(end_year, end_month, end_day, 23, 59)is_back_test_time() =>    time >= start_time and time <= end_time ? true : false// Last barh1_last_bar = (timenow - time)/1000/60/60 < 2// EMAema50 = ema(close, 50)ema200 = ema(close, 200)// RSI length 200rsi200 = rsi(close, 200)// Bollinger Bands length 50bb50 = 2 * stdev(close, 50)// BHD Unitbhd_unit = sma(bb50, 100)bb50_upper = ema50 + bhd_unitbb50_lower = ema50 - bhd_unit// All n candles is going downall_body_decrease(n) =>    isValid = true    for i = 0 to (n - 1)        if (close[i] > close[i + 1])            isValid := false            break    isValid// ENTRY// Long-term uptrendentry_condition1 = rsi200 > 51 // Short-term downtrendentry_condition2 = all_body_decrease(2) ENTRY_CONDITION = entry_condition1 and entry_condition2if (ENTRY_CONDITION and is_back_test_time())    strategy.entry("entry", strategy.long)// CLOSE CONDITIONS// Price increase 1 BHD unitTAKE_PROFIT = close > strategy.position_avg_price + bhd_unit// Price decrease 2 BHD unitSTOP_LOSS = close < strategy.position_avg_price - bhd_unit * 2CLOSE_CONDITION = TAKE_PROFIT or STOP_LOSSif (CLOSE_CONDITION or h1_last_bar)    strategy.close("entry")// Drawplot(ema50)plot(ema200, color=color.yellow)plot(bb50_upper)plot(bb50_lower)