Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Ichimoku with MACD- CMF- TSI

A Pine Script v4 strategy built on SMA or EMA (close, 17), EMA (close, 8) and Change (price). 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. 16 settings; defaults include Tenkan-Sen Bars 10, Kijun-Sen Bars 30 and Senkou-Span B Bars 52.

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

BTCUSDT · 1D · default settings

  • 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 (16)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$143,994$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. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference.
Net profit
+28.62%
$28,615.50
Buy and hold
+102.5%
same period
Closed trades
14
6 won · 8 lost
Profitable
42.9%
of closed trades
Profit factor
1.60
gross profit ÷ gross loss
Max drawdown
38.74%
−$38,743.10

One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A long 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 57, 58, 59, 60. 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 avg → math.avg, lowest → ta.lowest, highest → ta.highest, max → math.max, min → math.min, sma → ta.sma, ema → ta.ema, mom → ta.mom, sum → math.sum, change → ta.change, abs → math.abs.
  • 4 strategy calls use the when = argument (line 57, 58, 59, 60). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 13: avg → math.avg
  • Line 13: lowest → ta.lowest
  • Line 13: highest → ta.highest
  • Line 17: avg → math.avg
  • Line 19: max → math.max
23 more edits
  • Line 20: min → math.min
  • Line 22: input(type = input.integer) → input.int()
  • Line 23: input(type = input.integer) → input.int()
  • Line 24: input(type = input.source) → input.source()
  • Line 25: input(type = input.integer) → input.int()
  • Line 26: input(type = input.bool) → input.bool()
  • Line 27: input(type = input.bool) → input.bool()
  • Line 29: sma → ta.sma
  • Line 29: ema → ta.ema
  • Line 30: sma → ta.sma
  • Line 30: ema → ta.ema
  • Line 32: sma → ta.sma
  • Line 32: ema → ta.ema
  • Line 36: mom → ta.mom
  • Line 37: mom → ta.mom
  • Line 43: sum → math.sum
  • Line 43: sum → math.sum
  • Line 45: input(type = input.integer) → input.int()
  • Line 46: input(type = input.integer) → input.int()
  • Line 49: ema → ta.ema
  • Line 50: ema → ta.ema
  • Line 51: change → ta.change
  • Line 53: abs → math.abs
⋯// © exlux99-//@version=4+//@version=5strategy("Ichimoku with MACD/ CMF/ TSI", overlay=true, margin_long=0, margin_short=0)⋯short_entry = input(true, title="Short Entry")-middle(len) => avg(lowest(len), highest(len))+middle(len) => math.avg(ta.lowest(len), ta.highest(len))// Ichimoku Components⋯kijun = middle(ks_bars)-senkouA = avg(tenkan, kijun)+senkouA = math.avg(tenkan, kijun)senkouB = middle(ssb_bars)-ss_high = max(senkouA[ss_offset-1], senkouB[ss_offset-1])+ss_high = math.max(senkouA[ss_offset-1], senkouB[ss_offset-1])-ss_low = min(senkouA[ss_offset-1], senkouB[ss_offset-1])+ss_low = math.min(senkouA[ss_offset-1], senkouB[ss_offset-1])// Entry/Exit Signals-fast_length = input(title="Fast Length", type=input.integer, defval=17)+fast_length = input.int(title="Fast Length", defval=17)-slow_length = input(title="Slow Length", type=input.integer, defval=28)+slow_length = input.int(title="Slow Length", defval=28)-src = input(title="Source", type=input.source, defval=close)+src = input.source(title="Source", defval=close)-signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 5)+signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 5)-sma_source = input(title="Simple MA(Oscillator)", type=input.bool, defval=true)+sma_source = input.bool(title="Simple MA(Oscillator)", defval=true)-sma_signal = input(title="Simple MA(Signal Line)", type=input.bool, defval=true)+sma_signal = input.bool(title="Simple MA(Signal Line)", defval=true)// Calculating-fast_ma = sma_source ? sma(src, fast_length) : ema(src, fast_length)+fast_ma = sma_source ? ta.sma(src, fast_length) : ta.ema(src, fast_length)-slow_ma = sma_source ? sma(src, slow_length) : ema(src, slow_length)+slow_ma = sma_source ? ta.sma(src, slow_length) : ta.ema(src, slow_length)macd = fast_ma - slow_ma-signal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)+signal = sma_signal ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)hist = macd - signal⋯tk_cross_bear = tenkan < kijun-cs_cross_bull = mom(close, cs_offset-1) > 0+cs_cross_bull = ta.mom(close, cs_offset-1) > 0-cs_cross_bear = mom(close, cs_offset-1) < 0+cs_cross_bear = ta.mom(close, cs_offset-1) < 0price_above_kumo = close > ss_high⋯ad = close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volume-mf = sum(ad, lengthA) / sum(volume, lengthA)+mf = math.sum(ad, lengthA) / math.sum(volume, lengthA)//TSI-long = input(title="Long Length", type=input.integer, defval=8)+long = input.int(title="Long Length", defval=8)-short = input(title="Short Length", type=input.integer, defval=8)+short = input.int(title="Short Length", defval=8)price = closedouble_smooth(src, long, short) =>-    fist_smooth = ema(src, long)+    fist_smooth = ta.ema(src, long)-    ema(fist_smooth, short)+    ta.ema(fist_smooth, short)-pc = change(price)+pc = ta.change(price)double_smoothed_pc = double_smooth(pc, long, short)-double_smoothed_abs_pc = double_smooth(abs(pc), long, short)+double_smoothed_abs_pc = double_smooth(math.abs(pc), long, short)tsi_value = 100 * (double_smoothed_pc / double_smoothed_abs_pc)⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
  • Line 9: input() → input.int()
  • Line 10: input() → input.int()
  • Line 11: input() → input.bool()
6 more edits
  • Line 12: input() → input.bool()
  • Line 41: input() → input.int()
  • Line 57: when = bullish and long_entry → if block
  • Line 58: when = bearish and short_entry → if block
  • Line 59: when = bearish and not short_entry → if block
  • Line 60: when = bullish and not long_entry → if block
⋯//Inputs-ts_bars = input(10, minval=1, title="Tenkan-Sen Bars")+ts_bars = input.int(10, minval=1, title="Tenkan-Sen Bars")-ks_bars = input(30, minval=1, title="Kijun-Sen Bars")+ks_bars = input.int(30, minval=1, title="Kijun-Sen Bars")-ssb_bars = input(52, minval=1, title="Senkou-Span B Bars")+ssb_bars = input.int(52, minval=1, title="Senkou-Span B Bars")-cs_offset = input(26, minval=1, title="Chikou-Span Offset")+cs_offset = input.int(26, minval=1, title="Chikou-Span Offset")-ss_offset = input(26, minval=1, title="Senkou-Span Offset")+ss_offset = input.int(26, minval=1, title="Senkou-Span Offset")-long_entry = input(true, title="Long Entry")+long_entry = input.bool(true, title="Long Entry")-short_entry = input(true, title="Short Entry")+short_entry = input.bool(true, title="Short Entry")middle(len) => math.avg(ta.lowest(len), ta.highest(len))⋯//CMF-lengthA = input(8, minval=1, title="CMF Length")+lengthA = input.int(8, minval=1, title="CMF Length")ad = close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volume⋯bearish = tk_cross_bear and cs_cross_bear and price_below_kumo and hist < 0  and mf < -0.1 and tsi_value < 0-strategy.entry("Long", strategy.long, when=bullish and long_entry)+if bullish and long_entry+    strategy.entry("Long", strategy.long)-strategy.entry("Short", strategy.short, when=bearish and short_entry)+if bearish and short_entry+    strategy.entry("Short", strategy.short)-strategy.close("Long", when=bearish and not short_entry)+if bearish and not short_entry+    strategy.close("Long")-strategy.close("Short", when=bullish and not long_entry)+if bullish and not long_entry+    strategy.close("Short")

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

⋯// © exlux99-//@version=5+//@version=6strategy("Ichimoku with MACD/ CMF/ TSI", overlay=true, margin_long=0, margin_short=0)⋯

Settings

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

SettingDefaultType and rangeFeeds
Tenkan-Sen Bars10int · min 1tenkan
Kijun-Sen Bars30int · min 1kijun
Senkou-Span B Bars52int · min 1senkouB
Chikou-Span Offset26int · min 1cs_cross_bull cs_cross_bear
Senkou-Span Offset26int · min 1ss_high ss_low
Long Entrytrueboolentry Long close Short
Short Entrytrueboolentry Short close Long
Fast Length17int (written input.integer)fast_ma
Slow Length28int (written input.integer)slow_ma
Sourceclosesourcefast_ma slow_ma fist_smooth
Signal Smoothing5int (written input.integer) · min 1 · max 50signal
Simple MA(Oscillator)trueboolfast_ma slow_ma
Simple MA(Signal Line)trueboolsignal
CMF Length8int · min 1mf
Long Length8int (written input.integer)fist_smooth double_smoothed_pc double_smoothed_abs_pc
Short Length8int (written input.integer)double_smoothed_pc double_smoothed_abs_pc line 50

What it calculates

  • SMA / EMA (sma, ta.sma in v5)Source (close), Fast Length (17)fast_ma · line 29
  • SMA / EMA (sma, ta.sma in v5)Source (close), Slow Length (28)slow_ma · line 30
  • SMA / EMA (sma, ta.sma in v5)macd, Signal Smoothing (5)signal · line 32
  • EMA (ema, ta.ema in v5)Source (close), Long Length (8)fist_smooth · line 49
  • Change (change, ta.change in v5)pricepc · line 51

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 datafast_lengthFast Lengthsetting · 17slow_lengthSlow Lengthsetting · 28signal_lengthSignal Smoothingsetting · 5longLong Lengthsetting · 8ts_barsTenkan-Sen Barssetting · 10ks_barsKijun-Sen Barssetting · 30ssb_barsSenkou-Span B Barssetting · 52ss_offsetSenkou-Span Offsetsetting · 26volumevolumeprice datalowlowprice datahighhighprice datalengthACMF Lengthsetting · 8shortShort Lengthsetting · 8cs_offsetChikou-Span Offsetsetting · 26fast_maSMA / EMA→ fast_maslow_maSMA / EMA→ slow_masignalSMA / EMA→ signalfist_smoothEMA→ fist_smoothpcChange→ pctenkantenkanvaluekijunkijunvaluesenkouAsenkouAvaluesenkouBsenkouBvaluess_high, ss_lowss_high · ss_low2 valuesmacdmacdvaluehisthistvalueadadvaluemfmfvaluepricepricevaluedouble_smoothed_pc, double_smoothed_abs_pcdouble_smoothed_pc · do…2 valuestsi_valuetsi_valuevaluetk_cross_bull, tk_cross_beartk_cross_bull · tk_cros…2 conditionscs_cross_bull, cs_cross_bearcs_cross_bull · cs_cros…2 conditionsprice_above_kumo, price_below_kumoprice_above_kumo · pric…2 conditionsbullishbullishconditionbearishbearishconditionentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryclose:LongClose Longstrategy.closeclose:ShortClose Shortstrategy.close

Order rules

OrderFires whenBy defaultLine
Open Long longbullish and long_entryOn57
Open Short shortbearish and short_entryOn58
Close Longbearish and not short_entryOn59
Close Shortbullish and not long_entryOn60

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.

4/4trades 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+28.6%+102.5%1443%1.6038.7%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+20.9%+5.5%1155%3.567.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−0.1%+9.8%1540%0.983.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.7%+8.4%1145%2.300.3%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.1%+16.7%1050%2.300.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%1155%4.250.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.1%+148.3%1040%0.810.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%1040%1.200.2%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 market30%−$18,566.60
Sideways market863%$45,755.10
Falling market333%$1,427.03

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

How bad could the drawdown be?

34.5%

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

0%40%
All 14 trades
SideEntryExitBarsP&L
long12 Apr 2024 70,006.201 May 2024 60,672.0019−$9,334.21
short1 May 2024 60,672.0018 May 2024 67,024.0017−$6,351.99
long18 May 2024 67,024.0022 Jun 2024 64,143.6035−$2,880.44
short22 Jun 2024 64,143.6020 Jul 2024 66,660.0028−$2,516.45
long20 Jul 2024 66,660.0019 Aug 2024 58,427.3030−$8,232.66
short19 Aug 2024 58,427.3021 Sep 2024 63,201.1033−$4,773.70
long21 Sep 2024 63,201.109 Feb 2025 96,444.80141$33,243.70
short9 Feb 2025 96,444.8023 Apr 2025 93,443.0073$3,001.76
long23 Apr 2025 93,443.0022 Oct 2025 108,298.00182$14,854.70
short22 Oct 2025 108,298.0015 Jan 2026 96,951.8085$11,345.90
long15 Jan 2026 96,951.8026 Jan 2026 86,670.4011−$10,281.40
short26 Jan 2026 86,670.4018 Apr 2026 77,072.0082$9,598.35
long18 Apr 2026 77,072.001 Jun 2026 73,674.4044−$3,397.62
short1 Jun 2026 73,674.4020 Aug 2026 69,334.8080$4,339.61

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
Ichimoku with MACD- CMF- TSI this page—v4 strategy+28.6%1438.7%
MACD Long Strat by TheGrindTodayema smav4 strategy+24.0%7920.1%
Stock trending strategy by exlux99ema smav4 strategy+35.3%2114.7%
4-Hour Stochastic EMA Trend by slymnturkogluema smav4 strategyNo trades on this market
4X EMA and volume strategy by SoftKill21ema smav4 strategy+1.8%325.8%
Simple Momentum Strategy Based on SMA, EMA and Volume by slip_streamsma emav4 strategy+7.4%1827.4%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 13 msYes 1,000 bars in 59 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/// © exlux99//@version=4strategy("Ichimoku with MACD/ CMF/ TSI", overlay=true, margin_long=0, margin_short=0)//Inputsts_bars = input(10, minval=1, title="Tenkan-Sen Bars")ks_bars = input(30, minval=1, title="Kijun-Sen Bars")ssb_bars = input(52, minval=1, title="Senkou-Span B Bars")cs_offset = input(26, minval=1, title="Chikou-Span Offset")ss_offset = input(26, minval=1, title="Senkou-Span Offset")long_entry = input(true, title="Long Entry")short_entry = input(true, title="Short Entry")middle(len) => avg(lowest(len), highest(len))// Ichimoku Componentstenkan = middle(ts_bars)kijun = middle(ks_bars)senkouA = avg(tenkan, kijun)senkouB = middle(ssb_bars)ss_high = max(senkouA[ss_offset-1], senkouB[ss_offset-1])ss_low = min(senkouA[ss_offset-1], senkouB[ss_offset-1])// Entry/Exit Signalsfast_length = input(title="Fast Length", type=input.integer, defval=17)slow_length = input(title="Slow Length", type=input.integer, defval=28)src = input(title="Source", type=input.source, defval=close)signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 5)sma_source = input(title="Simple MA(Oscillator)", type=input.bool, defval=true)sma_signal = input(title="Simple MA(Signal Line)", type=input.bool, defval=true)// Calculatingfast_ma = sma_source ? sma(src, fast_length) : ema(src, fast_length)slow_ma = sma_source ? sma(src, slow_length) : ema(src, slow_length)macd = fast_ma - slow_masignal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)hist = macd - signaltk_cross_bull = tenkan > kijuntk_cross_bear = tenkan < kijuncs_cross_bull = mom(close, cs_offset-1) > 0cs_cross_bear = mom(close, cs_offset-1) < 0price_above_kumo = close > ss_highprice_below_kumo = close < ss_low//CMFlengthA = input(8, minval=1, title="CMF Length")ad = close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volumemf = sum(ad, lengthA) / sum(volume, lengthA)//TSIlong = input(title="Long Length", type=input.integer, defval=8)short = input(title="Short Length", type=input.integer, defval=8)price = closedouble_smooth(src, long, short) =>    fist_smooth = ema(src, long)    ema(fist_smooth, short)pc = change(price)double_smoothed_pc = double_smooth(pc, long, short)double_smoothed_abs_pc = double_smooth(abs(pc), long, short)tsi_value = 100 * (double_smoothed_pc / double_smoothed_abs_pc)bullish = tk_cross_bull and cs_cross_bull and price_above_kumo and hist > 0 and mf > 0.1 and tsi_value > 0bearish = tk_cross_bear and cs_cross_bear and price_below_kumo and hist < 0  and mf < -0.1 and tsi_value < 0strategy.entry("Long", strategy.long, when=bullish and long_entry)strategy.entry("Short", strategy.short, when=bearish and short_entry)strategy.close("Long", when=bearish and not short_entry)strategy.close("Short", when=bullish and not long_entry)