Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Full Crypto Swing Strategy ALMA Cross with MACD

A Pine Script v4 strategy built on ALMA (src, 20) and EMA (src, 6). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays 0.03% commission. 18 settings; defaults include From Day 1, From Month 1 and From Year 2010.

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 Full Crypto Swing Strategy ALMA Cross with MACD repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Full Crypto Swing Strategy ALMA Cross with MACD do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
Can Full Crypto Swing Strategy ALMA Cross with MACD be converted to Pine Script v5?
Not tested
The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
Does Full Crypto Swing Strategy ALMA Cross with MACD use a stop loss?
Yes
strategy.exit sets a stop on line 48, 49.
Does Full Crypto Swing Strategy ALMA Cross with MACD run in Zeal Terminal?
Yes
It compiles in 12 ms and runs 1,000 bars in 45 ms, in the browser.

BTCUSDT · 1D · default settings

  • ALMA
  • ALMA
  • EMA
  • EMA
  • EMA
  • 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 (18)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$1$2Equity from $1
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. Zeal Terminal's engine currently reads an order side written as 1, 0 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 46, 47) so the engine trades the way the script says. 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.
Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
$0.00

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

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    4 settings have no label

    In the settings dialog takeProfit_long (line 42), stopLoss_long (line 43), takeProfit_short (line 44), stopLoss_short (line 45) show an empty name. The labels on this page come from the variable names.

  • Note

    Uses an argument v6 removed

    when = on line 46, 47. 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 security → request.security, heikinashi → ticker.heikinashi, alma → ta.alma, ema → ta.ema, crossover → ta.crossover, crossunder → ta.crossunder.
  • 2 strategy calls use the when = argument (line 46, 47). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 3: //@version=4 → //@version=5
  • Line 18: security → request.security
  • Line 18: heikinashi → ticker.heikinashi
  • Line 19: security → request.security
  • Line 19: heikinashi → ticker.heikinashi
  • Line 20: security → request.security
19 more edits
  • Line 20: heikinashi → ticker.heikinashi
  • Line 21: security → request.security
  • Line 21: heikinashi → ticker.heikinashi
  • Line 24: input(type = input.integer) → input.int()
  • Line 25: input(type = input.integer) → input.int()
  • Line 26: input(type = input.float) → input.float()
  • Line 27: input(type = input.float) → input.float()
  • Line 28: alma → ta.alma
  • Line 29: alma → ta.alma
  • Line 31: input(type = input.integer) → input.int()
  • Line 32: input(type = input.integer) → input.int()
  • Line 33: input(type = input.integer) → input.int()
  • Line 35: ema → ta.ema
  • Line 36: ema → ta.ema
  • Line 38: ema → ta.ema
  • Line 40: crossover → ta.crossover
  • Line 41: crossunder → ta.crossunder
  • Line 46: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
  • Line 47: strategy.entry(…, 0) → strategy.entry(…, strategy.short)
⋯// © exlux99-//@version=4+//@version=5strategy(title = "Full Crypto Swing Strategy ALMA Cross", overlay = true,  pyramiding=1,initial_capital = 1, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.03)⋯UseHAcandles    = input(false, title="Use Heikin Ashi Candles in Algo Calculations")-haClose = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, close) : close+haClose = UseHAcandles ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close) : close-haOpen  = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, open) : open+haOpen  = UseHAcandles ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open) : open-haHigh  = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, high) : high+haHigh  = UseHAcandles ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high) : high-haLow   = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, low) : low+haLow   = UseHAcandles ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low) : low//alma fast and slowsrc = haClose-windowsize = input(title="Length Size Fast", type=input.integer, defval=20)+windowsize = input.int(title="Length Size Fast", defval=20)-windowsize2 = input(title="Length Size Slow", type=input.integer, defval=40)+windowsize2 = input.int(title="Length Size Slow", defval=40)-offset = input(title="Offset", type=input.float, defval=0.9, step=0.05)+offset = input.float(title="Offset", defval=0.9, step=0.05)-sigma = input(title="Sigma", type=input.float, defval=5)+sigma = input.float(title="Sigma", defval=5)-outfast=alma(src, windowsize, offset, sigma)+outfast=ta.alma(src, windowsize, offset, sigma)-outslow=alma(src, windowsize2, offset, sigma)+outslow=ta.alma(src, windowsize2, offset, sigma)//macd-fast_length = input(title="Fast Length", type=input.integer, defval=6)+fast_length = input.int(title="Fast Length", defval=6)-slow_length = input(title="Slow Length", type=input.integer, defval=25)+slow_length = input.int(title="Slow Length", defval=25)-signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)+signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9)// Calculating-fast_ma = ema(src, fast_length)+fast_ma = ta.ema(src, fast_length)-slow_ma =  ema(src, slow_length)+slow_ma =  ta.ema(src, slow_length)macd = fast_ma - slow_ma-signal = ema(macd, signal_length)+signal = ta.ema(macd, signal_length)hist = macd - signal-long=crossover(outfast,outslow) and hist > hist[1] and time_cond+long=ta.crossover(outfast,outslow) and hist > hist[1] and time_cond-short=crossunder(outfast,outslow) and hist < hist[1] and time_cond+short=ta.crossunder(outfast,outslow) and hist < hist[1] and time_condtakeProfit_long=input(2.0, step=0.005)⋯stopLoss_short=input(1.0, step=0.005)-strategy.entry("long",1,when=long)+strategy.entry("long",strategy.long,when=long)-strategy.entry("short",0,when=short)+strategy.entry("short",strategy.short,when=short)strategy.exit("short_tp/sl", "long", profit=close * takeProfit_long / syminfo.mintick, loss=close * stopLoss_long / syminfo.mintick, comment='LONG EXIT',  alert_message = 'closeshort')⋯

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
  • Line 11: input() → input.int()
  • Line 12: input() → input.int()
  • Line 13: input() → input.int()
7 more edits
  • Line 17: input() → input.bool()
  • Line 42: input() → input.float()
  • Line 43: input() → input.float()
  • Line 44: input() → input.float()
  • Line 45: input() → input.float()
  • Line 46: when = long → if block
  • Line 47: when = short → if block
⋯//time condition-fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)+fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)-fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)+fromMonth = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)-fromYear = input(defval = 2010, title = "From Year", minval = 1970)+fromYear = input.int(defval = 2010, title = "From Year", minval = 1970) //monday and session // To Date Inputs-toDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31)+toDay = input.int(defval = 31, title = "To Day", minval = 1, maxval = 31)-toMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12)+toMonth = input.int(defval = 12, title = "To Month", minval = 1, maxval = 12)-toYear = input(defval = 2021, title = "To Year", minval = 1970)+toYear = input.int(defval = 2021, title = "To Year", minval = 1970)startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)⋯time_cond = time >= startDate and time <= finishDate-UseHAcandles    = input(false, title="Use Heikin Ashi Candles in Algo Calculations")+UseHAcandles    = input.bool(false, title="Use Heikin Ashi Candles in Algo Calculations")haClose = UseHAcandles ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close) : close⋯short=ta.crossunder(outfast,outslow) and hist < hist[1] and time_cond-takeProfit_long=input(2.0, step=0.005)+takeProfit_long=input.float(2.0, step=0.005)-stopLoss_long=input(0.2, step=0.005)+stopLoss_long=input.float(0.2, step=0.005)-takeProfit_short=input(0.05, step=0.005)+takeProfit_short=input.float(0.05, step=0.005)-stopLoss_short=input(1.0, step=0.005)+stopLoss_short=input.float(1.0, step=0.005)-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.exit("short_tp/sl", "long", profit=close * takeProfit_long / syminfo.mintick, loss=close * stopLoss_long / syminfo.mintick, comment='LONG EXIT',  alert_message = 'closeshort')⋯

Does it run in Pine Script v6?

Not tested

Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version 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(title = "Full Crypto Swing Strategy ALMA Cross", overlay = true,  pyramiding=1,initial_capital = 1, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.03)⋯

Settings

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

SettingDefaultType and rangeFeeds
From Day1int · min 1 · max 31startDate
From Month1int · min 1 · max 12startDate
From Year2010int · min 1970startDate
To Day31int · min 1 · max 31finishDate
To Month12int · min 1 · max 12finishDate
To Year2021int · min 1970finishDate
Use Heikin Ashi Candles in Algo CalculationsfalseboolhaClose haOpen haHigh haLow
Length Size Fast20int (written input.integer)outfast
Length Size Slow40int (written input.integer)outslow
Offset0.9float · step 0.05outfast outslow
Sigma5floatoutfast outslow
Fast Length6int (written input.integer)fast_ma
Slow Length25int (written input.integer)slow_ma
Signal Smoothing9int (written input.integer) · min 1 · max 50signal
Take Profit long (no label in the script)2.0float · step 0.005exit short_tp/sl
Stop Loss long (no label in the script)0.2float · step 0.005exit short_tp/sl
Take Profit short (no label in the script)0.05float · step 0.005exit short_tp/sl
Stop Loss short (no label in the script)1.0float · step 0.005exit short_tp/sl

What it calculates

  • ALMA (alma, ta.alma in v5)src, Length Size Fast (20), Offset (0.9), Sigma (5)outfast · line 28
  • ALMA (alma, ta.alma in v5)src, Length Size Slow (40), Offset (0.9), Sigma (5)outslow · line 29
  • EMA (ema, ta.ema in v5)src, Fast Length (6)fast_ma · line 35
  • EMA (ema, ta.ema in v5)src, Slow Length (25)slow_ma · line 36
  • EMA (ema, ta.ema in v5)macd, Signal Smoothing (9)signal · line 38

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.

windowsizeLength Size Fastsetting · 20offsetOffsetsetting · 0.9sigmaSigmasetting · 5windowsize2Length Size Slowsetting · 40fast_lengthFast Lengthsetting · 6slow_lengthSlow Lengthsetting · 25signal_lengthSignal Smoothingsetting · 9fromYearFrom Yearsetting · 2010fromMonthFrom Monthsetting · 1fromDayFrom Daysetting · 1toYearTo Yearsetting · 2021toMonthTo Monthsetting · 12toDayTo Daysetting · 31closecloseprice dataopenopenprice datahighhighprice datalowlowprice datatimetimeprice dataoutfastALMA→ outfastoutslowALMA→ outslowfast_maEMA→ fast_maslow_maEMA→ slow_masignalEMA→ signalstartDatestartDatevaluefinishDatefinishDatevaluehaClosehaClosevaluehaOpenhaOpenvaluehaHighhaHighvaluehaLowhaLowvaluesrcsrcvaluemacdmacdvaluehisthistvaluelonglongconditionshortshortconditiontime_condtime_condconditionentry:longOpen longstrategy.entryentry:shortOpen shortstrategy.entryexit:short_tp/slexit short_tp/slstrategy.exit

Order rules

OrderFires whenBy defaultLine
Open long longlongcrossover(outfast,outslow) and hist > hist[1] and time_condOn46
Open short shortshortcrossunder(outfast,outslow) and hist < hist[1] and time_condOn47
Exit short_tp/sl stop and limitevery barOn48
Exit short_tp/sl stop and limitevery barOn49

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe data4 security call(s), none with lookahead on.
  • 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 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—0.0%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

Settings heatmap

Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (Length Size Fast 10, Length Size Slow 20) made 0.0% before 26 Dec 2025 and 0.0% after it, against 0.0% for the defaults. 0% of the 64 combinations made money in-sample and 0% out-of-sample.

Before 26 Dec 2025 · in-sample
Length Size Slow ↓ · Length Size Fast →1012141720242834
200%0%0%0%0%0%0%0%
240%0%0%0%0%0%0%0%
280%0%0%0%0%0%0%0%
340%0%0%0%0%0%0%0%
400%0%0%0%0%0%0%0%
480%0%0%0%0%0%0%0%
560%0%0%0%0%0%0%0%
680%0%0%0%0%0%0%0%
From 26 Dec 2025 · out-of-sample
Length Size Slow ↓ · Length Size Fast →1012141720242834
200%0%0%0%0%0%0%0%
240%0%0%0%0%0%0%0%
280%0%0%0%0%0%0%0%
340%0%0%0%0%0%0%0%
400%0%0%0%0%0%0%0%
480%0%0%0%0%0%0%0%
560%0%0%0%0%0%0%0%
680%0%0%0%0%0%0%0%

Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. Backtests are simulations on historical data and are not investment advice.

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
Full Crypto Swing Strategy ALMA Cross with MACD this page—v4 strategy0.0%00.0%
Trend Identifier Strategy by spacekadet17alma emav5 strategy+62.0%2420.4%
Arnaud Legoux Moving Average Cross (ALMA) by Sarahann999alma emav5 strategy+0.2%90.9%
Korea premium(KIMP) by roses27alma emav4 strategydoes not run in Zeal Terminal

Where it runs

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

Zeal Terminal's engine currently reads an order side written as 1, 0 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 46, 47) so the engine trades the way the script says. 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. 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(title = "Full Crypto Swing Strategy ALMA Cross", overlay = true,  pyramiding=1,initial_capital = 1, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.03)//time conditionfromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)fromYear = input(defval = 2010, title = "From Year", minval = 1970) //monday and session // To Date InputstoDay = input(defval = 31, title = "To Day", minval = 1, maxval = 31)toMonth = input(defval = 12, title = "To Month", minval = 1, maxval = 12)toYear = input(defval = 2021, title = "To Year", minval = 1970)startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)finishDate = timestamp(toYear, toMonth, toDay, 00, 00)time_cond = time >= startDate and time <= finishDateUseHAcandles    = input(false, title="Use Heikin Ashi Candles in Algo Calculations")haClose = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, close) : closehaOpen  = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, open) : openhaHigh  = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, high) : highhaLow   = UseHAcandles ? security(heikinashi(syminfo.tickerid), timeframe.period, low) : low//alma fast and slowsrc = haClosewindowsize = input(title="Length Size Fast", type=input.integer, defval=20)windowsize2 = input(title="Length Size Slow", type=input.integer, defval=40)offset = input(title="Offset", type=input.float, defval=0.9, step=0.05)sigma = input(title="Sigma", type=input.float, defval=5)outfast=alma(src, windowsize, offset, sigma)outslow=alma(src, windowsize2, offset, sigma)//macdfast_length = input(title="Fast Length", type=input.integer, defval=6)slow_length = input(title="Slow Length", type=input.integer, defval=25)signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)// Calculatingfast_ma = ema(src, fast_length)slow_ma =  ema(src, slow_length)macd = fast_ma - slow_masignal = ema(macd, signal_length)hist = macd - signallong=crossover(outfast,outslow) and hist > hist[1] and time_condshort=crossunder(outfast,outslow) and hist < hist[1] and time_condtakeProfit_long=input(2.0, step=0.005)stopLoss_long=input(0.2, step=0.005)takeProfit_short=input(0.05, step=0.005)stopLoss_short=input(1.0, step=0.005)strategy.entry("long",1,when=long)strategy.entry("short",0,when=short)strategy.exit("short_tp/sl", "long", profit=close * takeProfit_long / syminfo.mintick, loss=close * stopLoss_long / syminfo.mintick, comment='LONG EXIT',  alert_message = 'closeshort')strategy.exit("short_tp/sl", "short", profit=close * takeProfit_short / syminfo.mintick, loss=close * stopLoss_short / syminfo.mintick, comment='SHORT EXIT',  alert_message = 'closeshort')