Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

MACD 50x Leveraged Strategy Real Equity Simulation

A Pine Script v4 strategy built on EMA (close, 12) and Change (strategy.position_size). It has 5 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 1 in cash and pays no commission. 9 settings; defaults include From Year 2009, To Year 2100 and From Month 04.

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 50x Leveraged Strategy Real Equity Simulation repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did MACD 50x Leveraged Strategy Real Equity Simulation do on BTCUSDT 1D with default settings?
+16,714.70%
From 26 Jan 2024 to 21 Oct 2026, over 117 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can MACD 50x Leveraged Strategy Real Equity Simulation 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 MACD 50x Leveraged Strategy Real Equity Simulation use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does MACD 50x Leveraged Strategy Real Equity Simulation run in Zeal Terminal?
Yes
It compiles in 26 ms and runs 1,000 bars in 85 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • 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 (9)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$17,881$203Equity from $100
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.
Net profit
+16,714.70%
$16,714.70
Buy and hold
+102.5%
same period
Closed trades
117
37 won · 80 lost
Profitable
31.6%
of closed trades
Profit factor
1.09
gross profit ÷ gross loss
Max drawdown
3,427.11%
−$62,483.80

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

  • Note

    3 settings have no label

    In the settings dialog fastLength (line 30), slowlength (line 31), MACDLength (line 32) show 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.

  • Note

    Uses an argument v6 removed

    when = on line 90, 91. 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 ema → ta.ema, valuewhen → ta.valuewhen, barssince → ta.barssince, change → ta.change, abs → math.abs.
  • 2 strategy calls use the when = argument (line 90, 91). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 33: ema → ta.ema
  • Line 33: ema → ta.ema
  • Line 34: ema → ta.ema
  • Line 40: valuewhen → ta.valuewhen
  • Line 41: valuewhen → ta.valuewhen
23 more edits
  • Line 49: barssince → ta.barssince
  • Line 49: barssince → ta.barssince
  • Line 50: barssince → ta.barssince
  • Line 50: barssince → ta.barssince
  • Line 51: barssince → ta.barssince
  • Line 51: barssince → ta.barssince
  • Line 52: barssince → ta.barssince
  • Line 52: barssince → ta.barssince
  • Line 53: barssince → ta.barssince
  • Line 53: barssince → ta.barssince
  • Line 54: barssince → ta.barssince
  • Line 54: barssince → ta.barssince
  • Line 57: change → ta.change
  • Line 59: valuewhen → ta.valuewhen
  • Line 60: valuewhen → ta.valuewhen
  • Line 61: valuewhen → ta.valuewhen
  • Line 62: valuewhen → ta.valuewhen
  • Line 63: valuewhen → ta.valuewhen
  • Line 64: valuewhen → ta.valuewhen
  • Line 77: change → ta.change
  • Line 77: change → ta.change
  • Line 78: abs → math.abs
  • Line 78: abs → math.abs
⋯// © Noldo-//@version=4+//@version=5strategy(title="MACD STRATEGY REAL EQUITY WITH 50X LEVERAGE",shorttitle = "MACD 50X REAL EQUITY", overlay=true, ⋯MACDLength = input(9)-MACD = ema(close, fastLength) - ema(close, slowlength)+MACD = ta.ema(close, fastLength) - ta.ema(close, slowlength)-aMACD = ema(MACD, MACDLength)+aMACD = ta.ema(MACD, MACDLength)delta = MACD - aMACD⋯// SL values-stop_long = valuewhen(strategy.position_size > 0  and strategy.position_size[1] <= 0 and trend ==  1  ,strategy.position_avg_price * 0.98,0)+stop_long = ta.valuewhen(strategy.position_size > 0  and strategy.position_size[1] <= 0 and trend ==  1  ,strategy.position_avg_price * 0.98,0)-stop_short= valuewhen(strategy.position_size < 0  and strategy.position_size[1] >= 0 and  trend == -1 ,strategy.position_avg_price * 1.02,0)+stop_short= ta.valuewhen(strategy.position_size < 0  and strategy.position_size[1] >= 0 and  trend == -1 ,strategy.position_avg_price * 1.02,0)// REAL LEVERAGE SIMULATION --- ⋯_dsmov = strategy.position_size[1] > 0 and strategy.position_size < 0 -onlylong = barssince(_lmov) < barssince(_dlmov) and _lmov+onlylong = ta.barssince(_lmov) < ta.barssince(_dlmov) and _lmov-onlyshort = barssince(_smov) < barssince (_dsmov) and _smov+onlyshort = ta.barssince(_smov) < ta.barssince (_dsmov) and _smov-onlylongexit  = barssince(_elmov) < barssince(_dsmov) and _elmov+onlylongexit  = ta.barssince(_elmov) < ta.barssince(_dsmov) and _elmov-onlyshortexit = barssince(_esmov) < barssince(_dlmov) and _esmov+onlyshortexit = ta.barssince(_esmov) < ta.barssince(_dlmov) and _esmov-directlong  = barssince(_dlmov) < barssince(_lmov) and _dlmov+directlong  = ta.barssince(_dlmov) < ta.barssince(_lmov) and _dlmov-directshort = barssince(_dsmov) < barssince(_smov) and _dsmov+directshort = ta.barssince(_dsmov) < ta.barssince(_smov) and _dsmov// float capital = 0.00-chg = change(strategy.position_size)+chg = ta.change(strategy.position_size)ch  = strategy.position_size-_l  = valuewhen(strategy.position_size > 0 and strategy.position_size[1] == 0,strategy.position_avg_price,0) // Long after Short or Long Exit+_l  = ta.valuewhen(strategy.position_size > 0 and strategy.position_size[1] == 0,strategy.position_avg_price,0) // Long after Short or Long Exit-_le = valuewhen(strategy.position_size[1] > 0 and strategy.position_size == 0 ,open,0)+_le = ta.valuewhen(strategy.position_size[1] > 0 and strategy.position_size == 0 ,open,0)-_s  = valuewhen(strategy.position_size < 0 and strategy.position_size[1] == 0,strategy.position_avg_price,0) // Short after Long or Long Exit+_s  = ta.valuewhen(strategy.position_size < 0 and strategy.position_size[1] == 0,strategy.position_avg_price,0) // Short after Long or Long Exit-_se = valuewhen(strategy.position_size[1] < 0 and strategy.position_size == 0 ,open,0)+_se = ta.valuewhen(strategy.position_size[1] < 0 and strategy.position_size == 0 ,open,0)-_dds = valuewhen(strategy.position_size < 0 and strategy.position_size[1] >= 0,strategy.position_avg_price,0) // Close Short and Long == DirectLong+_dds = ta.valuewhen(strategy.position_size < 0 and strategy.position_size[1] >= 0,strategy.position_avg_price,0) // Close Short and Long == DirectLong-_ddl = valuewhen(strategy.position_size > 0 and strategy.position_size[1] <= 0,strategy.position_avg_price,0) // Close Long and Short == DirectShort+_ddl = ta.valuewhen(strategy.position_size > 0 and strategy.position_size[1] <= 0,strategy.position_avg_price,0) // Close Long and Short == DirectShortpiplong = ((_le - _l) / _l) * 100 ⋯float mode = na-mode := change(strategy.wintrades) > 0 ? 1 : change(strategy.losstrades) > 0 ? -1 : nz(mode[1], 1)+mode := ta.change(strategy.wintrades) > 0 ? 1 : ta.change(strategy.losstrades) > 0 ? -1 : nz(mode[1], 1)-pipsize = (abs(chg) - abs(ch)) +pipsize = (math.abs(chg) - math.abs(ch)) capital := onlylong ? nz(capital[1], 0) - chg : ⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 18: input() → input.int()
  • Line 19: input() → input.int()
  • Line 20: input() → input.int()
  • Line 21: input() → input.int()
  • Line 22: input() → input.int()
  • Line 23: input() → input.int()
5 more edits
  • Line 30: input() → input.int()
  • Line 31: input() → input.int()
  • Line 32: input() → input.int()
  • Line 90: when = enterLong → if block
  • Line 91: when = enterShort → if block
⋯src = close -fromyear = input(2016, defval = 2009, minval = 2000, maxval = 2100, title = "From Year")+fromyear = input.int(2016, defval = 2009, minval = 2000, maxval = 2100, title = "From Year")-toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")+toyear = input.int(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")-frommonth = input(04, defval = 04, minval = 01, maxval = 12, title = "From Month")+frommonth = input.int(04, defval = 04, minval = 01, maxval = 12, title = "From Month")-tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")+tomonth = input.int(12, defval = 12, minval = 01, maxval = 12, title = "To Month")-fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")+fromday = input.int(01, defval = 01, minval = 01, maxval = 31, title = "From day")-today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")+today = input.int(31, defval = 31, minval = 01, maxval = 31, title = "To day")term = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59))⋯// MACD-fastLength = input(12)+fastLength = input.int(12)-slowlength = input(26)+slowlength = input.int(26)-MACDLength = input(9)+MACDLength = input.int(9)MACD = ta.ema(close, fastLength) - ta.ema(close, slowlength)⋯// STRATEGY-strategy.entry("Long",strategy.long, comment="LONG" ,when = enterLong , qty = possize)+if enterLong+    strategy.entry("Long",strategy.long, comment="LONG"  , qty = possize)-strategy.entry("Short",strategy.short, comment="SHORT" ,when = enterShort , qty = possize)+if enterShort+    strategy.entry("Short",strategy.short, comment="SHORT"  , qty = possize)if(sLong)⋯

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

⋯// © Noldo-//@version=5+//@version=6strategy(title="MACD STRATEGY REAL EQUITY WITH 50X LEVERAGE",shorttitle = "MACD 50X REAL EQUITY", overlay=true, ⋯

Settings

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

SettingDefaultType and rangeFeeds
From Year2009int · min 2000 · max 2100term
To Year2100int · min 1900 · max 2100term close_all line 96
From Month04int · min 01 · max 12term
To Month12int · min 01 · max 12term close_all line 96
From day01int · min 01 · max 31term
To day31int · min 01 · max 31term close_all line 96
Fast Length (no label in the script)12intMACD
Slowlength (no label in the script)26intMACD
MACDLength (no label in the script)9intaMACD

What it calculates

  • EMA (ema, ta.ema in v5)close, Fast Length (12)MACD · line 33
  • EMA (ema, ta.ema in v5)MACD, MACDLength (9)aMACD · line 34
  • Change (change, ta.change in v5)strategy.position_sizechg · line 57
  • Change (change, ta.change in v5)strategy.wintradesmode · line 77

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 datafastLengthFast Lengthsetting · 12slowlengthSlowlengthsetting · 26MACDLengthMACDLengthsetting · 9lowlowprice datahighhighprice datatimetimeprice datafromyearFrom Yearsetting · 2009frommonthFrom Monthsetting · 04fromdayFrom daysetting · 01toyearTo Yearsetting · 2100tomonthTo Monthsetting · 12todayTo daysetting · 31openopenprice dataMACDEMA→ MACDaMACDEMA→ aMACDchgChange→ chgmodeChange→ modesrcsrcvaluedeltadeltavaluetrendtrendvaluecapitalcapitalvaluechchvaluepiplongpiplongvaluepipshortpipshortvaluepipdl, pipdspipdl · pipds2 valuespipsizepipsizevaluecapitacapitavaluenetcapitalnetcapitalvalueenterLongenterLongconditionsLongsLongconditionenterShortenterShortconditionsShortsShortconditiontermtermconditionstop_long, stop_shortstop_long · stop_short2 conditions_lmov, _elmov, _smov, _esmov, _dlmov, _dsmov, _l, _s, _dds, _ddl, onlylong, onlyshort, onlylongexit, onlyshortexit, directlong, directshort_lmov · _elmov +1416 conditions_le, _se_le · _se2 conditionsentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryclose:LongClose Longstrategy.closeclose:ShortClose Shortstrategy.closeclose_all:close_all strategy.close_allplot:98plotplot

Order rules

OrderFires whenBy defaultLine
Open Long longenterLong((trend == 1 and term and trend[1] != 1) or (trend == 1 and term and trend[1] != 1 and low[1] <= stop_long) or (trend == 1 and term and trend[1] == 1 and low[1] <= stop_long))On90
Open Short shortenterShort((trend == -1 and term and trend[1] != -1) or (trend == -1 and term and trend[1] != -1 and high[1] >= stop_short) or (trend == -1 and term and trend[1] == -1 and high[1] >= stop_short))On91
Close Long(sLong)On93
Close Short(sShort )On95
Close time > timestamp(toyear, tomonth, today, 23, 59)On97

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

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

32/32trades 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. On 0 of them the position changed while the bar was forming before it settled. Anyone watching live sees those changes; once the bar closes it matches history.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationcalc_on_every_tick = true. Live values can differ from history.
  • 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+16,714.7%+102.5%11732%1.093,427.1%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+17,707.3%+5.5%7236%1.412,760.8%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−2,454.0%+9.8%12530%0.80371.2%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−51.0%+8.4%8429%0.98374.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+99.1%+16.7%10740%1.1970.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−4.8%+21.5%8230%0.9528.6%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−282.3%+148.3%12830%0.83563.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+24.0%+17.1%8630%1.0453.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 market5030%−$1,714.07
Sideways market4736%$12,818.20
Falling market2025%$5,610.58

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

How bad could the drawdown be?

63,301.5%

The 95th percentile of the worst drawdown when the same 117 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 234.2% to 63,301.5%; the tick is what actually happened, 133.0%. Order luck alone moves it this much.

0%72,797%
All 117 trades
SideEntryExitBarsP&L
long29 Feb 2024 62,432.1016 Mar 2024 69,499.8016$7,067.73
short16 Mar 2024 69,499.8026 Mar 2024 69,880.0010−$380.16
short27 Mar 2024 69,988.0028 Mar 2024 69,470.001$518.00
short29 Mar 2024 70,780.609 Apr 2024 71,620.0011−$839.40
short10 Apr 2024 69,146.0011 Apr 2024 70,631.101−$1,485.08
short12 Apr 2024 70,006.206 May 2024 64,012.0024$5,994.22
long6 May 2024 64,012.0012 May 2024 60,826.006−$3,186.01
short12 May 2024 60,826.0013 May 2024 61,484.001−$658.01
long13 May 2024 61,484.0031 May 2024 68,352.2018$6,868.17
short31 May 2024 68,352.204 Jun 2024 68,809.904−$457.72
short5 Jun 2024 70,537.806 Jun 2024 71,108.001−$570.17
long6 Jun 2024 71,108.009 Jun 2024 69,310.503−$1,797.54
short9 Jun 2024 69,310.5013 Jul 2024 57,889.1034$11,421.40
long13 Jul 2024 57,889.101 Aug 2024 64,628.0019$6,738.92
short1 Aug 2024 64,628.0020 Aug 2024 59,438.5019$5,189.51
long20 Aug 2024 59,438.5031 Aug 2024 59,124.0011−$314.51
short31 Aug 2024 59,124.0013 Sep 2024 58,132.3013$991.68
long13 Sep 2024 58,132.302 Oct 2024 60,804.9019$2,672.61
short2 Oct 2024 60,804.903 Oct 2024 60,649.301$155.65
short4 Oct 2024 60,752.705 Oct 2024 62,086.001−$1,333.28
short6 Oct 2024 62,058.008 Oct 2024 62,224.002−$166.00
short9 Oct 2024 62,160.5012 Oct 2024 62,540.003−$379.49
short13 Oct 2024 63,206.2015 Oct 2024 66,084.002−$2,877.77
long15 Oct 2024 66,084.0027 Oct 2024 67,092.8012$1,008.76
short27 Oct 2024 67,092.8029 Oct 2024 69,962.202−$2,869.45
long29 Oct 2024 69,962.204 Nov 2024 68,776.006−$1,186.22
short4 Nov 2024 68,776.006 Nov 2024 69,372.002−$596.02
long7 Nov 2024 75,572.0027 Nov 2024 91,965.2020$16,393.20
short27 Nov 2024 91,965.2028 Nov 2024 95,863.101−$3,897.95
short29 Nov 2024 95,644.0030 Nov 2024 97,460.001−$1,816.01
short1 Dec 2024 96,408.005 Dec 2024 98,587.304−$2,179.33
short6 Dec 2024 96,945.607 Dec 2024 99,740.801−$2,795.21
short8 Dec 2024 99,832.0012 Dec 2024 101,125.004−$1,293.01
short13 Dec 2024 100,004.0015 Dec 2024 101,420.002−$1,415.71
short16 Dec 2024 104,464.0017 Dec 2024 106,059.001−$1,594.66
long17 Dec 2024 106,059.0019 Dec 2024 100,204.002−$5,854.64
short19 Dec 2024 100,204.0020 Dec 2024 97,461.901$2,742.15
short21 Dec 2024 97,805.4027 Dec 2024 95,791.606$2,013.84
short28 Dec 2024 94,299.001 Jan 2025 93,576.004$723.03
short2 Jan 2025 94,591.803 Jan 2025 96,984.801−$2,393.01
short4 Jan 2025 98,174.206 Jan 2025 98,363.602−$189.44
long6 Jan 2025 98,363.6010 Jan 2025 92,552.504−$5,811.12
short10 Jan 2025 92,552.5011 Jan 2025 94,726.101−$2,173.61
short12 Jan 2025 94,600.0015 Jan 2025 96,560.903−$1,960.86
long16 Jan 2025 100,497.0029 Jan 2025 101,336.0013$838.17
short29 Jan 2025 101,336.0030 Jan 2025 103,733.001−$2,397.73
short31 Jan 2025 104,723.0021 Feb 2025 98,305.0021$6,417.93
long21 Feb 2025 98,305.0025 Feb 2025 91,552.904−$6,752.13
short25 Feb 2025 91,552.903 Mar 2025 94,270.006−$2,717.11
short4 Mar 2025 86,221.205 Mar 2025 87,282.001−$1,060.82
short6 Mar 2025 90,606.007 Mar 2025 89,931.901$674.12
long7 Mar 2025 89,931.909 Mar 2025 86,222.502−$3,709.42
short9 Mar 2025 86,222.5016 Mar 2025 84,338.407$1,884.02
long16 Mar 2025 84,338.407 Apr 2025 78,430.0022−$5,908.44
short7 Apr 2025 78,430.008 Apr 2025 79,163.201−$733.24
short9 Apr 2025 76,322.4010 Apr 2025 82,615.201−$6,292.80
short11 Apr 2025 79,607.3012 Apr 2025 83,423.801−$3,816.53
long12 Apr 2025 83,423.8018 May 2025 103,127.0036$19,702.80
short18 May 2025 103,127.0019 May 2025 106,454.001−$3,327.62
long19 May 2025 106,454.0020 May 2025 105,574.001−$880.54
short20 May 2025 105,574.0022 May 2025 109,644.002−$4,070.26
long22 May 2025 109,644.0025 May 2025 107,762.003−$1,882.09
short25 May 2025 107,762.0027 May 2025 109,435.002−$1,672.88
short28 May 2025 108,938.0011 Jun 2025 110,274.0014−$1,336.22
long11 Jun 2025 110,274.0013 Jun 2025 105,672.002−$4,602.65
short13 Jun 2025 105,672.0017 Jun 2025 106,795.004−$1,122.79
short18 Jun 2025 104,551.0026 Jun 2025 107,341.008−$2,789.42
long27 Jun 2025 106,947.0022 Jul 2025 117,380.0025$10,433.30
short22 Jul 2025 117,380.0023 Jul 2025 119,954.001−$2,574.07
long23 Jul 2025 119,954.0024 Jul 2025 118,756.001−$1,198.43
short24 Jul 2025 118,756.0012 Aug 2025 118,686.0019$70.00
long12 Aug 2025 118,686.0018 Aug 2025 117,405.006−$1,280.99
short18 Aug 2025 117,405.007 Sep 2025 110,188.0020$7,217.03
long7 Sep 2025 110,188.0024 Sep 2025 111,999.0017$1,810.82
short24 Sep 2025 111,999.0030 Sep 2025 114,312.006−$2,313.17
short1 Oct 2025 114,049.002 Oct 2025 118,595.001−$4,546.05
long2 Oct 2025 118,595.0011 Oct 2025 112,774.009−$5,820.50
short11 Oct 2025 112,774.0013 Oct 2025 114,959.002−$2,184.32
short14 Oct 2025 115,166.0027 Oct 2025 114,559.0013$606.59
long27 Oct 2025 114,559.004 Nov 2025 106,583.008−$7,976.36
short4 Nov 2025 106,583.0028 Nov 2025 91,333.9024$15,249.10
long28 Nov 2025 91,333.9018 Dec 2025 86,243.2020−$5,090.71
short18 Dec 2025 86,243.2019 Dec 2025 85,516.401$726.82
short20 Dec 2025 88,136.9021 Dec 2025 88,360.901−$223.96
long21 Dec 2025 88,360.9021 Jan 2026 88,427.7031$66.75
short21 Jan 2026 88,427.7022 Jan 2026 89,454.701−$1,027.07
short23 Jan 2026 89,559.7016 Feb 2026 68,832.6024$20,727.10
long16 Feb 2026 68,832.6023 Mar 2026 67,859.0035−$973.59
short23 Mar 2026 67,859.0024 Mar 2026 70,906.401−$3,047.45
short25 Mar 2026 70,556.7026 Mar 2026 71,336.501−$779.79
long26 Mar 2026 71,336.5027 Mar 2026 68,820.301−$2,516.22
short27 Mar 2026 68,820.307 Apr 2026 68,853.7011−$33.35
long7 Apr 2026 68,853.7029 Apr 2026 76,342.8022$7,489.12
short29 Apr 2026 76,342.8030 Apr 2026 75,780.001$562.78
short1 May 2026 76,346.602 May 2026 78,231.101−$1,884.55
short3 May 2026 78,686.805 May 2026 79,861.002−$1,174.17
long5 May 2026 79,861.0013 May 2026 80,504.508$643.46
short13 May 2026 80,504.5014 Jun 2026 64,458.0032$16,046.50
long14 Jun 2026 64,458.0028 Jun 2026 60,029.0014−$4,429.00
short28 Jun 2026 60,029.0030 Jun 2026 60,260.202−$231.19
long30 Jun 2026 60,260.201 Jul 2026 58,624.701−$1,635.49
short1 Jul 2026 58,624.702 Jul 2026 60,024.001−$1,399.29
long2 Jul 2026 60,024.0028 Jul 2026 63,755.9026$3,731.86
short28 Jul 2026 63,755.9031 Jul 2026 64,780.003−$1,024.17
short1 Aug 2026 62,887.905 Aug 2026 64,106.604−$1,218.67
short6 Aug 2026 64,665.208 Aug 2026 64,923.202−$257.96
long8 Aug 2026 64,923.2012 Aug 2026 63,600.004−$1,323.19
short12 Aug 2026 63,600.0019 Aug 2026 64,725.407−$1,125.41
long19 Aug 2026 64,725.403 Sep 2026 77,340.0015$12,614.60
short3 Sep 2026 77,340.004 Sep 2026 81,270.401−$3,930.36
long4 Sep 2026 81,270.405 Sep 2026 79,660.801−$1,609.60
short5 Sep 2026 79,660.8019 Sep 2026 80,883.9014−$1,223.09
short20 Sep 2026 81,250.0022 Sep 2026 86,620.002−$5,370.02
long22 Sep 2026 86,620.0030 Sep 2026 83,663.708−$2,956.35
short30 Sep 2026 83,663.701 Oct 2026 83,623.601$40.07
short2 Oct 2026 84,880.103 Oct 2026 84,518.001$362.05
short4 Oct 2026 84,753.605 Oct 2026 86,530.001−$1,776.43

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 50x Leveraged Strategy Real Equity Simulation this page—v4 strategy+16,714.7%1173,427.1%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 26 msYes 1,000 bars in 85 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/// © Noldo//@version=4strategy(title="MACD STRATEGY REAL EQUITY WITH 50X LEVERAGE",shorttitle = "MACD 50X REAL EQUITY", overlay=true,          initial_capital=100,          linktoseries = false,         default_qty_type=strategy.cash,          default_qty_value=1,          commission_type=strategy.commission.percent,          commission_value=0.0,         calc_on_order_fills = false,         calc_on_every_tick  = true,         max_bars_back = 5000,         pyramiding = 0,         precision = 0)// Variables src = close fromyear = input(2016, defval = 2009, minval = 2000, maxval = 2100, title = "From Year")toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")frommonth = input(04, defval = 04, minval = 01, maxval = 12, title = "From Month")tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")term = (time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59))// LEVERAGE ==> 50Xleverage = 50 // POSITION SIZE ==> %1 (0.01)possize = 1// MACDfastLength = input(12)slowlength = input(26)MACDLength = input(9)MACD = ema(close, fastLength) - ema(close, slowlength)aMACD = ema(MACD, MACDLength)delta = MACD - aMACD// DEFINITION : TRENDfloat trend = na trend:= delta > 0 ? 1 : -1// SL valuesstop_long = valuewhen(strategy.position_size > 0  and strategy.position_size[1] <= 0 and trend ==  1  ,strategy.position_avg_price * 0.98,0)stop_short= valuewhen(strategy.position_size < 0  and strategy.position_size[1] >= 0 and  trend == -1 ,strategy.position_avg_price * 1.02,0)// REAL LEVERAGE SIMULATION --- _lmov = strategy.position_size > 0 and strategy.position_size[1] == 0 _elmov = strategy.position_size[1] > 0 and strategy.position_size == 0_smov = strategy.position_size < 0 and strategy.position_size[1] == 0 _esmov= strategy.position_size[1] < 0 and strategy.position_size == 0 _dlmov = strategy.position_size[1] < 0 and strategy.position_size > 0 _dsmov = strategy.position_size[1] > 0 and strategy.position_size < 0 onlylong = barssince(_lmov) < barssince(_dlmov) and _lmovonlyshort = barssince(_smov) < barssince (_dsmov) and _smovonlylongexit  = barssince(_elmov) < barssince(_dsmov) and _elmovonlyshortexit = barssince(_esmov) < barssince(_dlmov) and _esmovdirectlong  = barssince(_dlmov) < barssince(_lmov) and _dlmovdirectshort = barssince(_dsmov) < barssince(_smov) and _dsmov// float capital = 0.00chg = change(strategy.position_size)ch  = strategy.position_size_l  = valuewhen(strategy.position_size > 0 and strategy.position_size[1] == 0,strategy.position_avg_price,0) // Long after Short or Long Exit_le = valuewhen(strategy.position_size[1] > 0 and strategy.position_size == 0 ,open,0)_s  = valuewhen(strategy.position_size < 0 and strategy.position_size[1] == 0,strategy.position_avg_price,0) // Short after Long or Long Exit_se = valuewhen(strategy.position_size[1] < 0 and strategy.position_size == 0 ,open,0)_dds = valuewhen(strategy.position_size < 0 and strategy.position_size[1] >= 0,strategy.position_avg_price,0) // Close Short and Long == DirectLong_ddl = valuewhen(strategy.position_size > 0 and strategy.position_size[1] <= 0,strategy.position_avg_price,0) // Close Long and Short == DirectShortpiplong = ((_le - _l) / _l) * 100 pipshort= ((_se - _s) / _s) * 100 pipdl = ((_ddl - _dds) / _dds) * 100  // Direct Longpipds = ((_dds - _ddl) / _ddl) * 100   // Direct Short// CONSTRUCTION enterLong = ((trend == 1 and term and  trend[1] != 1) or (trend == 1 and term  and trend[1] != 1 and low[1] <= stop_long) or              (trend == 1 and term and  trend[1] == 1 and low[1] <= stop_long)) // 2sLong = low <= stop_long and trend == 1 and strategy.position_size > 0 and term  // 1enterShort = ((trend == -1 and term and trend[1] != -1) or (trend == -1 and term and trend[1] != -1 and high[1] >= stop_short) or              (trend == -1 and term and trend[1] == -1 and high[1] >= stop_short)) // -2sShort = high >= stop_short and trend == -1  and strategy.position_size < 0 and term // -1float mode = namode := change(strategy.wintrades) > 0 ? 1 : change(strategy.losstrades) > 0 ? -1 : nz(mode[1], 1)pipsize = (abs(chg) - abs(ch)) capital := onlylong ? nz(capital[1], 0) - chg :            onlylongexit  ? capital[1] : onlyshort ? nz(capital[1], 0) + chg :            onlyshortexit ? capital[1] :            directlong and mode == 1 ? (capital[1]) - ch  + ((-pipsize * leverage * pipdl)/100) : directlong and mode != 1 ? capital[1] - ch  :           directshort and mode == 1 ? (capital[1]) + ch + ((pipsize * leverage * pipds)/100)  : directshort and mode != 1 ? capital[1] + ch  : capital[1]  // NET CAPITALcapita = 100 + capitalfloat netcapital = nanetcapital := netcapital[1] <= 0 ? 0 : capita// STRATEGYstrategy.entry("Long",strategy.long, comment="LONG" ,when = enterLong , qty = possize)strategy.entry("Short",strategy.short, comment="SHORT" ,when = enterShort , qty = possize)if(sLong)    strategy.close("Long",strategy.long , comment = "SL LONG")if(sShort )    strategy.close("Short" , comment = "SL SHORT")if time > timestamp(toyear, tomonth, today, 23, 59)    strategy.close_all()plot(netcapital)