Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Take Profit On Trend v2 (by BHD_Trade_Bot)

A Pine Script v5 strategy built on EMA (close, 50), RSI (close, 200) and RMA (high - low, 200). 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 100% of equity and pays 0.1% commission. 6 settings; defaults include Start year 2021, Start month 1 and Start day 1.

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 v2 (by BHD_Trade_Bot) repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did Take Profit On Trend v2 (by BHD_Trade_Bot) do on BTCUSDT 1D with default settings?
+9.44%
From 26 Jan 2024 to 21 Oct 2026, over 6 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Take Profit On Trend v2 (by BHD_Trade_Bot) run in Pine Script v6?
Yes
Same 6 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 Take Profit On Trend v2 (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 v2 (by BHD_Trade_Bot) run in Zeal Terminal?
Yes
It compiles in 15 ms and runs 1,000 bars in 40 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 (6)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,098$2,025Equity from $1,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
+9.44%
$94.41
Buy and hold
+102.5%
same period
Closed trades
6
4 won · 2 lost
Profitable
66.7%
of closed trades
Profit factor
1.17
gross profit ÷ gross loss
Max drawdown
24.01%
−$326.88

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

  • Check

    No stop loss

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

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • 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
Start year2021intstart_time
Start month1intstart_time
Start day1intstart_time
end year2050intend_time
end month1intend_time
end day1intend_time

What it calculates

  • EMAclose, 50ema50 · line 27
  • EMAclose, 200ema200 · line 28
  • RSIclose, 200rsi200 · line 30
  • EMAemacd, 50emacd_signal · line 33
  • RMAhigh - low, 200bhd_unit · line 36

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 datalowlowprice datahighhighprice datastart_yearStart yearsetting · 2021start_monthStart monthsetting · 1start_dayStart daysetting · 1end_yearend yearsetting · 2050end_monthend monthsetting · 1end_dayend daysetting · 1ema50EMA→ ema50ema200EMA→ ema200rsi200RSI→ rsi200emacd_signalEMA→ emacd_signalbhd_unitRMA→ bhd_unitstart_timestart_timevalueend_timeend_timevalueemacdemacdvaluehisthistvaluebhd_upper, bhd_lowerbhd_upper · bhd_lower2 valuesENTRY_CONDITIONSENTRY_CONDITIONSconditionCLOSE_CONDITIONSCLOSE_CONDITIONSconditionentry_condition1entry_condition1conditiontake_profit, stop_losstake_profit · stop_loss2 conditionsentry:entryOpen entrystrategy.entryclose:entryClose entrystrategy.closeplot:64plotplotplot:65plotplotplot:66plotplotplot:67plotplotfill:68Fillfill

Order rules

OrderFires whenBy defaultLine
Open entry longENTRY_CONDITIONS and is_back_test_time()On54
Close entryCLOSE_CONDITIONSOn62

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.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationcalc_on_every_tick = true. Live values can differ from history.
  • 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+9.4%+102.5%667%1.1724.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+11.4%+5.5%2100%103.376.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−5.0%+9.8%560%0.9446.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−5.5%+8.4%250%0.5211.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−34.0%+16.7%450%0.6057.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+4.3%+21.5%667%1.1812.7%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+76.2%+148.3%683%2.4727.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−2.3%+17.1%560%0.8610.2%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 market367%$1.26
Sideways market367%$94.25
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?

36.6%

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

0%42%
All 6 trades
SideEntryExitBarsP&L
long1 Oct 2024 63,327.607 Nov 2024 75,572.0037$190.97
long18 Nov 2024 89,856.009 Dec 2024 101,110.0021$146.48
long11 Dec 2024 96,593.009 Apr 2025 76,322.40119−$282.78
long5 May 2025 94,277.6022 May 2025 109,644.0017$169.45
long29 May 2025 107,782.0013 Aug 2025 120,134.0076$137.56
long16 Aug 2025 117,342.0015 Nov 2025 94,594.0091−$266.17

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 v2 (by BHD_Trade_Bot) this page—v5 strategy+9.4%624.0%
MTF Diagonally Layered RSI - 1 minute Bitcoin Bot [wbburgin] by wbburginrsi rma emav5 strategyNo trades on this market
Hulk Strategy x35 Leverage 5m chart w-Alerts by npietronuto1rsi rma emav5 strategyNo trades on this market
Kahlman HullMA - WT Cross Strategy by pigsqema rsi rmav5 strategy+1.0%5433.3%
RSI Cross [xaurr] by livetrendrsi emav4 strategy+24.4%5335.3%
Bitpanda Coinrule Template by joshuajcoop01rsi emav5 strategy−2.8%44.6%

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.

  • 6 settings use the untyped input() (line 17, 18, 19, 21, 22, 23). 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 6 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 17: input() → input.int()
  • Line 18: input() → input.int()
  • Line 19: input() → input.int()
  • Line 21: input() → input.int()
  • Line 22: input() → input.int()
  • Line 23: input() → input.int()
⋯// Backtest Time Period-start_year   = input(title='Start year'   ,defval=2021)+start_year   = input.int(title='Start year'   ,defval=2021)-start_month  = input(title='Start month'  ,defval=1)+start_month  = input.int(title='Start month'  ,defval=1)-start_day    = input(title='Start day'    ,defval=1)+start_day    = input.int(title='Start day'    ,defval=1)start_time = timestamp(start_year, start_month, start_day, 00, 00)-end_year     = input(title='end year'     ,defval=2050)+end_year     = input.int(title='end year'     ,defval=2050)-end_month    = input(title='end month'    ,defval=1)+end_month    = input.int(title='end month'    ,defval=1)-end_day      = input(title='end day'      ,defval=1)+end_day      = input.int(title='end day'      ,defval=1)end_time = timestamp(end_year, end_month, end_day, 23, 59)⋯

Does it run in Pine Script v6?

Yes

Same 6 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

⋯// © BHD_Trade_Bot-// @version=5+// @version=6strategy(⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 15 msYes 1,000 bars in 40 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/// © BHD_Trade_Bot// @version=5strategy( shorttitle            = 'Take Profit On Trend', title                 = 'Take Profit On Trend (by BHD_Trade_Bot)', overlay               = true, calc_on_every_tick    = true, calc_on_order_fills   = true, use_bar_magnifier     = true, initial_capital       = 1000, default_qty_type      = strategy.percent_of_equity, default_qty_value     = 100, commission_type       = strategy.commission.percent, commission_value      = 0.1)// Backtest Time Periodstart_year   = input(title='Start year'   ,defval=2021)start_month  = input(title='Start month'  ,defval=1)start_day    = input(title='Start day'    ,defval=1)start_time = timestamp(start_year, start_month, start_day, 00, 00)end_year     = input(title='end year'     ,defval=2050)end_month    = input(title='end month'    ,defval=1)end_day      = input(title='end day'      ,defval=1)end_time = timestamp(end_year, end_month, end_day, 23, 59)is_back_test_time() => time >= start_time and time <= end_time ? true : false// EMAema50 = ta.ema(close, 50)ema200 = ta.ema(close, 200)// RSIrsi200 = ta.rsi(close, 200)// EMA_CDemacd = ema50 - ema200emacd_signal = ta.ema(emacd, 50)hist = emacd - emacd_signal// BHD Unitbhd_unit = ta.rma(high - low, 200) * 2bhd_upper = ema200 + bhd_unitbhd_lower = ema200 - 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 CONDITIONS// Long-term uptrendentry_condition1 = rsi200 > 51 and hist > 0// Short-term downtrendentry_condition2 = all_body_decrease(2)ENTRY_CONDITIONS = entry_condition1 and entry_condition2if ENTRY_CONDITIONS and is_back_test_time()    strategy.entry('entry', strategy.long)// CLOSE CONDITIONS// Price increase 2 BHD unittake_profit = close > strategy.position_avg_price + bhd_unit * 2// Price decrease 3 BHD unitstop_loss = close < strategy.position_avg_price - bhd_unit * 3CLOSE_CONDITIONS = take_profit or stop_lossif CLOSE_CONDITIONS    strategy.close('entry')// Drawplot(ema50, color=color.orange, linewidth=2)plot(ema200, color=color.purple, linewidth=2)bhd_upper_line = plot(bhd_upper, color=color.teal)bhd_lower_line = plot(bhd_lower, color=color.teal)fill(bhd_upper_line, bhd_lower_line, color=color.new(color.teal, 90))