Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

MACD Willy Strategy

A Pine Script v5 strategy built on RMA (ta.tr, 14), SMA (volume, 50) and EMA (close, 200). 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. 29 settings; defaults include Start Year 2011, Start Month 1 and Start Day 1.

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 MACD Willy Strategy repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did MACD Willy Strategy 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 entry conditions never all held on this data. It closed no trades on the other markets either. A backtest, not investment advice.
What alerts does MACD Willy Strategy have?
4
Long Signal; Short Signal; Long Exit Signal; Short Exit Signal.
Does MACD Willy Strategy 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: 33 before, 11 after on ETHUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does MACD Willy Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.

BTCUSDT · 1D · default settings

  • RMA
  • SMA
  • EMA
  • SMA
  • SMA
  • SMA
  • Highest
  • Lowest
  • WMA
  • EMA
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$10,000$20,253Equity from $10,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. 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. The live re-run is not offered here: the script requests VIX D, which this page cannot load in your browser.

Needs VIX D data, not available: not a Binance spot market Values that depend on it are empty on this chart.

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, $10,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

    7 settings do nothing

    “VIX Threshold for entry”, “MACD Line ”, “Signal Line ”, “Above Grow”, “Fall”, “Below Grow”, “Fall” are declared but never read.

  • 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

    1 setting has no label

    In the settings dialog w_length (line 63) shows an empty name. The labels on this page come from the variable names.

  • 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
Trading window
Start Year2011inttimestart
Start Month1int · min 1 · max 12timestart
Start Day1int · min 1 · max 31timestart
Finish Year2050inttimefinish
Finish Month12int · min 1 · max 12timefinish
Finish Day31int · min 1 · max 31timefinish
Trading Options
Leverage (if applicable)1float · step 0.1trade_amount
Reinvest profitfalseboolline 77
Reinvest percentage20floattrade_amount
Sourceclosesourceema1 fast_ma slow_ma
Volume MA Period50intavg_vol
Fast Length12intfast_ma
Slow Length26intslow_ma
Signal Smoothing9int · min 1 · max 50signal
Oscillator MA TypeEMAstring · options ["SMA", "EMA"]fast_ma slow_ma
Signal Line MA TypeEMAstring · options ["SMA", "EMA"]signal
W length (no label in the script)34int · min 1w_upper w_lower
Smoothed %R Length5intw_fast_ma
Slow EMA Length13intw_slow_ma
Daily ATR
ATR period14int · min 1datr
% ATR to use for SL / PT5float · min 1 · max 100 · step 0.1percentage
VIX Volatility Index
VIX Threshold for entry20.0float · step 0.5unused
Moving Averages
EMA200int · min 1ema1
Color Settings
MACD Line #2962FFvalueunused
Signal Line #FF6D00valueunused
Histogram
Above Grow#26A69Avalueunused
Fall#B2DFDBvalueunused
Below Grow#FFCDD2valueunused
Fall#FF5252valueunused

What it calculates

  • RMAta.tr, ATR period (14)datr · line 29
  • SMAvolume, Volume MA Period (50)avg_vol · line 38
  • EMASource (close), EMA (200)ema1 · line 41
  • SMA / EMASource (close), Fast Length (12) · chosen by Oscillator MA Typefast_ma · line 57
  • SMA / EMASource (close), Slow Length (26) · chosen by Oscillator MA Typeslow_ma · line 58
  • SMA / EMAmacd, Signal Smoothing (9) · chosen by Signal Line MA Typesignal · line 60
  • HighestW length (34)w_upper · line 64
  • LowestW length (34)w_lower · line 65
  • WMAw_output, Smoothed %R Length (5)w_fast_ma · line 69
  • EMAw_output, Slow EMA Length (13)w_slow_ma · line 70

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.

high · low · closehigh · low · closeprice dataatrlenATR periodsetting · 14volumevolumeprice datavol_lenVolume MA Periodsetting · 50closecloseprice dataemalen1EMAsetting · 200sma_sourceOscillator MA Typesetting · EMAfast_lengthFast Lengthsetting · 12slow_lengthSlow Lengthsetting · 26sma_signalSignal Line MA Typesetting · EMAsignal_lengthSignal Smoothingsetting · 9w_lengthW lengthsetting · 34fast_periodSmoothed %R Lengthsetting · 5slow_periodSlow EMA Lengthsetting · 13startYStart Yearsetting · 2011startMStart Monthsetting · 1startDStart Daysetting · 1finishYFinish Yearsetting · 2050finishMFinish Monthsetting · 12finishDFinish Daysetting · 31iPercent% ATR to use for SL / PTsetting · 5leverageLeverage (if applicable)setting · 1reinvest_percentReinvest percentagesetting · 20datrRMA→ datravg_volSMA→ avg_volema1EMA→ ema1fast_maSMA / EMA→ fast_ma · by Oscillator MA …slow_maSMA / EMA→ slow_ma · by Oscillator MA …signalSMA / EMA→ signal · by Signal Line MA …w_upperHighest→ w_upperw_lowerLowest→ w_lowerw_fast_maWMA→ w_fast_maw_slow_maEMA→ w_slow_matimestarttimestartvaluetimefinishtimefinishvaluepercentagepercentagevaluedatrpdatrpvalueVIXVIXvaluemacdmacdvaluehisthistvaluew_outputw_outputvalueprofitprofitvaluetrade_amounttrade_amountvalueL_entry1L_entry1conditionS_entry1S_entry1conditionL_exit1L_exit1conditionS_exit1S_exit1conditionentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryclose:LongClose Longstrategy.closeclose:ShortClose Shortstrategy.closealert:83alertalertalert:86alertalertalert:93alertalertalert:97alertalert

Order rules

OrderFires whenBy defaultLine
Open Long longL_entry1On82
Open Short shortS_entry1On85
Close LongL_exit1On92
Close ShortS_exit1On96

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

Alerts

AlertCallMessageLine
(no title)alertLong Signal83
(no title)alertShort Signal86
(no title)alertLong Exit Signal93
(no title)alertShort Exit Signal97

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 data2 request.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

Not run on other markets: the script requests VIX D, and that data is not available here (not a Binance spot market). Its results would rest on empty values.

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
MACD Willy Strategy this page—v5 strategy0.0%00.0%
Bagheri IG Ether by Bagheri_IGema highest lowest rma smav4 strategy+0.0%30.0%
Bagheri IG Ether v2 by Bagheri_IGema highest lowest rma smav4 strategy−0.0%20.0%
Swing Multi Moving Averages Crypto and Stocks Strategy by exlux99ema wma highest lowest smav5 strategy+60.2%2213.1%
VCP pivot buy by perrycc007sma ema rma wma lowest highestv4 strategydoes not run in Zeal Terminal
SPX Scalping Strategy by connor2279sma ema lowest wma rmav5 strategy+1.5%1095.0%

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.

  • 14 settings use the untyped input() (line 6, 9, 23, 37, 44, 45, 50, 51, 52, 53, 54, 55, 67, 68). 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 33 trades and the same P&L on ETHUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 6: input() → input.int()
  • Line 9: input() → input.int()
  • Line 23: input() → input.source()
  • Line 37: input() → input.int()
  • Line 44: input() → input.int()
  • Line 45: input() → input.int()
8 more edits
  • Line 50: input() → input.color()
  • Line 51: input() → input.color()
  • Line 52: input() → input.color()
  • Line 53: input() → input.color()
  • Line 54: input() → input.color()
  • Line 55: input() → input.color()
  • Line 67: input() → input.int()
  • Line 68: input() → input.int()
⋯// ******************** Trade Period **************************************-startY = input(title='Start Year', defval=2011, group = "Trading window")+startY = input.int(title='Start Year', defval=2011, group = "Trading window")startM = input.int(title='Start Month', defval=1, minval=1, maxval=12, group = "Trading window")startD = input.int(title='Start Day', defval=1, minval=1, maxval=31, group = "Trading window")-finishY = input(title='Finish Year', defval=2050, group = "Trading window")+finishY = input.int(title='Finish Year', defval=2050, group = "Trading window")finishM = input.int(title='Finish Month', defval=12, minval=1, maxval=12, group = "Trading window")⋯// -------------------------------------------- Data Source ---------------------------------------------src = input(title="Source", defval=close)+src = input.source(title="Source", defval=close)// ***************************************************************************************************** Daily ATR *****************************************************⋯// ************************************************ Volume ******************************************************-vol_len = input(50, 'Volume MA Period')+vol_len = input.int(50, 'Volume MA Period')avg_vol = ta.sma(volume, vol_len)⋯// Getting inputs-fast_length = input(title="Fast Length", defval=12)+fast_length = input.int(title="Fast Length", defval=12)-slow_length = input(title="Slow Length", defval=26)+slow_length = input.int(title="Slow Length", defval=26)signal_length = input.int(title="Signal Smoothing",  minval = 1, maxval = 50, defval = 9)⋯// Plot colors-col_macd = input(#2962FF, "MACD Line  ", group="Color Settings", inline="MACD")+col_macd = input.color(#2962FF, "MACD Line  ", group="Color Settings", inline="MACD")-col_signal = input(#FF6D00, "Signal Line  ", group="Color Settings", inline="Signal")+col_signal = input.color(#FF6D00, "Signal Line  ", group="Color Settings", inline="Signal")-col_grow_above = input(#26A69A, "Above   Grow", group="Histogram", inline="Above")+col_grow_above = input.color(#26A69A, "Above   Grow", group="Histogram", inline="Above")-col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")+col_fall_above = input.color(#B2DFDB, "Fall", group="Histogram", inline="Above")-col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")+col_grow_below = input.color(#FFCDD2, "Below Grow", group="Histogram", inline="Below")-col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")+col_fall_below = input.color(#FF5252, "Fall", group="Histogram", inline="Below")// Calculating⋯w_output = 100 * (close - w_upper) / (w_upper - w_lower)-fast_period = input(defval=5, title='Smoothed %R Length')+fast_period = input.int(defval=5, title='Smoothed %R Length')-slow_period = input(defval=13, title='Slow EMA Length')+slow_period = input.int(defval=13, title='Slow EMA Length')w_fast_ma = ta.wma(w_output,fast_period)⋯

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: 33 before, 11 after on ETHUSDT 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.

⋯// © platsn-//@version=5+//@version=6strategy("MACD Willy Strategy", overlay=true, pyramiding=1, initial_capital=10000) ⋯

Where it runs

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

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.

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/// © platsn//@version=5strategy("MACD Willy Strategy", overlay=true, pyramiding=1, initial_capital=10000) // ******************** Trade Period **************************************startY = input(title='Start Year', defval=2011, group = "Trading window")startM = input.int(title='Start Month', defval=1, minval=1, maxval=12, group = "Trading window")startD = input.int(title='Start Day', defval=1, minval=1, maxval=31, group = "Trading window")finishY = input(title='Finish Year', defval=2050, group = "Trading window")finishM = input.int(title='Finish Month', defval=12, minval=1, maxval=12, group = "Trading window")finishD = input.int(title='Finish Day', defval=31, minval=1, maxval=31, group = "Trading window")timestart = timestamp(startY, startM, startD, 00, 00)timefinish = timestamp(finishY, finishM, finishD, 23, 59)// t1 = time(timeframe.period, "0945-1545:23456") // window = time >= timestart and time <= timefinish and t1 ? true : false // t2 = time(timeframe.period, "0930-1555:23456")// window2 = time >= timestart and time <= timefinish and t2 ? true : false leverage = input.float(1, title="Leverage (if applicable)", step=0.1, group = "Trading Options")reinvest = input.bool(defval=false,title="Reinvest profit", group = "Trading Options")reinvest_percent = input.float(defval=20, title = "Reinvest percentage", group="Trading Options")// entry_lookback = input.int(defval=10, title="Lookback period for entry condition", group = "Trading Options")// -------------------------------------------- Data Source --------------------------------------------src = input(title="Source", defval=close)// ***************************************************************************************************** Daily ATR *****************************************************atrlen = input.int(14, minval=1, title="ATR period", group = "Daily ATR")iPercent = input.float(5, minval=1, maxval=100, step=0.1, title="% ATR to use for SL / PT", group = "Daily ATR") percentage = iPercent * 0.01datr = request.security(syminfo.tickerid, "1D", ta.rma(ta.tr, atrlen))datrp = datr * percentage// plot(datr,"Daily ATR")// plot(datrp, "Daily % ATR")//*********************************************************** VIX volatility index ****************************************VIX = request.security("VIX", timeframe.period, close)vix_thres = input.float(20.0, "VIX Threshold for entry", step=0.5, group="VIX Volatility Index")// ************************************************ Volume ******************************************************vol_len = input(50, 'Volume MA Period')avg_vol = ta.sma(volume, vol_len)//-------------------------------------------------------- Moving Average ------------------------------------emalen1 = input.int(200, minval=1, title='EMA', group= "Moving Averages")ema1 = ta.ema(src, emalen1)// ------------------------------------------ MACD ------------------------------------------// Getting inputsfast_length = input(title="Fast Length", defval=12)slow_length = input(title="Slow Length", defval=26)signal_length = input.int(title="Signal Smoothing",  minval = 1, maxval = 50, defval = 9)sma_source = input.string(title="Oscillator MA Type",  defval="EMA", options=["SMA", "EMA"])sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"])// Plot colorscol_macd = input(#2962FF, "MACD Line  ", group="Color Settings", inline="MACD")col_signal = input(#FF6D00, "Signal Line  ", group="Color Settings", inline="Signal")col_grow_above = input(#26A69A, "Above   Grow", group="Histogram", inline="Above")col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")// Calculatingfast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length)slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length)macd = fast_ma - slow_masignal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)hist = macd - signal// ---------------------------------------- William %R --------------------------------------w_length = input.int(defval=34, minval=1)w_upper = ta.highest(w_length)w_lower = ta.lowest(w_length)w_output = 100 * (close - w_upper) / (w_upper - w_lower)fast_period = input(defval=5, title='Smoothed %R Length')slow_period = input(defval=13, title='Slow EMA Length')w_fast_ma = ta.wma(w_output,fast_period)w_slow_ma = ta.ema(w_output,slow_period)// ------------------------------------------------ Entry Conditions ----------------------------------------L_entry1 = close > ema1 and hist > 0 and w_fast_ma > w_slow_ma S_entry1 = close < ema1 and hist < 0 and w_fast_ma < w_slow_ma // -------------------------------------------------- Entry -----------------------------------------------profit = strategy.netprofittrade_amount = math.floor(strategy.initial_capital*leverage / close) if strategy.netprofit > 0 and reinvest    trade_amount := math.floor((strategy.initial_capital+(profit*reinvest_percent*0.01))*leverage / close) else    trade_amount := math.floor(strategy.initial_capital*leverage/ close) if L_entry1 //and window    strategy.entry("Long", strategy.long, trade_amount)    alert(message= "Long Signal", freq= alert.freq_once_per_bar_close)if S_entry1 //and window    strategy.entry("Short", strategy.short, trade_amount)    alert(message= "Short Signal", freq= alert.freq_once_per_bar_close)// --------------------------------------------------- Exit Conditions -------------------------------------L_exit1 = hist < 0 and w_fast_ma < w_slow_ma and w_fast_ma < -20S_exit1 = hist > 0 and w_fast_ma > w_slow_ma and w_fast_ma > -80// ----------------------------------------------------- Exit ---------------------------------------------if L_exit1 //and window2    strategy.close("Long")    alert(message= "Long Exit Signal", freq= alert.freq_once_per_bar_close)    if S_exit1 //and window2    strategy.close("Short")    alert(message= "Short Exit Signal", freq= alert.freq_once_per_bar_close)// if time(timeframe.period, "1530-1600:23456")//     strategy.close_all()