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
- 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.
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
VerifiedNothing 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| 均线长度 | 24 | int (written input.integer) · min 1 | T3ma rangema |
| 均线源 | close | source | T3ma |
What it calculates
- EMA (
ema,ta.emain v5)src, lenxe1 · line 6 - EMA (
ema,ta.emain v5)xe1, lenxe2 · line 7 - EMA (
ema,ta.emain v5)xe2, lenxe3 · line 8 - EMA (
ema,ta.emain v5)xe3, lenxe4 · line 9 - EMA (
ema,ta.emain v5)xe4, lenxe5 · line 10 - EMA (
ema,ta.emain 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open 多 long | (alertlong) | On | 46 |
| Open 空 short | (alertshort) | On | 48 |
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 | +94.5% | +102.5% | 17 | 47% | 2.25 | 27.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −2.3% | +5.5% | 18 | 33% | 0.93 | 16.9% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +435.3% | +9.8% | 11 | 73% | 5.07 | 32.4% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +1.8% | +8.4% | 20 | 35% | 1.03 | 23.6% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +33.2% | +16.7% | 17 | 47% | 1.22 | 37.6% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +45.4% | +21.5% | 16 | 38% | 2.38 | 17.7% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −48.0% | +148.3% | 21 | 38% | 0.48 | 65.8% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +11.1% | +17.1% | 17 | 47% | 1.39 | 13.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 4 | 0% | −$1,805.32 |
| Sideways market | 10 | 60% | $4,195.00 |
| Falling market | 3 | 67% | $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.
All 17 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 23 Jul 2024 67,532.00 | 12 Aug 2024 58,712.60 | 20 | −$652.98 |
| short | 12 Aug 2024 58,712.60 | 22 Sep 2024 63,349.00 | 41 | −$343.27 |
| long | 22 Sep 2024 63,349.00 | 29 Dec 2024 95,300.00 | 98 | $2,019.35 |
| short | 29 Dec 2024 95,300.00 | 23 Jan 2025 103,707.00 | 25 | −$531.31 |
| long | 23 Jan 2025 103,707.00 | 10 Feb 2025 96,462.80 | 18 | −$383.60 |
| short | 10 Feb 2025 96,462.80 | 22 Apr 2025 87,516.20 | 71 | $473.76 |
| long | 22 Apr 2025 87,516.20 | 19 Jun 2025 104,887.00 | 58 | $1,107.93 |
| short | 19 Jun 2025 104,887.00 | 11 Jul 2025 116,010.00 | 22 | −$709.46 |
| long | 11 Jul 2025 116,010.00 | 22 Aug 2025 112,500.00 | 42 | −$180.94 |
| short | 22 Aug 2025 112,500.00 | 20 Sep 2025 115,632.00 | 29 | −$161.48 |
| long | 20 Sep 2025 115,632.00 | 20 Oct 2025 108,643.00 | 30 | −$340.80 |
| short | 20 Oct 2025 108,643.00 | 5 Jan 2026 91,529.70 | 77 | $834.40 |
| long | 5 Jan 2026 91,529.70 | 31 Jan 2026 84,260.50 | 26 | −$486.97 |
| short | 31 Jan 2026 84,260.50 | 16 Mar 2026 72,815.30 | 44 | $766.72 |
| long | 16 Mar 2026 72,815.30 | 27 May 2026 75,930.00 | 72 | $274.25 |
| short | 27 May 2026 75,930.00 | 16 Jul 2026 64,756.30 | 50 | $983.84 |
| long | 16 Jul 2026 64,756.30 | 19 Oct 2026 82,116.00 | 95 | $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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| T3MA_KC_7ye Strategy this page | — | v4 strategy | +94.5% | 17 | 27.4% |
| EMA Slope AyE by fajardoarelys | ema | v4 strategy | No trades on this market | ||
| ROoT by realisticDove62527 | ema | v5 strategy | −4.7% | 225 | 9.4% |
| sachin5986 by mohitesachin78 | ema | v4 strategy | +32.1% | 35 | 17.6% |
| sonu1997 by Sonu1997 | ema | v4 strategy | +960.7% | 2 | 1,103.8% |
| Moving Average Crossover by Muh4mm4d | ema | v4 strategy | +19,990.1% | 30 | 1,274.2% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 15 ms | Yes 1,000 bars in 43 ms | Not measured |
| PineTS | No 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)