Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Arnaud Legoux Moving Average Cross (ALMA)

A Pine Script v5 strategy built on ALMA (src, 60), EMA (volume, 5) and Crossover (Alma1, Alma2). 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 is one contract and pays no commission. 14 settings; defaults include ALMA Lenghth 1 60, Arnaud Legoux (ALMA) - Offset Value 0.85 and Arnaud Legoux (ALMA) - Sigma Value 6.

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 Arnaud Legoux Moving Average Cross (ALMA) 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 Arnaud Legoux Moving Average Cross (ALMA) do on BTCUSDT 1D with default settings?
+0.15%
From 26 Jan 2024 to 21 Oct 2026, over 9 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
What alerts does Arnaud Legoux Moving Average Cross (ALMA) have?
2
BUY Trade Entry Alert; SELL Trade Entry Alert.
Does Arnaud Legoux Moving Average Cross (ALMA) 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: 9 before, 9 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does Arnaud Legoux Moving Average Cross (ALMA) use a stop loss?
Yes
strategy.exit sets a stop on line 67, 69.

BTCUSDT · 1D · default settings

  • Alma Fast
  • Alma Slow
  • 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 (14)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,001,500$2,025,273Equity from $1,000,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 direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 58, 62) so the engine trades the way the script says.
Net profit
+0.15%
$1,501.79
Buy and hold
+102.5%
same period
Closed trades
9
5 won · 4 lost
Profitable
55.6%
of closed trades
Profit factor
1.16
gross profit ÷ gross loss
Max drawdown
0.86%
−$8,581.27

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

    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.

Settings

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

SettingDefaultType and rangeFeeds
Long Entrytrueboolentry Long line 57
Short Entrytrueboolentry Short line 61
Arnaud Legoux (ALMA) - Offset Value0.85float · min 0 · step 0.01Alma1
Arnaud Legoux (ALMA) - Sigma Value6int · min 0Alma1
Arnaud Legoux (ALMA) - Offset Value0.85float · min 0 · step 0.01Alma2
Arnaud Legoux (ALMA) - Sigma Value6int · min 0Alma2
Long Length10int · min 1long
Short Take Profit2float · min 0.0 · step 0.1shortExitPrice
Short Stop Loss2.5float · min 0.0 · step 0.1shortStopPrice
ALMA Fast Length Settings
ALMA Lenghth 160intAlma1
ALMA Slow Length Settings
ALMA Length 2120intAlma2
Volume Settings
Short Length5int · min 1short
Take Profit Percentage
Long Take Profit2float · min 0.0 · step 0.1longExitPrice
Stop Percentage
Long Stop Loss2.5float · min 0.0 · step 0.1longStopPrice

What it calculates

  • ALMAsrc, ALMA Lenghth 1 (60), Arnaud Legoux (ALMA) - Offset Value (0.85), Arnaud Legoux (ALMA) - Sigma Value (6)Alma1 · line 14
  • ALMAsrc, ALMA Length 2 (120), Arnaud Legoux (ALMA) - Offset Value (0.85), Arnaud Legoux (ALMA) - Sigma Value (6)Alma2 · line 19
  • EMAvolume, Short Length (5)short · line 27
  • EMAvolume, Long Length (10)long · line 28
  • CrossoverAlma1, Alma2buy · line 31
  • CrossunderAlma1, Alma2sell · line 32

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.

ALMA1ALMA Lenghth 1setting · 60alma_offsetArnaud Legoux (ALMA) - …setting · 0.85alma_sigmaArnaud Legoux (ALMA) - …setting · 6ALMA2ALMA Length 2setting · 120alma_offset2Arnaud Legoux (ALMA) - …setting · 0.85alma_sigma2Arnaud Legoux (ALMA) - …setting · 6volumevolumeprice datashortlenShort Lengthsetting · 5longlenLong Lengthsetting · 10closecloseprice datalongProfitPercLong Take Profitsetting · 2shortProfitPercShort Take Profitsetting · 2longStopPercLong Stop Losssetting · 2.5shortStopPercShort Stop Losssetting · 2.5Alma1ALMA→ Alma1Alma2ALMA→ Alma2shortEMA→ shortlongEMA→ longbuyCrossover→ buysellCrossunder→ sellsrcsrcvaluecumVolcumVolvalueoscoscvaluelongExitPricelongExitPricevalueshortExitPriceshortExitPricevaluelongStopPricelongStopPricevalueshortStopPriceshortStopPricevaluebuySignalbuySignalconditionsellSignalsellSignalconditionentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryexit:Long TP/SLexit Long TP/SLstrategy.exitexit:Short TP/SLexit Short TP/SLstrategy.exitalert:59alertalertalert:63alertalertplot:71Alma Fastplotplot:72Alma Slowplot

Order rules

OrderFires whenBy defaultLine
Open Long longbuySignal and long_entryOn58
Open Short shortsellSignal and short_entryOn62
Exit Long TP/SL stop and limit(strategy.position_size > 0)On67
Exit Short TP/SL stop and limit(strategy.position_size < 0)On69

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Alerts

AlertCallMessageLine
(no title)alertBUY Trade Entry Alert59
(no title)alertSELL Trade Entry Alert63

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+0.2%+102.5%956%1.160.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.0%+5.5%560%1.060.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.0%+9.8%3100%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%771%1.550.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%1258%1.320.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.0%+21.5%714%0.100.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%1060%1.420.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.0%+17.1%1443%0.610.0%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 market250%−$759.07
Sideways market560%$2,702.43
Falling market250%−$441.57

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

How bad could the drawdown be?

1.0%

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

0%1%
All 9 trades
SideEntryExitBarsP&L
short26 Jun 2024 61,806.0028 Jun 2024 60,569.902$1,236.13
short11 Jan 2025 94,726.1013 Jan 2025 92,831.602$1,894.53
long22 Jan 2025 106,144.0023 Jan 2025 103,490.001−$2,653.60
long26 Apr 2025 94,638.701 May 2025 96,531.505$1,892.78
short23 Oct 2025 107,567.0024 Oct 2025 110,257.001−$2,689.19
long14 Jan 2026 95,414.0019 Jan 2026 93,028.605−$2,385.35
short2 Feb 2026 76,968.203 Feb 2026 78,892.401−$1,924.21
long15 Apr 2026 74,131.6017 Apr 2026 75,614.202$1,482.64
short2 Jun 2026 71,408.903 Jun 2026 66,760.801$4,648.06

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

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 4 settings use the untyped input() (line 8, 9, 11, 16). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

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

  • Line 8: input() → input.bool()
  • Line 9: input() → input.bool()
  • Line 11: input() → input.int()
  • Line 16: input() → input.int()
⋯src= (close)-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')//Fast Settings-ALMA1 = input(60, "ALMA Lenghth 1", group= "ALMA Fast Length Settings")+ALMA1 = input.int(60, "ALMA Lenghth 1", group= "ALMA Fast Length Settings")alma_offset = input.float(defval=0.85, title='Arnaud Legoux (ALMA) - Offset Value', minval=0, step=0.01)⋯//Slow Settings-ALMA2 = input(120, "ALMA Length 2", group = "ALMA Slow Length Settings")+ALMA2 = input.int(120, "ALMA Length 2", group = "ALMA Slow Length Settings")alma_offset2 = input.float(defval=0.85, title='Arnaud Legoux (ALMA) - Offset Value', minval=0, step=0.01)⋯

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

⋯// Calculations for TP/SL based off: https://kodify.net/tradingview/orders/percentage-profit/-//@version=5+//@version=6strategy("ALMA Cross", overlay=true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 19 msWith a workaround 1,000 bars in 50 msNot measured
PineTSNot testedNot testedNot measured

Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 58, 62) 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.

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/// © Sarahann999// Calculations for TP/SL based off: https://kodify.net/tradingview/orders/percentage-profit///@version=5strategy("ALMA Cross", overlay=true)//User Inputssrc= (close)long_entry = input(true, title='Long Entry')short_entry = input(true, title='Short Entry')//Fast SettingsALMA1 = input(60, "ALMA Lenghth 1", group= "ALMA Fast Length Settings")alma_offset = input.float(defval=0.85, title='Arnaud Legoux (ALMA) - Offset Value', minval=0, step=0.01)alma_sigma = input.int(defval=6, title='Arnaud Legoux (ALMA) - Sigma Value', minval=0)Alma1 = ta.alma(src, ALMA1, alma_offset, alma_sigma)//Slow SettingsALMA2 = input(120, "ALMA Length 2", group = "ALMA Slow Length Settings")alma_offset2 = input.float(defval=0.85, title='Arnaud Legoux (ALMA) - Offset Value', minval=0, step=0.01)alma_sigma2 = input.int(defval=6, title='Arnaud Legoux (ALMA) - Sigma Value', minval=0)Alma2 = ta.alma(src, ALMA2, alma_offset2, alma_sigma2)//Volumevar cumVol = 0.cumVol += nz(volume)if barstate.islast and cumVol == 0    runtime.error("No volume is provided by the data vendor.")shortlen = input.int(5, minval=1, title = "Short Length", group= "Volume Settings")longlen = input.int(10, minval=1, title = "Long Length")short = ta.ema(volume, shortlen)long = ta.ema(volume, longlen)osc = 100 * (short - long) / long//Define Cross Conditionsbuy = ta.crossover(Alma1, Alma2)sell = ta.crossunder(Alma1, Alma2)//Calculate Take Profit PercentagelongProfitPerc = input.float(title="Long Take Profit", group='Take Profit Percentage',     minval=0.0, step=0.1, defval=2) / 100shortProfitPerc = input.float(title="Short Take Profit",     minval=0.0, step=0.1, defval=2) / 100     // Figure out take profit price 1longExitPrice  = strategy.position_avg_price * (1 + longProfitPerc)shortExitPrice = strategy.position_avg_price * (1 - shortProfitPerc)// Make inputs that set the stop %  1longStopPerc = input.float(title="Long Stop Loss", group='Stop Percentage',     minval=0.0, step=0.1, defval=2.5) / 100shortStopPerc = input.float(title="Short Stop Loss",     minval=0.0, step=0.1, defval=2.5) / 100// Figure Out Stop PricelongStopPrice  = strategy.position_avg_price * (1 - longStopPerc)shortStopPrice = strategy.position_avg_price * (1 + shortStopPerc)//Define ConditionsbuySignal = buy and osc > 0     and strategy.position_size == 0//sellSignal sellSignal = sell and osc > 0     and strategy.position_size == 0// Submit entry ordersif buySignal and long_entry    strategy.entry(id="Long", direction=strategy.long, alert_message="Enter Long")    alert(message="BUY Trade Entry Alert", freq=alert.freq_once_per_bar)    if sellSignal and short_entry    strategy.entry(id="Short", direction=strategy.short, alert_message="Enter Short")    alert(message="SELL Trade Entry Alert", freq=alert.freq_once_per_bar)    // Submit exit orders based on take profit priceif (strategy.position_size > 0)    strategy.exit(id="Long TP/SL", limit=longExitPrice, stop=longStopPrice, alert_message="Long Exit 1 at {{close}}")if (strategy.position_size < 0)    strategy.exit(id="Short TP/SL", limit=shortExitPrice, stop=shortStopPrice, alert_message="Short Exit 1 at {{close}}")//Drawplot(Alma1,"Alma Fast", color=color.purple, style=plot.style_circles)plot(Alma2,"Alma Slow", color=#acb5c2, style=plot.style_circles)