Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Atrend by OTS

A Pine Script v4 strategy built on EMA (close, 12), RSI (price, 18) and Crossover (vrsi, 30). It has 4 order rules, 4 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 14 settings; defaults include Fast Length 12, Slowlength 26 and MACDLength 9.

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 Atrend by OTS repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 22 of 22 trades.
How did Atrend by OTS do on BTCUSDT 1D with default settings?
+12.10%
From 26 Jan 2024 to 21 Oct 2026, over 76 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Atrend by OTS 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.
What alerts does Atrend by OTS have?
3
ATrend Buy; ATrend Sell; ATrend Direction Change.
Does Atrend by OTS use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.

BTCUSDT · 1D · default settings

  • Up Trend
  • UpTrend Begins
  • Down Trend
  • DownTrend Begins
  • DEMA
  • 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 (14)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$111,796$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. Lines are what the script plots.
Net profit
+12.10%
$12,097.30
Buy and hold
+102.5%
same period
Closed trades
76
28 won · 48 lost
Profitable
36.8%
of closed trades
Profit factor
1.07
gross profit ÷ gross loss
Max drawdown
34.37%
−$45,701.70

One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A short 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.

  • Likely bug

    crossover(delta, 0) ignores the settings line 12

    Line 12 hard-codes 0 where line 22 uses “Over Sold”. Changing those settings moves one band but not this one.

    crossover(delta, 0)crossover(delta, overSold)
  • Likely bug

    crossunder(delta, 0) ignores the settings line 14

    Line 14 hard-codes 0 where line 23 uses “Over Bought”. Changing those settings moves one band but not this one.

    crossunder(delta, 0)crossunder(delta, overBought)
  • Check

    No stop loss

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

  • Check

    No commission

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

  • Note

    7 settings have no label

    In the settings dialog fastLength (line 6), slowlength (line 7), MACDLength (line 8), length (line 17), overSold (line 18), overBought (line 19), length1 (line 64) show an empty name. The labels on this page come from the variable names.

  • Note

    No slippage

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

  • Note

    Uses transp =, which v5 removed line 49

    transp = on line 49, 50, 53, 54. v5 folds the transparency into the colour with color.new(c, transp).

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, crossover → ta.crossover, crossunder → ta.crossunder, rsi → ta.rsi, sma → ta.sma, atr → ta.atr, max → math.max, min → math.min.

v4 → v5

Verified

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

  • Line 4: //@version=4 → //@version=5
  • Line 9: ema → ta.ema
  • Line 9: ema → ta.ema
  • Line 10: ema → ta.ema
  • Line 12: crossover → ta.crossover
  • Line 14: crossunder → ta.crossunder
19 more edits
  • Line 21: rsi → ta.rsi
  • Line 22: crossover → ta.crossover
  • Line 23: crossunder → ta.crossunder
  • Line 30: input(type = input.integer) → input.int()
  • Line 32: input(type = input.float) → input.float()
  • Line 33: input(type = input.bool) → input.bool()
  • Line 34: input(type = input.bool) → input.bool()
  • Line 35: input(type = input.bool) → input.bool()
  • Line 36: sma → ta.sma
  • Line 36: tr → ta.tr
  • Line 37: atr → ta.atr
  • Line 40: max → math.max
  • Line 43: min → math.min
  • Line 49: transp = 0 → color.new(color.green, 0)
  • Line 50: transp = 0 → color.new(color.white, 0)
  • Line 53: transp = 0 → color.new(color.red, 0)
  • Line 54: transp = 0 → color.new(color.red, 0)
  • Line 66: ema → ta.ema
  • Line 67: ema → ta.ema
⋯// © OTS Music-//@version=4+//@version=5strategy("Atrend by OTS", overlay=true)⋯MACDLength = input(9)-MACD = ema(close, fastLength) - ema(close, slowlength)+MACD = ta.ema(close, fastLength) - ta.ema(close, slowlength)-aMACD = ema(MACD, MACDLength)+aMACD = ta.ema(MACD, MACDLength)delta = MACD - aMACD-if (crossover(delta, 0))+if (ta.crossover(delta, 0))    strategy.entry("MACD buy", strategy.long, comment="MACD buy")-if (crossunder(delta, 0))+if (ta.crossunder(delta, 0))    strategy.entry("MACD sell", strategy.short, comment="MACD sell")⋯price = close-vrsi = rsi(price, length)+vrsi = ta.rsi(price, length)-co = crossover(vrsi, overSold)+co = ta.crossover(vrsi, overSold)-cu = crossunder(vrsi, overBought)+cu = ta.crossunder(vrsi, overBought)if (not na(vrsi))⋯//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)-Periods = input(title="ATR Period", type=input.integer, defval=10)+Periods = input.int(title="ATR Period", defval=10)src = input(hl2, title="Source")-Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)+Multiplier = input.float(title="ATR Multiplier", step=0.1, defval=3.0)-changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)+changeATR= input.bool(title="Change ATR Calculation Method ?", defval=true)-showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=false)+showsignals = input.bool(title="Show Buy/Sell Signals ?", defval=false)-highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=false)+highlighting = input.bool(title="Highlighter On/Off ?", defval=false)-atr2 = sma(tr, Periods)+atr2 = ta.sma(ta.tr, Periods)-atr= changeATR ? atr(Periods) : atr2+atr= changeATR ? ta.atr(Periods) : atr2up=src-(Multiplier*atr)up1 = nz(up[1],up)-up := close[1] > up1 ? max(up,up1) : up+up := close[1] > up1 ? math.max(up,up1) : updn=src+(Multiplier*atr)dn1 = nz(dn[1], dn)-dn := close[1] < dn1 ? min(dn, dn1) : dn+dn := close[1] < dn1 ? math.min(dn, dn1) : dntrend = 1⋯buySignal = trend == 1 and trend[1] == -1-plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)+plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.green, 0))-plotshape(buySignal and showsignals ? up : na, title="", text="", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.white, textcolor=color.white, transp=0)+plotshape(buySignal and showsignals ? up : na, title="", text="", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.white, 0), textcolor=color.white)dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_line, linewidth=2, color=color.gray)sellSignal = trend == -1 and trend[1] == 1-plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)+plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.red, 0))-plotshape(sellSignal and showsignals ? dn : na, title="", text="", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)+plotshape(sellSignal and showsignals ? dn : na, title="", text="", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.white)mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)⋯srcb = input(close, title="Source")-e1 = ema(srcb, length1)+e1 = ta.ema(srcb, length1)-e2 = ema(e1, length)+e2 = ta.ema(e1, length)dema = 2 * e1 - e2⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
  • Line 17: input() → input.int()
  • Line 18: input() → input.int()
  • Line 19: input() → input.int()
3 more edits
  • Line 31: input() → input.source()
  • Line 64: input() → input.int()
  • Line 65: input() → input.source()
⋯strategy("Atrend by OTS", overlay=true)-fastLength = input(12)+fastLength = input.int(12)-slowlength = input(26)+slowlength = input.int(26)-MACDLength = input(9)+MACDLength = input.int(9)MACD = ta.ema(close, fastLength) - ta.ema(close, slowlength)⋯//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)-length = input( 18 )+length = input.int( 18 )-overSold = input( 30 )+overSold = input.int( 30 )-overBought = input( 70 )+overBought = input.int( 70 )price = close⋯Periods = input.int(title="ATR Period", defval=10)-src = input(hl2, title="Source")+src = input.source(hl2, title="Source")Multiplier = input.float(title="ATR Multiplier", step=0.1, defval=3.0)⋯alertcondition(changeCond, title="ATrend Direction Change", message="ATrend has changed direction!")-length1 = input(25, minval=1)+length1 = input.int(25, minval=1)-srcb = input(close, title="Source")+srcb = input.source(close, title="Source")e1 = ta.ema(srcb, length1)⋯

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L55:C56: 'linewidth' must be at least 1 in Pine Script v6. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © OTS Music-//@version=5+//@version=6strategy("Atrend by OTS", overlay=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
Fast Length (no label in the script)12intMACD
Slowlength (no label in the script)26intMACD
MACDLength (no label in the script)9intaMACD
Length (no label in the script)18intvrsi e2
Over Sold (no label in the script)30intco
Over Bought (no label in the script)70intcu
ATR Period10int (written input.integer)atr2 atr
Sourcehl2sourceup dn
ATR Multiplier3.0float · step 0.1up dn
Change ATR Calculation Method ?trueboolatr
Show Buy/Sell Signals ?falseboolplotshape
Highlighter On/Off ?falseboollongFillColor shortFillColor
Length1 (no label in the script)25int · min 1e1
Sourceclosesourcee1

What it calculates

  • EMA (ema, ta.ema in v5)close, Fast Length (12)MACD · line 9
  • EMA (ema, ta.ema in v5)MACD, MACDLength (9)aMACD · line 10
  • RSI (rsi, ta.rsi in v5)price, Length (18)vrsi · line 21
  • Crossover (crossover, ta.crossover in v5)vrsi, Over Sold (30)co · line 22
  • Crossunder (crossunder, ta.crossunder in v5)vrsi, Over Bought (70)cu · line 23
  • SMA (sma, ta.sma in v5)tr, ATR Period (10)atr2 · line 36
  • ATR (atr, ta.atr in v5)ATR Period (10)atr · line 37
  • EMA (ema, ta.ema in v5)Source (close), Length1 (25)e1 · line 66
  • EMA (ema, ta.ema in v5)e1, Length (18)e2 · line 67

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 datafastLengthFast Lengthsetting · 12slowlengthSlowlengthsetting · 26MACDLengthMACDLengthsetting · 9lengthLengthsetting · 18overSoldOver Soldsetting · 30overBoughtOver Boughtsetting · 70PeriodsATR Periodsetting · 10high · low · closehigh · low · closeprice datalength1Length1setting · 25hl2hl2price dataMultiplierATR Multipliersetting · 3.0ohlc4ohlc4price dataMACDEMA→ MACDaMACDEMA→ aMACDvrsiRSI→ vrsicoCrossover→ cocuCrossunder→ cuatr2SMA→ atr2atrATR→ atre1EMA→ e1e2EMA→ e2deltadeltavaluepricepricevalueupupvalueup1up1valuedndnvaluedn1dn1valuetrendtrendvaluedemademavaluebuySignal, sellSignal, changeCondbuySignal · sellSignal …3 conditionslongFillColor, shortFillColorColourlongFillColor · shortFillColorentry:MACD buyOpen MACD buystrategy.entryentry:MACD sellOpen MACD sellstrategy.entryentry:RSI buyOpen RSI buystrategy.entryentry:RSI sellOpen RSI sellstrategy.entryplot:47Up Trendplotplotshape:49UpTrend Beginsplotshapeplotshape:50plotshapeplot:51Down Trendplotplotshape:53DownTrend Beginsplotshapeplotshape:54plotshapeplot:55plotfill:UpTrend HighligterUpTrend Highligterfillfill:DownTrend HighligterDownTrend Highligterfillalertcondition:60ATrend Buyalertconditionalertcondition:61ATrend Sellalertconditionalertcondition:63ATrend Direction Changealertconditionplot:69DEMAplot

Order rules

OrderFires whenBy defaultLine
Open MACD buy long(crossover(delta, 0))On13
Open MACD sell short(crossunder(delta, 0))On15
Open RSI buy long(co)On26
Open RSI sell short(cu)On28

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Alerts

AlertCallMessageLine
ATrend BuyalertconditionATrend Buy!60
ATrend SellalertconditionATrend Sell!61
ATrend Direction ChangealertconditionATrend has changed direction!63

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

22/22trades 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. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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+12.1%+102.5%7637%1.0734.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+7.5%+5.5%6841%1.1515.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−1.3%+9.8%7233%0.883.7%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.4%+8.4%7633%0.830.8%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%6445%1.020.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.0%+21.5%7134%0.920.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.3%+148.3%6849%1.260.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.1%+17.1%7731%1.220.1%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 market2536%−$3,707.36
Sideways market3642%$30,805.00
Falling market1527%−$15,000.40

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

How bad could the drawdown be?

50.5%

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

0%58%
All 76 trades
SideEntryExitBarsP&L
short16 Mar 2024 69,499.806 May 2024 64,012.0051$5,487.84
long6 May 2024 64,012.0012 May 2024 60,826.006−$3,186.01
short12 May 2024 60,826.0013 May 2024 61,484.001−$658.01
long13 May 2024 61,484.0031 May 2024 68,352.2018$6,868.17
short31 May 2024 68,352.206 Jun 2024 71,108.006−$2,755.83
long6 Jun 2024 71,108.009 Jun 2024 69,310.503−$1,797.54
short9 Jun 2024 69,310.5013 Jul 2024 57,889.1034$11,421.40
long13 Jul 2024 57,889.101 Aug 2024 64,628.0019$6,738.92
short1 Aug 2024 64,628.0020 Aug 2024 59,438.5019$5,189.51
long20 Aug 2024 59,438.5031 Aug 2024 59,124.0011−$314.51
short31 Aug 2024 59,124.0013 Sep 2024 58,132.3013$991.68
long13 Sep 2024 58,132.302 Oct 2024 60,804.9019$2,672.61
short2 Oct 2024 60,804.9015 Oct 2024 66,084.0013−$5,279.08
long15 Oct 2024 66,084.0027 Oct 2024 67,092.8012$1,008.76
short27 Oct 2024 67,092.8029 Oct 2024 69,962.202−$2,869.45
long29 Oct 2024 69,962.204 Nov 2024 68,776.006−$1,186.22
short4 Nov 2024 68,776.007 Nov 2024 75,572.003−$6,796.00
long7 Nov 2024 75,572.0026 Nov 2024 93,010.0019$17,438.00
short26 Nov 2024 93,010.0017 Dec 2024 106,059.0021−$13,048.60
long17 Dec 2024 106,059.0019 Dec 2024 100,204.002−$5,854.64
short19 Dec 2024 100,204.006 Jan 2025 98,363.6018$1,840.40
long6 Jan 2025 98,363.6010 Jan 2025 92,552.504−$5,811.12
short10 Jan 2025 92,552.5016 Jan 2025 100,497.006−$7,944.86
long16 Jan 2025 100,497.0029 Jan 2025 101,336.0013$838.17
short29 Jan 2025 101,336.0021 Feb 2025 98,305.0023$3,030.51
long21 Feb 2025 98,305.0025 Feb 2025 91,552.904−$6,752.13
short25 Feb 2025 91,552.902 Mar 2025 86,064.505$5,488.34
long2 Mar 2025 86,064.509 Mar 2025 86,222.507$157.92
short9 Mar 2025 86,222.5016 Mar 2025 84,338.407$1,884.02
long16 Mar 2025 84,338.407 Apr 2025 78,430.0022−$5,908.44
short7 Apr 2025 78,430.0012 Apr 2025 83,423.805−$4,993.83
long12 Apr 2025 83,423.8013 May 2025 102,791.0031$19,367.50
short13 May 2025 102,791.0019 May 2025 106,454.006−$3,662.95
long19 May 2025 106,454.0020 May 2025 105,574.001−$880.54
short20 May 2025 105,574.0022 May 2025 109,644.002−$4,070.26
long22 May 2025 109,644.0024 May 2025 107,318.002−$2,325.69
short24 May 2025 107,318.0011 Jun 2025 110,274.0018−$2,956.09
long11 Jun 2025 110,274.0013 Jun 2025 105,672.002−$4,602.65
short13 Jun 2025 105,672.0027 Jun 2025 106,947.0014−$1,275.32
long27 Jun 2025 106,947.0016 Jul 2025 117,758.0019$10,811.00
short16 Jul 2025 117,758.0023 Jul 2025 119,954.007−$2,196.35
long23 Jul 2025 119,954.0024 Jul 2025 118,756.001−$1,198.43
short24 Jul 2025 118,756.0012 Aug 2025 118,686.0019$70.00
long12 Aug 2025 118,686.0018 Aug 2025 117,405.006−$1,280.99
short18 Aug 2025 117,405.007 Sep 2025 110,188.0020$7,217.03
long7 Sep 2025 110,188.0024 Sep 2025 111,999.0017$1,810.82
short24 Sep 2025 111,999.002 Oct 2025 118,595.008−$6,596.19
long2 Oct 2025 118,595.0011 Oct 2025 112,774.009−$5,820.50
short11 Oct 2025 112,774.0027 Oct 2025 114,559.0016−$1,784.92
long27 Oct 2025 114,559.004 Nov 2025 106,583.008−$7,976.36
short4 Nov 2025 106,583.0024 Nov 2025 86,830.0020$19,753.10
long24 Nov 2025 86,830.0018 Dec 2025 86,243.2024−$586.77
short18 Dec 2025 86,243.2021 Dec 2025 88,360.903−$2,117.68
long21 Dec 2025 88,360.9021 Jan 2026 88,427.7031$66.75
short21 Jan 2026 88,427.703 Feb 2026 78,738.6013$9,689.06
long3 Feb 2026 78,738.6023 Mar 2026 67,859.0048−$10,879.60
short23 Mar 2026 67,859.0026 Mar 2026 71,336.503−$3,477.53
long26 Mar 2026 71,336.5027 Mar 2026 68,820.301−$2,516.22
short27 Mar 2026 68,820.307 Apr 2026 68,853.7011−$33.35
long7 Apr 2026 68,853.7029 Apr 2026 76,342.8022$7,489.12
short29 Apr 2026 76,342.805 May 2026 79,861.006−$3,518.23
long5 May 2026 79,861.0013 May 2026 80,504.508$643.46
short13 May 2026 80,504.5012 Jun 2026 63,626.0030$16,878.50
long12 Jun 2026 63,626.0028 Jun 2026 60,029.0016−$3,596.99
short28 Jun 2026 60,029.0030 Jun 2026 60,260.202−$231.19
long30 Jun 2026 60,260.201 Jul 2026 58,624.701−$1,635.49
short1 Jul 2026 58,624.702 Jul 2026 60,024.001−$1,399.29
long2 Jul 2026 60,024.0028 Jul 2026 63,755.9026$3,731.86
short28 Jul 2026 63,755.908 Aug 2026 64,923.2011−$1,167.34
long8 Aug 2026 64,923.2012 Aug 2026 63,600.004−$1,323.19
short12 Aug 2026 63,600.0019 Aug 2026 64,725.407−$1,125.41
long19 Aug 2026 64,725.4029 Aug 2026 77,845.9010$13,120.50
short29 Aug 2026 77,845.904 Sep 2026 81,270.406−$3,424.49
long4 Sep 2026 81,270.405 Sep 2026 79,660.801−$1,609.60
short5 Sep 2026 79,660.8022 Sep 2026 86,620.0017−$6,959.24
long22 Sep 2026 86,620.0024 Sep 2026 84,397.602−$2,222.41

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
Atrend by OTS this page—v4 strategy+12.1%7634.4%
3 x EMA + Stochastic RSI + ATR by tomimarsonema rsi sma atrv4 strategy−42.3%1844.8%
EMA crossover (daily TF) by tradeswithashishema sma rsi atrv5 strategy+11.0%1211.6%
Delta-RSI Strategy (with filters) by tbiktagrsi ema atr smav4 strategy−28.8%7183.8%
[KL] Bollinger bands + RSI Strategy by DojiEmojisma atr ema rsiv4 strategy+28.2%3014.7%
3x Supertrend and Stoch RSI by M3RZIrsi sma ema atrv4 strategy−128.7%24207.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 25 msYes 1,000 bars in 83 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/// © prim722// © OTS Music//@version=4strategy("Atrend by OTS", overlay=true)fastLength = input(12)slowlength = input(26)MACDLength = input(9)MACD = ema(close, fastLength) - ema(close, slowlength)aMACD = ema(MACD, MACDLength)delta = MACD - aMACDif (crossover(delta, 0))    strategy.entry("MACD buy", strategy.long, comment="MACD buy")if (crossunder(delta, 0))    strategy.entry("MACD sell", strategy.short, comment="MACD sell")//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)length = input( 18 )overSold = input( 30 )overBought = input( 70 )price = closevrsi = rsi(price, length)co = crossover(vrsi, overSold)cu = crossunder(vrsi, overBought)if (not na(vrsi))    if (co)        strategy.entry("RSI buy", strategy.long, comment="RSI buy")    if (cu)        strategy.entry("RSI sell", strategy.short, comment="RSI sell")//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)Periods = input(title="ATR Period", type=input.integer, defval=10)src = input(hl2, title="Source")Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=false)highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=false)atr2 = sma(tr, Periods)atr= changeATR ? atr(Periods) : atr2up=src-(Multiplier*atr)up1 = nz(up[1],up)up := close[1] > up1 ? max(up,up1) : updn=src+(Multiplier*atr)dn1 = nz(dn[1], dn)dn := close[1] < dn1 ? min(dn, dn1) : dntrend = 1trend := nz(trend[1], trend)trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trendupPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_line, linewidth=2, color=color.white)buySignal = trend == 1 and trend[1] == -1plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)plotshape(buySignal and showsignals ? up : na, title="", text="", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.white, textcolor=color.white, transp=0)dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_line, linewidth=2, color=color.gray)sellSignal = trend == -1 and trend[1] == 1plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)plotshape(sellSignal and showsignals ? dn : na, title="", text="", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)longFillColor = highlighting ? (trend == 1 ? color.white : color.white) : color.whiteshortFillColor = highlighting ? (trend == -1 ? color.gray : color.white) : color.whitefill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)alertcondition(buySignal, title="ATrend Buy", message="ATrend Buy!")alertcondition(sellSignal, title="ATrend Sell", message="ATrend Sell!")changeCond = trend != trend[1]alertcondition(changeCond, title="ATrend Direction Change", message="ATrend has changed direction!")length1 = input(25, minval=1)srcb = input(close, title="Source")e1 = ema(srcb, length1)e2 = ema(e1, length)dema = 2 * e1 - e2plot(dema, "DEMA", color.red)