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
- 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Start year | 2021 | int | start_time |
| Start month | 1 | int | start_time |
| Start day | 1 | int | start_time |
| end year | 2050 | int | end_time |
| end month | 1 | int | end_time |
| end day | 1 | int | end_time |
What it calculates
- EMAclose, 50
ema50 · line 27 - EMAclose, 200
ema200 · line 28 - RSIclose, 200
rsi200 · line 30 - EMAemacd, 50
emacd_signal · line 33 - RMAhigh - low, 200
bhd_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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open entry long | ENTRY_CONDITIONS and is_back_test_time() | On | 54 |
| Close entry | CLOSE_CONDITIONS | On | 62 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +9.4% | +102.5% | 6 | 67% | 1.17 | 24.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +11.4% | +5.5% | 2 | 100% | 103.37 | 6.6% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −5.0% | +9.8% | 5 | 60% | 0.94 | 46.8% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −5.5% | +8.4% | 2 | 50% | 0.52 | 11.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −34.0% | +16.7% | 4 | 50% | 0.60 | 57.8% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +4.3% | +21.5% | 6 | 67% | 1.18 | 12.7% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +76.2% | +148.3% | 6 | 83% | 2.47 | 27.5% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −2.3% | +17.1% | 5 | 60% | 0.86 | 10.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 3 | 67% | $1.26 |
| Sideways market | 3 | 67% | $94.25 |
| Falling market | 0 | — | $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.
All 6 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 1 Oct 2024 63,327.60 | 7 Nov 2024 75,572.00 | 37 | $190.97 |
| long | 18 Nov 2024 89,856.00 | 9 Dec 2024 101,110.00 | 21 | $146.48 |
| long | 11 Dec 2024 96,593.00 | 9 Apr 2025 76,322.40 | 119 | −$282.78 |
| long | 5 May 2025 94,277.60 | 22 May 2025 109,644.00 | 17 | $169.45 |
| long | 29 May 2025 107,782.00 | 13 Aug 2025 120,134.00 | 76 | $137.56 |
| long | 16 Aug 2025 117,342.00 | 15 Nov 2025 94,594.00 | 91 | −$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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Take Profit On Trend v2 (by BHD_Trade_Bot) this page | — | v5 strategy | +9.4% | 6 | 24.0% |
| MTF Diagonally Layered RSI - 1 minute Bitcoin Bot [wbburgin] by wbburgin | rsi rma ema | v5 strategy | No trades on this market | ||
| Hulk Strategy x35 Leverage 5m chart w-Alerts by npietronuto1 | rsi rma ema | v5 strategy | No trades on this market | ||
| Kahlman HullMA - WT Cross Strategy by pigsq | ema rsi rma | v5 strategy | +1.0% | 54 | 33.3% |
| RSI Cross [xaurr] by livetrend | rsi ema | v4 strategy | +24.4% | 53 | 35.3% |
| Bitpanda Coinrule Template by joshuajcoop01 | rsi ema | v5 strategy | −2.8% | 4 | 4.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.
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.
⋯// © BHD_Trade_Bot-// @version=5+// @version=6strategy(⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 15 ms | Yes 1,000 bars in 40 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
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))