Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Trend Reversal - Potential pressure

A Pine Script v4 strategy built on ATR (7) and EMA (close, 500). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no 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 Trend Reversal - Potential pressure repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did Trend Reversal - Potential pressure do on BTCUSDT 1D with default settings?
+133,960.00%
From 26 Jan 2024 to 21 Oct 2026, over 5 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Trend Reversal - Potential pressure 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 Trend Reversal - Potential pressure use a stop loss?
Yes
strategy.exit sets a stop on line 14, 17.
Does Trend Reversal - Potential pressure run in Zeal Terminal?
Yes
It compiles in 19 ms and runs 1,000 bars in 24 ms, in the browser.

BTCUSDT · 1D · default settings

  • ATR
  • EMA
  • 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)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$134,067,000$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference.
Net profit
+133,960.00%
$133,960,000.00
Buy and hold
+102.5%
same period
Closed trades
5
4 won · 1 lost
Profitable
80.0%
of closed trades
Profit factor
3.23
gross profit ÷ gross loss
Max drawdown
1,504.80%
−$77,192,900.00

One run with the author's default settings, $100,000 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 commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • 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 atr → ta.atr, ema → ta.ema.

v4 → v5

VerifiedDownload the v5 script

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

  • Line 3: //@version=4 → //@version=5
  • Line 5: atr → ta.atr
  • Line 6: ema → ta.ema
⋯// © BardiaB2-//@version=4+//@version=5strategy("TR", calc_on_every_tick=true)-ATR=atr(7) * 1+ATR=ta.atr(7) * 1-trendMA = ema(close, 500)+trendMA = ta.ema(close, 500)is_trend_up = close>trendMA⋯

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: 5 before, 0 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.

⋯// © BardiaB2-//@version=5+//@version=6strategy("TR", calc_on_every_tick=true)⋯

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

  • ATR (atr, ta.atr in v5)7ATR · line 5
  • EMA (ema, ta.ema in v5)close, 500trendMA · line 6

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.

high · low · closehigh · low · closeprice dataclosecloseprice datalowlowprice dataopenopenprice datahighhighprice dataATRATR→ ATRtrendMAEMA→ trendMAis_trend_upis_trend_upconditionentry:LEOpen LEstrategy.entryexit:TP/SL LEexit TP/SL LEstrategy.exitentry:SEOpen SEstrategy.entryexit:TP/SL SEexit TP/SL SEstrategy.exit

Order rules

OrderFires whenBy defaultLine
Open LE longis_hammer(1) and is_red(2) and is_green(0) and close>close[1] and open[1]>open and low>low[1] and is_trend_upOn13
Exit TP/SL LE stop and limitis_hammer(1) and is_red(2) and is_green(0) and close>close[1] and open[1]>open and low>low[1] and is_trend_upOn14
Open SE shortis_stick(1) and is_green(2) and is_red(0) and close<close[1] and open[1]<open and high<high[1] and (not is_trend_up)On16
Exit TP/SL SE stop and limitis_stick(1) and is_green(2) and is_red(0) and close<close[1] and open[1]<open and high<high[1] and (not is_trend_up)On17

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.

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. On 2 of them the position changed while the bar was forming before it settled. Anyone watching live sees those changes; once the bar closes it matches history.
  • 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+133,960.0%+102.5%580%3.231,504.8%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+32,755.3%+5.5%2100%—5,861.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+8,133.5%+9.8%3100%—5.9%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−893.2%+8.4%633%0.602,124.4%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−409.2%+16.7%40%0.00409.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−31.2%+21.5%450%0.5751.3%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+1,344.6%+148.3%367%5.24439.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+179.6%+17.1%863%1.42117.0%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%$56,554,700.00
Sideways market1100%$31,598,200.00
Falling market1100%$45,807,200.00

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

How bad could the drawdown be?

57.2%

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

0%66%
All 5 trades
SideEntryExitBarsP&L
short3 Jul 2024 62,135.504 Jul 2024 58,975.601$31,598,200.00
short19 Dec 2024 100,204.0020 Dec 2024 92,894.001$73,100,400.00
long27 Jul 2025 117,920.003 Aug 2025 111,922.007−$59,976,100.00
short30 Jan 2026 84,650.2031 Jan 2026 80,069.401$45,807,200.00
long4 Sep 2026 81,270.4021 Sep 2026 85,613.4017$43,430,400.00

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
Trend Reversal - Potential pressure this page—v4 strategy+133,960.0%51,504.8%
Simple Ema_ATR Strategy HulkTrading by TheHulkTradingema atrv4 strategy+2.2%1415.6%
Keltner Breakout Strategy by Zeal Terminalema atrv5 strategy+3.5%212.3%
[EKIN] ATR Exit Strategy by ekinbasarkomurema atrv5 strategy+781.7%302,960.8%
DEMA-EMA & VOLATILITY (VAMS) by Qorbanjfema atrv4 strategy+2,833,450.0%1915,721.0%
Super Z strategy - Thanks to Rafael Zioni by 03.freemanema atrv4 strategy−404,823.0%562,951,790.0%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 19 msYes 1,000 bars in 24 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.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © BardiaB2//@version=4strategy("TR", calc_on_every_tick=true)ATR=atr(7) * 1trendMA = ema(close, 500)is_trend_up = close>trendMAis_red(i) => (close[i] < open[i]) ? 1 : 0is_green(i) => is_red(i) ? 0 : 1is_hammer(i) => is_red(i) ? ((high[i]-close[i]) < (high[i]-low[i])/3 ) : ((high[i]-open[i]) < (high[i]-low[i])/3 )  is_stick(i)  => is_red(i) ? ((open[i]-low[i]) < (high[i]-low[i])/3 ) : ((close[i]-low[i]) < (high[i]-low[i])/3 )  if is_hammer(1) and is_red(2) and is_green(0) and close>close[1] and open[1]>open and low>low[1] and is_trend_up    strategy.entry("LE", strategy.long, 10000)    strategy.exit("TP/SL LE", "LE", stop = low[1]-ATR, limit=close+(high[1]-low[1])+ATR)if is_stick(1) and is_green(2) and is_red(0) and close<close[1] and open[1]<open and high<high[1] and (not is_trend_up)    strategy.entry("SE", strategy.short, 10000)    strategy.exit("TP/SL SE", "SE", stop = high[1]+ATR, limit=close-(high[1]-low[1])-ATR)