Pine Script v5 · Strategy
STR-EMA Oscilator [Azzrael]
A Pine Script v5 strategy built on EMA (close, 200), Stdev (v, 200) and Crossunder or Crossover (v, dev_limit). It has 3 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 30% of equity and pays 0.1% commission. 5 settings; defaults include Period 200 and Factor 1.7.
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 STR-EMA Oscilator [Azzrael] repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: the script acts only when barstate.isconfirmed is true, which Zeal Terminal's engine never reports during a live replay (it does not run a bar's closing update in live mode), so the replay cannot test this script.
- How did STR-EMA Oscilator [Azzrael] do on BTCUSDT 1D with default settings?
- +2.28%
- 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 STR-EMA Oscilator [Azzrael] 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 STR-EMA Oscilator [Azzrael] use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does STR-EMA Oscilator [Azzrael] run in Zeal Terminal?
- Yes
- It compiles in 21 ms and runs 1,000 bars in 53 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Plot
- HLine
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +2.28%
- $22.83
- Buy and hold
- +102.5%
- same period
- Closed trades
- 6
- 3 won · 3 lost
- Profitable
- 50.0%
- of closed trades
- Profit factor
- 1.25
- gross profit ÷ gross loss
- Max drawdown
- 30.58%
- −$305.80
One run with the author's default settings, $1,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 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.
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 |
|---|---|---|---|
| Period | 200 | int · min 2 · step 10 | v dev |
| Factor | 1.7 | float · min 1 · max 10 · step 0.1 | dev_limit |
| Model | Buy on enter to OverSell | string · options ["Buy on enter to OverSell", "Buy on enter to OverBuy"] | k cond_long sig_col |
| Backtest period | |||
| Start | timestamp('01 January 2001 00:00 +0000') | time | bar_in_period |
| Finish | timestamp('01 January 2030 00:00 +0000') | time | bar_in_period close_all last line 44 |
What it calculates
- EMAclose, Period (200)
v · line 26 - Stdevv, Period (200)
dev · line 27 - Crossunder / Crossoverv, dev_limit · chosen by Model
cond_long · line 30
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_name long | cond_long | On | 41 |
| Close s | cond_close and strategy.position_size > 0 | On | 43 |
| Close last | time >= dt_end or barstate.islastconfirmedhistory | On | 45 |
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 | +2.3% | +102.5% | 6 | 50% | 1.25 | 30.6% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +36.0% | +9.8% | 5 | 100% | — | 30.4% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.0% | +8.4% | 0 | 0% | 0.00 | 1.5% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −20.2% | +16.7% | 4 | 25% | 0.31 | 48.8% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +23.8% | +148.3% | 4 | 100% | — | 3.8% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 0.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 0 | — | $0.00 |
| Sideways market | 3 | 100% | $115.42 |
| Falling market | 3 | 0% | −$92.59 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
9.1%
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, 4.0% to 9.1%; the tick is what actually happened, 9.1%. Order luck alone moves it this much.
All 6 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 15 Nov 2025 94,594.00 | 11 May 2026 82,210.10 | 177 | −$39.80 |
| long | 17 Nov 2025 94,261.40 | 11 May 2026 82,210.10 | 175 | −$38.83 |
| long | 2 Dec 2025 86,286.00 | 11 May 2026 82,210.10 | 160 | −$13.97 |
| long | 3 Jun 2026 66,760.80 | 21 Aug 2026 73,027.00 | 79 | $24.96 |
| long | 9 Jul 2026 62,290.00 | 21 Aug 2026 73,027.00 | 43 | $45.34 |
| long | 14 Jul 2026 62,334.50 | 21 Aug 2026 73,027.00 | 38 | $45.13 |
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 |
|---|---|---|---|---|---|
| STR-EMA Oscilator [Azzrael] this page | — | v5 strategy | +2.3% | 6 | 30.6% |
| Galileo Galilei by armigoldman | ema cross | v4 strategy | +16.9% | 61 | 42.2% |
| Escaping of Rate from Avarage By Mustafa OZVER Strategy by Mustafaozver | stdev ema | v4 strategy | +122.0% | 96 | 79.1% |
| Bollinger Band with Fib Golden Ratio (0.618) by mohanee | stdev ema | v4 strategy | No trades on this market | ||
| Volume Weighted Bollinger Bands Strategy by Ankit_1618 | ema stdev | v4 strategy | +10.0% | 15 | 27.5% |
| BB21_MA200_Strategy by mohanee | ema stdev | v4 strategy | No trades on this market | ||
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.
- No v6-only features. v6 is not needed to run this script.
Clean v5
VerifiedNothing to change.
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.
⋯// Exit - crossing zero of (EMA - close)-//@version=5+//@version=6strategy("STR:EMA Oscilator [Azzrael]", overlay=false, ⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 21 ms | With a workaround 1,000 bars in 53 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
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/// © Azzrael// Based on EMA and EMA Oscilator https://www.tradingview.com/script/qM9wm0PW-EMA-Oscilator-Azzrael/// (EMA - close) + Std Dev + Factor = detecting oversell/overbuy// Long only!// Pyramiding - sometimes, depends on ...// There 2 enter strategies in one script // 1 - Classic, buy on entering to OverSell zone (more profitable ~> 70%)// 2 - Crazy, buy on entering to OverBuy zone (catching trend and pyramiding, more net profit)// Exit - crossing zero of (EMA - close)//@version=5strategy("STR:EMA Oscilator [Azzrael]", overlay=false, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=30, pyramiding=3, commission_type=strategy.commission.percent, commission_value=0.1 )ema_length = input.int(200, "Period", minval=2, step=10)limit = input.float(1.7, "Factor", minval=1, step=0.1, maxval=10)dno = input.string(defval="Buy on enter to OverSell", title="Model", options=["Buy on enter to OverSell", "Buy on enter to OverBuy"]) == "Buy on enter to OverSell"dt_start = input.time(defval=timestamp('01 January 2001 00:00 +0000'), title='Start', group ="Backtest period")dt_end = input.time(defval=timestamp('01 January 2030 00:00 +0000'), title='Finish', group ="Backtest period")bar_in_period = time >= dt_start and time <= dt_endv = close - ta.ema(close, ema_length)dev = ta.stdev(v, ema_length)k = dno ? -1 : 1dev_limit = k*dev*limitcond_long = barstate.isconfirmed and bar_in_period and (dno ? ta.crossunder(v, dev_limit) : ta.crossover(v, dev_limit))cond_close = barstate.isconfirmed and bar_in_period and ta.cross(v, 0) // dev visualizationsig_col = (dno and v <= dev_limit) or (not dno and v >= dev_limit) ? color.green : color.new(color.blue, 80)plot(dev_limit, color=color.green)plot(k*dev, color=color.new(color.blue, 60))plot(v, color=sig_col )hline(0)// Make love not warif cond_long entry_name="b" + str.tostring(strategy.opentrades) strategy.entry(entry_name, strategy.long)if cond_close and strategy.position_size > 0 strategy.close_all("s")if time >= dt_end or barstate.islastconfirmedhistory strategy.close_all("last")