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
- 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.
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
VerifiedNothing 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.emain v5)close, 50ema50 · line 26 - EMA (
ema,ta.emain v5)close, 200ema200 · line 27 - RSI (
rsi,ta.rsiin v5)close, 200rsi200 · line 29 - Stdev (
stdev,ta.stdevin v5)close, 50bb50 · line 31 - SMA (
sma,ta.smain 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open entry long | (ENTRY_CONDITION and is_back_test_time()) | On | 51 |
| Close entry | (CLOSE_CONDITION or h1_last_bar) | On | 59 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +54.8% | +102.5% | 9 | 78% | 2.62 | 13.1% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +5.9% | +5.5% | 4 | 75% | 2.11 | 6.8% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −21.4% | +9.8% | 5 | 60% | 0.70 | 50.7% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +1.9% | +8.4% | 4 | 75% | 1.18 | 17.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +8.9% | +16.7% | 7 | 71% | 1.11 | 54.9% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +5.1% | +21.5% | 6 | 67% | 1.24 | 17.2% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +39.8% | +148.3% | 12 | 75% | 1.52 | 30.9% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +6.6% | +17.1% | 5 | 80% | 1.75 | 11.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 4 | 50% | −$1.68 |
| Sideways market | 5 | 100% | $9.91 |
| 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?
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.
All 9 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 16 Aug 2024 57,541.10 | 27 Sep 2024 65,174.00 | 42 | $1.96 |
| long | 1 Oct 2024 63,327.60 | 30 Oct 2024 72,736.40 | 29 | $2.20 |
| long | 1 Nov 2024 70,292.00 | 11 Nov 2024 80,370.00 | 10 | $2.12 |
| long | 18 Nov 2024 89,856.00 | 22 Nov 2024 98,317.10 | 4 | $1.38 |
| long | 27 Nov 2024 91,965.20 | 16 Dec 2024 104,464.00 | 19 | $2.01 |
| long | 20 Dec 2024 97,461.90 | 7 Apr 2025 78,430.00 | 108 | −$2.96 |
| long | 28 Apr 2025 93,749.30 | 11 May 2025 104,810.00 | 13 | $1.74 |
| long | 13 May 2025 102,791.00 | 11 Jul 2025 116,010.00 | 59 | $1.90 |
| long | 20 Jul 2025 117,840.00 | 5 Nov 2025 101,497.00 | 108 | −$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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Take Profit On Trend (by BHD_Trade_Bot) this page | — | v4 strategy | +54.8% | 9 | 13.1% |
| 5 Minute Scalping Strategy by Coachman0912 | sma ema stdev rsi | v5 strategy | No trades on this market | ||
| Bollinger Band + RSI + ADX + MACD + Heikinashi by TradeUsingPivots | sma stdev rsi ema | v4 strategy | No trades on this market | ||
| RSI Rising Crypto Trending Strategy by exlux99 | sma stdev ema rsi | v4 strategy | No trades on this market | ||
| [KL] Bollinger bands + RSI Strategy by DojiEmoji | sma stdev ema rsi | v4 strategy | +28.2% | 30 | 14.7% |
| [KL] Bollinger Bands Consolidation Strategy by DojiEmoji | sma stdev ema rsi | v4 strategy | +39.1% | 33 | 19.6% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 15 ms | Yes 1,000 bars in 31 ms | Not measured |
| PineTS | No 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)