Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

SMIO strat

A Pine Script v4 strategy built on TSI (close, 15), EMA (erg, 15) and Crossover (osc, 0). It has 4 order rules, 2 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. 3 settings; defaults include Long Length 35, Short Length 15 and Signal Line Length 15.

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 SMIO strat repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 16 of 16 trades.
How did SMIO strat do on BTCUSDT 1D with default settings?
+49.14%
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 SMIO strat 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 SMIO strat use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does SMIO strat run in Zeal Terminal?
Yes
It compiles in 10 ms and runs 1,000 bars in 22 ms, in the browser.

BTCUSDT · 1D · default settings

  • SMI Ergodic Oscillator
  • 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 (3)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$147,762$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. Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 14, 15) so the engine trades the way the script says.
Net profit
+49.14%
$49,137.50
Buy and hold
+102.5%
same period
Closed trades
45
17 won · 28 lost
Profitable
37.8%
of closed trades
Profit factor
1.42
gross profit ÷ gross loss
Max drawdown
28.08%
−$39,099.10

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.

  • 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

    No slippage

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

  • Note

    Uses an argument v6 removed

    when = on line 14, 15, 16, 17. The upgraded version below moves each call inside an if block.

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 tsi → ta.tsi, ema → ta.ema, crossover → ta.crossover, crossunder → ta.crossunder.
  • 4 strategy calls use the when = argument (line 14, 15, 16, 17). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 8: tsi → ta.tsi
  • Line 9: ema → ta.ema
  • Line 12: crossover → ta.crossover
  • Line 13: crossunder → ta.crossunder
  • Line 14: strategy.entry(…, true) → strategy.entry(…, strategy.long)
  • Line 15: strategy.entry(…, false) → strategy.entry(…, strategy.short)
⋯// © Nico_TM-//@version=4+//@version=5strategy(shorttitle= "MFM", title= "SMIO", overlay=true)⋯siglen = input(15, minval=1, title="Signal Line Length")-erg = tsi(close, shortlen, longlen)+erg = ta.tsi(close, shortlen, longlen)-sig = ema(erg, siglen)+sig = ta.ema(erg, siglen)osc = erg - sigplot(osc, color=#FF8080, style=plot.style_histogram, title="SMI Ergodic Oscillator")-long = crossover(osc, 0)+long = ta.crossover(osc, 0)-short = crossunder(osc, 0)+short = ta.crossunder(osc, 0)-strategy.entry("long", true, when = long)+strategy.entry("long", strategy.long, when = long)-strategy.entry("short", false, when = short)+strategy.entry("short", strategy.short, when = short)strategy.close("long", when = short)⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 5: input() → input.int()
  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 14: when = long → if block
  • Line 15: when = short → if block
  • Line 16: when = short → if block
  • Line 17: when = long → if block
⋯strategy(shorttitle= "MFM", title= "SMIO", overlay=true)-longlen = input(35, minval=1, title="Long Length")+longlen = input.int(35, minval=1, title="Long Length")-shortlen = input(15, minval=1, title="Short Length")+shortlen = input.int(15, minval=1, title="Short Length")-siglen = input(15, minval=1, title="Signal Line Length")+siglen = input.int(15, minval=1, title="Signal Line Length")erg = ta.tsi(close, shortlen, longlen)⋯short = ta.crossunder(osc, 0)-strategy.entry("long", strategy.long, when = long)+if long+    strategy.entry("long", strategy.long)-strategy.entry("short", strategy.short, when = short)+if short+    strategy.entry("short", strategy.short)-strategy.close("long", when = short)+if short+    strategy.close("long")-strategy.close("short", when = long)+if long+    strategy.close("short")start = timestamp(2020, 6, 1, 0, 0)⋯

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: 45 before, 51 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.

⋯// © Nico_TM-//@version=5+//@version=6strategy(shorttitle= "MFM", title= "SMIO", 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
Long Length35int · min 1erg
Short Length15int · min 1erg
Signal Line Length15int · min 1sig

What it calculates

  • TSI (tsi, ta.tsi in v5)close, Short Length (15), Long Length (35)erg · line 8
  • EMA (ema, ta.ema in v5)erg, Signal Line Length (15)sig · line 9
  • Crossover (crossover, ta.crossover in v5)osc, 0long · line 12
  • Crossunder (crossunder, ta.crossunder in v5)osc, 0short · line 13

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 datashortlenShort Lengthsetting · 15longlenLong Lengthsetting · 35siglenSignal Line Lengthsetting · 15ergTSI→ ergsigEMA→ siglongCrossover→ longshortCrossunder→ shortoscoscvalueentry:longOpen longstrategy.entryentry:shortOpen shortstrategy.entryclose:longClose longstrategy.closeclose:shortClose shortstrategy.closeplot:11SMI Ergodic Oscillatorplot

Order rules

OrderFires whenBy defaultLine
Open long longlongOn14
Open short shortshortOn15
Close longshortOn16
Close shortlongOn17

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.

16/16trades 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+49.1%+102.5%4538%1.4228.1%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+12.4%+5.5%4434%1.3211.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+1.4%+9.8%4730%1.212.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.2%+8.4%5028%1.170.3%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.1%+16.7%5137%1.270.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.0%+21.5%4831%0.900.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.6%+148.3%5927%0.641.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.1%+17.1%5431%1.510.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 market1338%$8,703.45
Sideways market1953%$43,035.10
Falling market1315%−$2,601.10

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

How bad could the drawdown be?

37.8%

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, 17.7% to 37.8%; the tick is what actually happened, 21.9%. Order luck alone moves it this much.

0%43%
All 45 trades
SideEntryExitBarsP&L
long16 May 2024 66,206.5013 Jun 2024 68,264.0028$2,057.47
short13 Jun 2024 68,264.0015 Jul 2024 60,797.9032$7,466.07
long15 Jul 2024 60,797.904 Aug 2024 60,698.0020−$99.92
short4 Aug 2024 60,698.0023 Aug 2024 60,375.8019$322.16
long23 Aug 2024 60,375.802 Sep 2024 57,301.8010−$3,074.06
short2 Sep 2024 57,301.8014 Sep 2024 60,498.0012−$3,196.22
long14 Sep 2024 60,498.005 Oct 2024 62,086.0021$1,588.01
short5 Oct 2024 62,086.0015 Oct 2024 66,084.0010−$3,998.00
long15 Oct 2024 66,084.005 Nov 2024 67,850.0021$1,766.01
short5 Nov 2024 67,850.007 Nov 2024 75,572.002−$7,721.98
long7 Nov 2024 75,572.0028 Nov 2024 95,863.1021$20,291.10
short28 Nov 2024 95,863.1018 Jan 2025 104,077.0051−$8,214.36
long18 Jan 2025 104,077.002 Feb 2025 100,636.0015−$3,441.81
short2 Feb 2025 100,636.0018 Mar 2025 84,010.0044$16,625.60
long18 Mar 2025 84,010.007 Apr 2025 78,430.0020−$5,580.02
short7 Apr 2025 78,430.0012 Apr 2025 83,423.805−$4,993.83
long12 Apr 2025 83,423.8029 May 2025 107,782.0047$24,357.90
short29 May 2025 107,782.001 Jul 2025 107,147.0033$635.27
long1 Jul 2025 107,147.002 Jul 2025 105,681.001−$1,465.38
short2 Jul 2025 105,681.003 Jul 2025 108,850.001−$3,168.46
long3 Jul 2025 108,850.0030 Jul 2025 117,951.0027$9,101.16
short30 Jul 2025 117,951.0014 Aug 2025 123,306.0015−$5,355.69
long14 Aug 2025 123,306.0016 Aug 2025 117,342.002−$5,964.40
short16 Aug 2025 117,342.0011 Sep 2025 113,960.0026$3,382.04
long11 Sep 2025 113,960.0026 Sep 2025 108,994.0015−$4,965.51
short26 Sep 2025 108,994.002 Oct 2025 118,595.006−$9,600.50
long2 Oct 2025 118,595.0012 Oct 2025 110,644.0010−$7,950.59
short12 Oct 2025 110,644.003 Dec 2025 91,277.9052$19,366.50
long3 Dec 2025 91,277.9023 Jan 2026 89,559.7051−$1,718.20
short23 Jan 2026 89,559.7023 Feb 2026 67,643.4031$21,916.30
long23 Feb 2026 67,643.4024 Feb 2026 64,656.001−$2,987.38
short24 Feb 2026 64,656.0026 Feb 2026 67,988.002−$3,332.03
long26 Feb 2026 67,988.0029 Mar 2026 66,377.0031−$1,611.00
short29 Mar 2026 66,377.007 Apr 2026 68,853.709−$2,476.62
long7 Apr 2026 68,853.7016 May 2026 79,113.2039$10,259.50
short16 May 2026 79,113.2020 Jun 2026 63,543.9035$15,569.30
long20 Jun 2026 63,543.9026 Jun 2026 59,794.606−$3,749.26
short26 Jun 2026 59,794.603 Jul 2026 61,560.007−$1,765.36
long3 Jul 2026 61,560.002 Aug 2026 62,823.7030$1,263.65
short2 Aug 2026 62,823.706 Aug 2026 64,665.204−$1,841.59
long6 Aug 2026 64,665.2013 Aug 2026 63,480.007−$1,185.25
short13 Aug 2026 63,480.0020 Aug 2026 69,334.807−$5,854.79
long20 Aug 2026 69,334.809 Sep 2026 78,455.8020$9,121.02
short9 Sep 2026 78,455.8023 Sep 2026 86,208.6014−$7,752.77
long23 Sep 2026 86,208.608 Oct 2026 83,321.8015−$2,886.76

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
SMIO strat this page—v4 strategy+49.1%4528.1%
Full Swing Gold Vwap Macd SMO Strategy by exlux99ema tsiv4 strategy−2,062.4%2301.0%
True Strength Index by Zeal Terminaltsi emav5 indicatorindicator
Risk Reduction Ultimate Template by burgercrisistsi emav4 strategyNo trades on this market

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 10 msWith a workaround 1,000 bars in 22 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 14, 15) so the engine trades the way the script says.

“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/// © Nico_TM//@version=4strategy(shorttitle= "MFM", title= "SMIO", overlay=true)longlen = input(35, minval=1, title="Long Length")shortlen = input(15, minval=1, title="Short Length")siglen = input(15, minval=1, title="Signal Line Length")erg = tsi(close, shortlen, longlen)sig = ema(erg, siglen)osc = erg - sigplot(osc, color=#FF8080, style=plot.style_histogram, title="SMI Ergodic Oscillator")long = crossover(osc, 0)short = crossunder(osc, 0)strategy.entry("long", true, when = long)strategy.entry("short", false, when = short)strategy.close("long", when = short)strategy.close("short", when = long)start = timestamp(2020, 6, 1, 0, 0)end = timestamp(2021, 6, 1 ,0, 0)