Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

T3MA_KC_7ye Strategy

A Pine Script v4 strategy built on EMA (src, len). It has 2 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 commits 100% of equity and pays no commission. 2 settings; defaults include 均线长度 24 and 均线源 close.

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 T3MA_KC_7ye Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 5 of 5 trades.
How did T3MA_KC_7ye Strategy do on BTCUSDT 1D with default settings?
+94.51%
From 26 Jan 2024 to 21 Oct 2026, over 17 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can T3MA_KC_7ye Strategy 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 T3MA_KC_7ye Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does T3MA_KC_7ye Strategy run in Zeal Terminal?
Yes
It compiles in 15 ms and runs 1,000 bars in 43 ms, in the browser.

BTCUSDT · 1D · default settings

  • T3均线
  • KC通道上沿
  • KC通道下沿
  • 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 (2)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$9,419$10,126Equity from $5,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
+94.51%
$4,725.44
Buy and hold
+102.5%
same period
Closed trades
17
8 won · 9 lost
Profitable
47.1%
of closed trades
Profit factor
2.25
gross profit ÷ gross loss
Max drawdown
27.44%
−$1,770.91

One run with the author's default settings, $5,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.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • 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 33

    transp = on line 33, 44. 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.

v4 → v5

VerifiedDownload the v5 script

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

  • Line 3: //@version=4 → //@version=5
  • Line 6: ema → ta.ema
  • Line 7: ema → ta.ema
  • Line 8: ema → ta.ema
  • Line 9: ema → ta.ema
  • Line 10: ema → ta.ema
6 more edits
  • Line 11: ema → ta.ema
  • Line 19: input(type = input.integer) → input.int()
  • Line 20: input(type = input.source) → input.source()
  • Line 24: range is reserved in v5: renamed range_
  • Line 33: transp = 95 → color.new(#0094FF, 95)
  • Line 44: transp = 20 → color.new(alertshort ? color.red : alertlong?color.lime:na, 20)
⋯// © Trader_7ye-//@version=4+//@version=5strategy(title="Trader_7ye_ETH_30M_T3ma Strategy", shorttitle="Trader_7ye_ETH_30M_T3ma  Strategy",max_bars_back=500,overlay=true,default_qty_type=strategy.percent_of_equity,default_qty_value=100,initial_capital=5000,currency=currency.USD)t3(src,len)=>-    xe1 = ema(src, len)+    xe1 = ta.ema(src, len)-    xe2 = ema(xe1, len)+    xe2 = ta.ema(xe1, len)-    xe3 = ema(xe2, len)+    xe3 = ta.ema(xe2, len)-    xe4 = ema(xe3, len)+    xe4 = ta.ema(xe3, len)-    xe5 = ema(xe4, len)+    xe5 = ta.ema(xe4, len)-    xe6 = ema(xe5, len)+    xe6 = ta.ema(xe5, len)    b = 0.7⋯    -Length = input(title="均线长度", type=input.integer, defval=24, minval=1)+Length = input.int(title="均线长度", defval=24, minval=1)-xPrice = input(title="均线源", type=input.source, defval=close)+xPrice = input.source(title="均线源", defval=close)T3ma=t3(xPrice,Length)⋯downCol = T3ma < T3ma[1]-range= high - low+range_= high - low-rangema=t3(range,Length)+rangema=t3(range_,Length)upper = T3ma + rangema⋯l = plot(lower, color=#0094FF, title="KC通道下沿")-fill(u, l, color=#0094FF, transp=95, title="背景")+fill(u, l, color=color.new(#0094FF, 95), title="背景")buySignal = upCol and ohlc4>upper⋯alertshort= direction!=direction[1] and direction==-1-bgcolor(alertshort ? color.red : alertlong?color.lime:na, transp=20)+bgcolor(color.new(alertshort ? color.red : alertlong?color.lime:na, 20))if (alertlong)⋯

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: 17 before, 11 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.

⋯// © Trader_7ye-//@version=5+//@version=6strategy(title="Trader_7ye_ETH_30M_T3ma Strategy", shorttitle="Trader_7ye_ETH_30M_T3ma  Strategy",max_bars_back=500,overlay=true,default_qty_type=strategy.percent_of_equity,default_qty_value=100,initial_capital=5000,currency=currency.USD)⋯

Settings

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

SettingDefaultType and rangeFeeds
均线长度24int (written input.integer) · min 1T3ma rangema
均线源closesourceT3ma

What it calculates

  • EMA (ema, ta.ema in v5)src, lenxe1 · line 6
  • EMA (ema, ta.ema in v5)xe1, lenxe2 · line 7
  • EMA (ema, ta.ema in v5)xe2, lenxe3 · line 8
  • EMA (ema, ta.ema in v5)xe3, lenxe4 · line 9
  • EMA (ema, ta.ema in v5)xe4, lenxe5 · line 10
  • EMA (ema, ta.ema in v5)xe5, lenxe6 · line 11

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 dataLength均线长度setting · 24lowlowprice datahighhighprice dataohlc4ohlc4price dataxe1EMA→ xe1xe2EMA→ xe2xe3EMA→ xe3xe4EMA→ xe4xe5EMA→ xe5xe6EMA→ xe6c1, c2, c3, c4c1 · c2 +24 valuesT3maT3mavaluerangerangevaluerangemarangemavalueupper, lowerupper · lower2 valuesdirectiondirectionvaluealertlongalertlongconditionalertshortalertshortconditionupCol, downColupCol · downCol2 conditionsbuySignalbuySignalconditionsellSignalsellSignalconditionmyColor, c, macolorColourmyColor · c +1entry:多Open 多strategy.entryentry:空Open 空strategy.entryplot:29T3均线plotplot:31KC通道上沿plotplot:32KC通道下沿plotfill:背景背景fillbgcolor:44bgcolorbgcolor

Order rules

OrderFires whenBy defaultLine
Open 多 long(alertlong)On46
Open 空 short(alertshort)On48

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.

5/5trades 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+94.5%+102.5%1747%2.2527.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−2.3%+5.5%1833%0.9316.9%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+435.3%+9.8%1173%5.0732.4%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+1.8%+8.4%2035%1.0323.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+33.2%+16.7%1747%1.2237.6%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+45.4%+21.5%1638%2.3817.7%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−48.0%+148.3%2138%0.4865.8%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+11.1%+17.1%1747%1.3913.5%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 market40%−$1,805.32
Sideways market1060%$4,195.00
Falling market367%$2,335.76

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

How bad could the drawdown be?

38.4%

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

0%44%
All 17 trades
SideEntryExitBarsP&L
long23 Jul 2024 67,532.0012 Aug 2024 58,712.6020−$652.98
short12 Aug 2024 58,712.6022 Sep 2024 63,349.0041−$343.27
long22 Sep 2024 63,349.0029 Dec 2024 95,300.0098$2,019.35
short29 Dec 2024 95,300.0023 Jan 2025 103,707.0025−$531.31
long23 Jan 2025 103,707.0010 Feb 2025 96,462.8018−$383.60
short10 Feb 2025 96,462.8022 Apr 2025 87,516.2071$473.76
long22 Apr 2025 87,516.2019 Jun 2025 104,887.0058$1,107.93
short19 Jun 2025 104,887.0011 Jul 2025 116,010.0022−$709.46
long11 Jul 2025 116,010.0022 Aug 2025 112,500.0042−$180.94
short22 Aug 2025 112,500.0020 Sep 2025 115,632.0029−$161.48
long20 Sep 2025 115,632.0020 Oct 2025 108,643.0030−$340.80
short20 Oct 2025 108,643.005 Jan 2026 91,529.7077$834.40
long5 Jan 2026 91,529.7031 Jan 2026 84,260.5026−$486.97
short31 Jan 2026 84,260.5016 Mar 2026 72,815.3044$766.72
long16 Mar 2026 72,815.3027 May 2026 75,930.0072$274.25
short27 May 2026 75,930.0016 Jul 2026 64,756.3050$983.84
long16 Jul 2026 64,756.3019 Oct 2026 82,116.0095$2,056.01

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
T3MA_KC_7ye Strategy this page—v4 strategy+94.5%1727.4%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 15 msYes 1,000 bars in 43 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/// © Trader_7ye//@version=4strategy(title="Trader_7ye_ETH_30M_T3ma Strategy", shorttitle="Trader_7ye_ETH_30M_T3ma  Strategy",max_bars_back=500,overlay=true,default_qty_type=strategy.percent_of_equity,default_qty_value=100,initial_capital=5000,currency=currency.USD)t3(src,len)=>    xe1 = ema(src, len)    xe2 = ema(xe1, len)    xe3 = ema(xe2, len)    xe4 = ema(xe3, len)    xe5 = ema(xe4, len)    xe6 = ema(xe5, len)    b = 0.7    c1 = -b*b*b    c2 = 3*b*b+3*b*b*b    c3 = -6*b*b-3*b-3*b*b*b    c4 = 1+3*b+b*b*b+3*b*b    c1 * xe6 + c2 * xe5 + c3 * xe4 + c4 * xe3    Length = input(title="均线长度", type=input.integer, defval=24, minval=1)xPrice = input(title="均线源", type=input.source, defval=close)T3ma=t3(xPrice,Length)upCol = T3ma > T3ma[1] downCol = T3ma < T3ma[1]range= high - lowrangema=t3(range,Length)upper = T3ma + rangemalower = T3ma - rangemamyColor = upCol ? color.lime : downCol ? color.red : naplot(T3ma, color=myColor, title="T3均线")c = color.blueu = plot(upper, color=#0094FF, title="KC通道上沿")l = plot(lower, color=#0094FF, title="KC通道下沿")fill(u, l, color=#0094FF, transp=95, title="背景")buySignal = upCol and ohlc4>uppersellSignal= downCol and ohlc4<lower//=======输出======= //多空颜色判断direction=0direction:=buySignal?1:sellSignal?-1:direction[1]macolor=direction==1?color.green:color.red//多信号处理为一个信号alertlong = direction!=direction[1] and direction== 1alertshort= direction!=direction[1] and direction==-1bgcolor(alertshort ? color.red : alertlong?color.lime:na, transp=20)if (alertlong)    strategy.entry("多", strategy.long)if (alertshort)    strategy.entry("空",strategy.short)