Pine Script v4 · Strategy
Oath
A Pine Script v4 strategy built on EMA (close, 21), SMA (close, 20) and DEV (close, 20). It has 12 order rules, 6 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. 22 settings; defaults include Short EMA 21, Long EMA 55 and Overbought/sold detector period 20.
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 Oath repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 28 of 28 trades.
- How did Oath do on BTCUSDT 1D with default settings?
- +0.18%
- From 26 Jan 2024 to 21 Oct 2026, over 45 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Oath be converted to Pine Script v5?
- No
- The automatic step from v4 to v5 changes the results, so no v5 download is offered; the edits are shown below.
- Does Oath use a stop loss?
- Yes
- strategy.exit sets a stop on line 75, 83, 91, 97, 103, 109.
- Does Oath run in Zeal Terminal?
- Yes
- It compiles in 27 ms and runs 1,000 bars in 73 ms, in the browser.
BTCUSDT · 1D · default settings
- Shape
- Shape
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +0.18%
- $180.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 45
- 45 won · 0 lost
- Profitable
- 100.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.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
1 setting does nothing
“Illuminate Trend” is declared but never read.
-
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.
-
Note
Uses transp =, which v5 removed line 110
transp = on line 110, 111, 112, 113, 114, 115. 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, sma → ta.sma, dev → ta.dev, atr → ta.atr, max → math.max, min → math.min, floor → math.floor, barssince → ta.barssince.
v4 → v5
DiffersTrades differ: 45 before, 52 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 7: ema → ta.ema
- Line 10: ema → ta.ema
- Line 14: sma → ta.sma
- Line 15: dev → ta.dev
- Line 30: input(type = input.integer) → input.int()
26 more edits
- Line 31: input(type = input.float) → input.float()
- Line 32: input(type = input.bool) → input.bool()
- Line 33: input(type = input.bool) → input.bool()
- Line 34: atr → ta.atr
- Line 37: max → math.max
- Line 40: min → math.min
- Line 57: floor → math.floor
- Line 58: input(type = input.bool) → input.bool()
- Line 59: input(type = input.bool) → input.bool()
- Line 61: input(type = input.bool) → input.bool()
- Line 62: input(type = input.bool) → input.bool()
- Line 63: input(type = input.bool) → input.bool()
- Line 64: input(type = input.bool) → input.bool()
- Line 65: input(type = input.integer) → input.int()
- Line 70: barssince → ta.barssince
- Line 78: barssince → ta.barssince
- Line 86: barssince → ta.barssince
- Line 93: barssince → ta.barssince
- Line 99: barssince → ta.barssince
- Line 105: barssince → ta.barssince
- Line 110: transp = 0 → color.new(color.green, 0)
- Line 111: transp = 0 → color.new(color.red, 0)
- Line 112: transp = 0 → color.new(color.green, 0)
- Line 113: transp = 0 → color.new(color.red, 0)
- Line 114: transp = 0 → color.new(color.green, 0)
- Line 115: transp = 0 → color.new(color.red, 0)
⋯// © greenmask9-//@version=4+//@version=5strategy("Oath", overlay=true)⋯emalength = input(21, title="Short EMA")-emashort = ema(close, emalength)+emashort = ta.ema(close, emalength)// 55 EMAemalength2 = input(55, title="Long EMA")-ema = ema(close, emalength2)+ema = ta.ema(close, emalength2)//CCI calculation and inputs⋯src = input(close, title="Overbought/sold detector source")-ma = sma(src, lengthcci)+ma = ta.sma(src, lengthcci)-ccivalue = (src - ma) / (0.015 * dev(src, lengthcci))+ccivalue = (src - ma) / (0.015 * ta.dev(src, lengthcci))//CCI plotting⋯//Supertrend-length = input(title="ATR Period", type=input.integer, defval=55)+length = input.int(title="ATR Period", defval=55)-mult = input(title="ATR Multiplier", type=input.float, step=0.1, defval=5.0)+mult = input.float(title="ATR Multiplier", step=0.1, defval=5.0)-wicks = input(title="Take Wicks into Account ?", type=input.bool, defval=true)+wicks = input.bool(title="Take Wicks into Account ?", defval=true)-illuminate = input(title="Illuminate Trend", type=input.bool, defval=false)+illuminate = input.bool(title="Illuminate Trend", defval=false)-atr = mult * atr(length)+atr = mult * ta.atr(length)longStop = hl2 - atrlongStopPrev = nz(longStop[1], longStop)-longStop := (wicks ? low[1] : close[1]) > longStopPrev ? max(longStop, longStopPrev) : longStop+longStop := (wicks ? low[1] : close[1]) > longStopPrev ? math.max(longStop, longStopPrev) : longStopshortStop = hl2 + atrshortStopPrev = nz(shortStop[1], shortStop)-shortStop := (wicks ? high[1] : close[1]) < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop+shortStop := (wicks ? high[1] : close[1]) < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStopdir = 1⋯downstoploss = shortStop + spread-ordersize=floor(strategy.initial_capital/close)+ordersize=math.floor(strategy.initial_capital/close)-testlong = input(title="Test longs", type=input.bool, defval=true)+testlong = input.bool(title="Test longs", defval=true)-testshort = input(title="Test shorts", type=input.bool, defval=true)+testshort = input.bool(title="Test shorts", defval=true)//new-degree = input(title="Test level 1 overbought/sold levels", type=input.bool, defval=true)+degree = input.bool(title="Test level 1 overbought/sold levels", defval=true)-degree2 = input(title="Test level 2 overbought/sold levels", type=input.bool, defval=false)+degree2 = input.bool(title="Test level 2 overbought/sold levels", defval=false)-degree3 = input(title="Test level 3 overbought/sold levels", type=input.bool, defval=false)+degree3 = input.bool(title="Test level 3 overbought/sold levels", defval=false)-statictarget = input(title="Use static target", type=input.bool, defval=true)+statictarget = input.bool(title="Use static target", defval=true)-statictargetvalue = input(title="Static target in pips", type=input.integer, defval=400)+statictargetvalue = input.int(title="Static target in pips", defval=400)//timetrade = input(title="Open trades only withing specified time", type=input.bool, defval=true)⋯buy1 = uptrend and upsignal and strategy.opentrades==0 and testlong and degree-x1 = barssince (buy1)+x1 = ta.barssince (buy1)if (buy1)⋯buy2 = uptrend and upsignal2 and strategy.opentrades==0 and testlong and degree2-x2 = barssince (buy2)+x2 = ta.barssince (buy2)if (buy2)⋯buy3 = uptrend and upsignal3 and strategy.opentrades==0 and testlong and degree3-x3 = barssince (buy3)+x3 = ta.barssince (buy3)if (buy3)⋯sell1 = downtrend and downsignal and strategy.opentrades==0 and testshort and degree-y1 = barssince (sell1)+y1 = ta.barssince (sell1)if (sell1)⋯sell2 = downtrend and downsignal2 and strategy.opentrades==0 and testshort and degree2-y2 = barssince (sell2)+y2 = ta.barssince (sell2)if (sell2)⋯sell3 = downtrend and downsignal3 and strategy.opentrades==0 and testshort and degree3-y3 = barssince (sell3)+y3 = ta.barssince (sell3)if (sell3)⋯ strategy.exit( "Oath3 Close", from_entry="Oath3.s" , profit=statictargetvalue,stop=downstoploss[y3])-plotshape(uptrend and upsignal and degree, location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, size=size.tiny, text="Oath up")+plotshape(uptrend and upsignal and degree, location=location.belowbar, color=color.new(color.green, 0), style=shape.triangleup, size=size.tiny, text="Oath up")-plotshape(downtrend and downsignal and degree, location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, size=size.tiny, text="Oath down")+plotshape(downtrend and downsignal and degree, location=location.abovebar, color=color.new(color.red, 0), style=shape.triangledown, size=size.tiny, text="Oath down")-plotshape(uptrend and upsignal2 and degree2, location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, size=size.tiny, text="Oath up+")+plotshape(uptrend and upsignal2 and degree2, location=location.belowbar, color=color.new(color.green, 0), style=shape.triangleup, size=size.tiny, text="Oath up+")-plotshape(downtrend and downsignal2 and degree2, location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, size=size.tiny, text="Oath down+")+plotshape(downtrend and downsignal2 and degree2, location=location.abovebar, color=color.new(color.red, 0), style=shape.triangledown, size=size.tiny, text="Oath down+")-plotshape(uptrend and upsignal3 and degree3, location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, size=size.tiny, text="Oath up++")+plotshape(uptrend and upsignal3 and degree3, location=location.belowbar, color=color.new(color.green, 0), style=shape.triangleup, size=size.tiny, text="Oath up++")-plotshape(downtrend and downsignal3 and degree3, location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, size=size.tiny, text="Oath down++")+plotshape(downtrend and downsignal3 and degree3, location=location.abovebar, color=color.new(color.red, 0), style=shape.triangledown, size=size.tiny, text="Oath down++")Clean v5
VerifiedSame 52 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 6: input() → input.int()
- Line 9: input() → input.int()
- Line 12: input() → input.int()
- Line 13: input() → input.source()
- Line 17: input() → input.int()
- Line 18: input() → input.int()
5 more edits
- Line 19: input() → input.int()
- Line 20: input() → input.int()
- Line 21: input() → input.int()
- Line 22: input() → input.int()
- Line 54: input() → input.float()
⋯// 21 EMA-emalength = input(21, title="Short EMA")+emalength = input.int(21, title="Short EMA")emashort = ta.ema(close, emalength)// 55 EMA-emalength2 = input(55, title="Long EMA")+emalength2 = input.int(55, title="Long EMA")ema = ta.ema(close, emalength2)//CCI calculation and inputs-lengthcci = input(20, minval=1, title="Overbought/sold detector period")+lengthcci = input.int(20, minval=1, title="Overbought/sold detector period")-src = input(close, title="Overbought/sold detector source")+src = input.source(close, title="Overbought/sold detector source")ma = ta.sma(src, lengthcci)⋯//CCI plotting-ccioverbought = input(defval=100, title="Overbought level 1")+ccioverbought = input.int(defval=100, title="Overbought level 1")-ccioverbought2 = input(defval=140, title="Overbought level 2")+ccioverbought2 = input.int(defval=140, title="Overbought level 2")-ccioverbought3 = input(defval=180, title="Overbought level 3")+ccioverbought3 = input.int(defval=180, title="Overbought level 3")-ccioversold = input(defval=-100, title="Oversold level 1")+ccioversold = input.int(defval=-100, title="Oversold level 1")-ccioversold2 = input(defval=-140, title="Oversold level 2")+ccioversold2 = input.int(defval=-140, title="Oversold level 2")-ccioversold3 = input(defval=-180, title="Oversold level 3")+ccioversold3 = input.int(defval=-180, title="Oversold level 3")//cciOB = (ccivalue >= ccioverbought and ccivalue < ccioverbought2)⋯//adapts to the current bar, I need to save the bars number when the condition for buy was true, static number is spread-spread = input (0.00020, title="Spread")+spread = input.float (0.00020, title="Spread")upstoploss = longStop - spread⋯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: 52 before, 45 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.
⋯// © greenmask9-//@version=5+//@version=6strategy("Oath", overlay=true)⋯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 |
|---|---|---|---|
| Short EMA | 21 | int | emashort |
| Long EMA | 55 | int | ema |
| Overbought/sold detector period | 20 | int · min 1 | ma ccivalue |
| Overbought/sold detector source | close | source | ma ccivalue |
| Overbought level 1 | 100 | int | downsignal |
| Overbought level 2 | 140 | int | downsignal downsignal2 |
| Overbought level 3 | 180 | int | downsignal2 downsignal3 |
| Oversold level 1 | -100 | int | upsignal |
| Oversold level 2 | -140 | int | upsignal upsignal2 |
| Oversold level 3 | -180 | int | upsignal2 upsignal3 |
| ATR Period | 55 | int (written input.integer) | atr |
| ATR Multiplier | 5.0 | float · step 0.1 | atr |
| Take Wicks into Account ? | true | bool | longStop shortStop dir |
| Illuminate Trend | false | bool | unused |
| Spread | 0.00020 | float | upstoploss downstoploss |
| Test longs | true | bool | buy1 buy2 buy3 |
| Test shorts | true | bool | sell1 sell2 sell3 |
| Test level 1 overbought/sold levels | true | bool | buy1 sell1 plotshape |
| Test level 2 overbought/sold levels | false | bool | buy2 sell2 plotshape |
| Test level 3 overbought/sold levels | false | bool | buy3 sell3 plotshape |
| Use static target | true | bool | entry Oath1 exit Oath1 Close entry Oath2 exit Oath2 Close entry Oath3 exit Oath3 Close entry Oath1.s exit Oath1 Close entry Oath2.s exit Oath2 Close entry Oath3.s exit Oath3 Close line 73 line 81 line 89 line 95 line 101 line 107 |
| Static target in pips | 400 | int (written input.integer) | exit Oath1 Close exit Oath2 Close exit Oath3 Close |
What it calculates
- EMA (
ema,ta.emain v5)close, Short EMA (21)emashort · line 7 - EMA (
ema,ta.emain v5)close, Long EMA (55)ema · line 10 - SMA (
sma,ta.smain v5)Overbought/sold detector source (close), Overbought/sold detector period (20)ma · line 14 - DEV (
dev,ta.devin v5)Overbought/sold detector source (close), Overbought/sold detector period (20)ccivalue · line 15 - ATR (
atr,ta.atrin v5)ATR Period (55)atr · line 34 - Barssince (
barssince,ta.barssincein v5)buy1x1 · line 70 - Barssince (
barssince,ta.barssincein v5)buy2x2 · line 78 - Barssince (
barssince,ta.barssincein v5)buy3x3 · line 86 - Barssince (
barssince,ta.barssincein v5)sell1y1 · line 93 - Barssince (
barssince,ta.barssincein v5)sell2y2 · line 99 - Barssince (
barssince,ta.barssincein v5)sell3y3 · line 105
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.
The script has 64 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Oath1 long | (statictarget) | On | 74 |
| Exit Oath1 Close stop and limit | (statictarget) | On | 75 |
| Open Oath2 long | (statictarget) | On | 82 |
| Exit Oath2 Close stop and limit | (statictarget) | On | 83 |
| Open Oath3 long | (statictarget) | On | 90 |
| Exit Oath3 Close stop and limit | (statictarget) | On | 91 |
| Open Oath1.s short | (statictarget) | On | 96 |
| Exit Oath1 Close stop and limit | (statictarget) | On | 97 |
| Open Oath2.s short | (statictarget) | On | 102 |
| Exit Oath2 Close stop and limit | (statictarget) | On | 103 |
| Open Oath3.s short | (statictarget) | On | 108 |
| Exit Oath3 Close stop and limit | (statictarget) | On | 109 |
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, and the live replay matched history.
- 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 | +0.2% | +102.5% | 45 | 100% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.3% | +5.5% | 72 | 100% | — | 0.6% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +8.4% | +9.8% | 57 | 100% | — | 6.2% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +6.2% | +8.4% | 32 | 100% | — | 3.4% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −61.7% | +16.7% | 27 | 74% | 0.48 | 110.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +15.6% | +21.5% | 14 | 64% | 1.61 | 16.4% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +10.1% | +148.3% | 38 | 95% | 1.82 | 8.7% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −7.1% | +17.1% | 33 | 76% | 0.68 | 9.8% | 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 | 19 | 100% | $76.00 |
| Sideways market | 12 | 100% | $48.00 |
| Falling market | 14 | 100% | $56.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
0.0%
The 95th percentile of the worst drawdown when the same 45 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 0.0% to 0.0%; the tick is what actually happened, 0.0%. Order luck alone moves it this much.
All 45 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 23 Mar 2024 63,796.60 | 23 Mar 2024 63,800.60 | 0 | $4.00 |
| long | 24 Mar 2024 63,990.00 | 24 Mar 2024 63,994.00 | 0 | $4.00 |
| long | 13 Apr 2024 67,116.50 | 13 Apr 2024 67,120.50 | 0 | $4.00 |
| long | 15 Apr 2024 65,661.90 | 15 Apr 2024 65,665.90 | 0 | $4.00 |
| long | 17 Apr 2024 63,793.40 | 17 Apr 2024 63,797.40 | 0 | $4.00 |
| short | 18 Jul 2024 64,088.00 | 18 Jul 2024 64,084.00 | 0 | $4.00 |
| short | 18 Sep 2024 60,314.00 | 18 Sep 2024 60,310.00 | 0 | $4.00 |
| short | 22 Sep 2024 63,349.00 | 22 Sep 2024 63,345.00 | 0 | $4.00 |
| short | 23 Sep 2024 63,578.80 | 23 Sep 2024 63,574.80 | 0 | $4.00 |
| long | 23 Dec 2024 95,186.30 | 23 Dec 2024 95,190.30 | 0 | $4.00 |
| long | 24 Dec 2024 94,881.50 | 24 Dec 2024 94,885.50 | 0 | $4.00 |
| long | 28 Dec 2024 94,299.00 | 28 Dec 2024 94,303.00 | 0 | $4.00 |
| long | 30 Dec 2024 93,738.20 | 30 Dec 2024 93,742.20 | 0 | $4.00 |
| long | 31 Dec 2024 92,792.10 | 31 Dec 2024 92,796.10 | 0 | $4.00 |
| long | 10 Jan 2025 92,552.50 | 10 Jan 2025 92,556.50 | 0 | $4.00 |
| short | 28 Mar 2025 87,232.00 | 28 Mar 2025 87,228.00 | 0 | $4.00 |
| short | 10 Dec 2025 92,678.80 | 10 Dec 2025 92,674.80 | 0 | $4.00 |
| short | 17 Jan 2026 95,550.90 | 17 Jan 2026 95,546.90 | 0 | $4.00 |
| short | 11 Mar 2026 69,948.60 | 11 Mar 2026 69,944.60 | 0 | $4.00 |
| short | 12 Mar 2026 70,191.90 | 12 Mar 2026 70,187.90 | 0 | $4.00 |
| short | 13 Mar 2026 70,541.30 | 13 Mar 2026 70,537.30 | 0 | $4.00 |
| short | 14 Mar 2026 70,930.00 | 14 Mar 2026 70,926.00 | 0 | $4.00 |
| short | 15 Mar 2026 71,211.90 | 15 Mar 2026 71,207.90 | 0 | $4.00 |
| short | 16 Mar 2026 72,815.30 | 16 Mar 2026 72,811.30 | 0 | $4.00 |
| short | 18 Mar 2026 73,909.40 | 18 Mar 2026 73,905.40 | 0 | $4.00 |
| short | 9 Apr 2026 71,069.90 | 9 Apr 2026 71,065.90 | 0 | $4.00 |
| short | 10 Apr 2026 71,788.00 | 10 Apr 2026 71,784.00 | 0 | $4.00 |
| short | 12 Apr 2026 73,043.20 | 12 Apr 2026 73,039.20 | 0 | $4.00 |
| short | 15 Apr 2026 74,131.60 | 15 Apr 2026 74,127.60 | 0 | $4.00 |
| short | 16 Apr 2026 74,810.00 | 16 Apr 2026 74,806.00 | 0 | $4.00 |
| short | 17 Apr 2026 75,154.30 | 17 Apr 2026 75,150.30 | 0 | $4.00 |
| long | 19 May 2026 77,001.90 | 19 May 2026 77,005.90 | 0 | $4.00 |
| long | 20 May 2026 76,834.40 | 20 May 2026 76,838.40 | 0 | $4.00 |
| long | 27 May 2026 75,930.00 | 27 May 2026 75,934.00 | 0 | $4.00 |
| long | 31 May 2026 73,884.40 | 31 May 2026 73,888.40 | 0 | $4.00 |
| long | 1 Jun 2026 73,674.40 | 1 Jun 2026 73,678.40 | 0 | $4.00 |
| short | 15 Jul 2026 65,044.00 | 15 Jul 2026 65,040.00 | 0 | $4.00 |
| short | 16 Jul 2026 64,756.30 | 16 Jul 2026 64,752.30 | 0 | $4.00 |
| short | 21 Jul 2026 65,255.50 | 21 Jul 2026 65,251.50 | 0 | $4.00 |
| long | 14 Sep 2026 76,842.00 | 14 Sep 2026 76,846.00 | 0 | $4.00 |
| long | 17 Sep 2026 76,206.00 | 17 Sep 2026 76,210.00 | 0 | $4.00 |
| long | 10 Oct 2026 82,635.60 | 10 Oct 2026 82,639.60 | 0 | $4.00 |
| long | 15 Oct 2026 81,682.00 | 15 Oct 2026 81,686.00 | 0 | $4.00 |
| long | 17 Oct 2026 81,615.90 | 17 Oct 2026 81,619.90 | 0 | $4.00 |
| long | 18 Oct 2026 81,491.00 | 18 Oct 2026 81,495.00 | 0 | $4.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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Oath this page | — | v4 strategy | +0.2% | 45 | 0.0% |
| Dazzling Bolts by OrcChieftain | sma ema atr barssince | v4 strategy | +8.5% | 14 | 13.0% |
| ATR with EOM and VORTEX by SoftKill21 | atr ema sma | v4 strategy | +66.2% | 22 | 29.9% |
| cATRpillar Strategy by Obi-wanClintobe | atr sma ema | v4 strategy | +1.02827e+24% | 27 | 88,097.2% |
| Optimized Zhaocaijinbao strategy by fzj20020403 | sma ema atr | v5 strategy | +15.6% | 12 | 9.8% |
| pomila by cryptostartegy | sma atr barssince | v4 strategy | −54.6% | 25 | 86.6% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 27 ms | With a workaround 1,000 bars in 73 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“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/// © greenmask9//@version=4strategy("Oath", overlay=true)// 21 EMAemalength = input(21, title="Short EMA")emashort = ema(close, emalength)// 55 EMAemalength2 = input(55, title="Long EMA")ema = ema(close, emalength2)//CCI calculation and inputslengthcci = input(20, minval=1, title="Overbought/sold detector period")src = input(close, title="Overbought/sold detector source")ma = sma(src, lengthcci)ccivalue = (src - ma) / (0.015 * dev(src, lengthcci))//CCI plottingccioverbought = input(defval=100, title="Overbought level 1")ccioverbought2 = input(defval=140, title="Overbought level 2")ccioverbought3 = input(defval=180, title="Overbought level 3")ccioversold = input(defval=-100, title="Oversold level 1")ccioversold2 = input(defval=-140, title="Oversold level 2")ccioversold3 = input(defval=-180, title="Oversold level 3")//cciOB = (ccivalue >= ccioverbought and ccivalue < ccioverbought2)//cciOS = (ccivalue <= ccioversold and ccivalue > ccioversold2)//cciOB2 = (ccivalue >= ccioverbought2 and ccivalue < ccioverbought3)//cciOS2 = (ccivalue <= ccioversold and ccivalue > ccioversold3)//cciOB3 = (ccivalue >= ccioverbought3)//cciOS3 = (ccivalue <= ccioversold3)//Supertrendlength = input(title="ATR Period", type=input.integer, defval=55)mult = input(title="ATR Multiplier", type=input.float, step=0.1, defval=5.0)wicks = input(title="Take Wicks into Account ?", type=input.bool, defval=true)illuminate = input(title="Illuminate Trend", type=input.bool, defval=false)atr = mult * atr(length)longStop = hl2 - atrlongStopPrev = nz(longStop[1], longStop)longStop := (wicks ? low[1] : close[1]) > longStopPrev ? max(longStop, longStopPrev) : longStopshortStop = hl2 + atrshortStopPrev = nz(shortStop[1], shortStop)shortStop := (wicks ? high[1] : close[1]) < shortStopPrev ? min(shortStop, shortStopPrev) : shortStopdir = 1dir := nz(dir[1], dir)dir := dir == -1 and (wicks ? high : close) > shortStopPrev ? 1 : dir == 1 and (wicks ? low : close) < longStopPrev ? -1 : dir//entriesuptrend = emashort>ema and dir == 1upsignal = ccivalue<=ccioversold and ccivalue>ccioversold2upsignal2 = ccivalue<=ccioversold2 and ccivalue>ccioversold3upsignal3 = ccivalue<=ccioversold3downtrend = emashort<ema and dir == -1downsignal = ccivalue>=ccioverbought and ccivalue<ccioverbought2downsignal2 = ccivalue>=ccioverbought2 and ccivalue<ccioverbought3downsignal3 = ccivalue>=ccioverbought3//adapts to the current bar, I need to save the bars number when the condition for buy was true, static number is spreadspread = input (0.00020, title="Spread")upstoploss = longStop - spreaddownstoploss = shortStop + spreadordersize=floor(strategy.initial_capital/close)testlong = input(title="Test longs", type=input.bool, defval=true)testshort = input(title="Test shorts", type=input.bool, defval=true)//newdegree = input(title="Test level 1 overbought/sold levels", type=input.bool, defval=true)degree2 = input(title="Test level 2 overbought/sold levels", type=input.bool, defval=false)degree3 = input(title="Test level 3 overbought/sold levels", type=input.bool, defval=false)statictarget = input(title="Use static target", type=input.bool, defval=true)statictargetvalue = input(title="Static target in pips", type=input.integer, defval=400)//timetrade = input(title="Open trades only withing specified time", type=input.bool, defval=true)//timtrade = input()//přidat možnost TP podle ATR a sl podle ATRbuy1 = uptrend and upsignal and strategy.opentrades==0 and testlong and degreex1 = barssince (buy1)if (buy1)//bodlo by zakázat atrtarget v tomto případě if (statictarget) strategy.entry("Oath1", strategy.long, ordersize) strategy.exit( "Oath1 Close", from_entry="Oath1" , profit=statictargetvalue,stop=upstoploss[x1]) buy2 = uptrend and upsignal2 and strategy.opentrades==0 and testlong and degree2x2 = barssince (buy2)if (buy2)//bodlo by zakázat atrtarget v tomto případě if (statictarget) strategy.entry("Oath2", strategy.long, ordersize) strategy.exit( "Oath2 Close", from_entry="Oath2" , profit=statictargetvalue,stop=upstoploss[x2]) buy3 = uptrend and upsignal3 and strategy.opentrades==0 and testlong and degree3x3 = barssince (buy3)if (buy3)//bodlo by zakázat atrtarget v tomto případě if (statictarget) strategy.entry("Oath3", strategy.long, ordersize) strategy.exit( "Oath3 Close", from_entry="Oath3" , profit=statictargetvalue,stop=upstoploss[x3])sell1 = downtrend and downsignal and strategy.opentrades==0 and testshort and degreey1 = barssince (sell1)if (sell1) if (statictarget) strategy.entry("Oath1.s", strategy.short, ordersize) strategy.exit( "Oath1 Close", from_entry="Oath1.s" , profit=statictargetvalue,stop=downstoploss[y1])sell2 = downtrend and downsignal2 and strategy.opentrades==0 and testshort and degree2y2 = barssince (sell2)if (sell2) if (statictarget) strategy.entry("Oath2.s", strategy.short, ordersize) strategy.exit( "Oath2 Close", from_entry="Oath2.s" , profit=statictargetvalue,stop=downstoploss[y2])sell3 = downtrend and downsignal3 and strategy.opentrades==0 and testshort and degree3y3 = barssince (sell3)if (sell3) if (statictarget) strategy.entry("Oath3.s", strategy.short, ordersize) strategy.exit( "Oath3 Close", from_entry="Oath3.s" , profit=statictargetvalue,stop=downstoploss[y3])plotshape(uptrend and upsignal and degree, location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, size=size.tiny, text="Oath up")plotshape(downtrend and downsignal and degree, location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, size=size.tiny, text="Oath down")plotshape(uptrend and upsignal2 and degree2, location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, size=size.tiny, text="Oath up+")plotshape(downtrend and downsignal2 and degree2, location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, size=size.tiny, text="Oath down+")plotshape(uptrend and upsignal3 and degree3, location=location.belowbar, color=color.green, transp=0, style=shape.triangleup, size=size.tiny, text="Oath up++")plotshape(downtrend and downsignal3 and degree3, location=location.abovebar, color=color.red, transp=0, style=shape.triangledown, size=size.tiny, text="Oath down++")