Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

MACD ReLoaded STRATEGY

A Pine Script v5 strategy built on EMA (close, 12), Linreg (close, 12) and WMA (src, length). It has 2 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. 13 settings; defaults include Source close, Short Moving Average Length 12 and Long Moving Average Length 26.

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 ReLoaded STRATEGY repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 6 of 6 trades.
How did MACD ReLoaded STRATEGY do on BTCUSDT 1D with default settings?
+7.83%
From 26 Jan 2024 to 21 Oct 2026, over 31 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does MACD ReLoaded 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: 31 before, 18 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 MACD ReLoaded STRATEGY use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does MACD ReLoaded STRATEGY run in Zeal Terminal?
Yes
It compiles in 81 ms and runs 1,000 bars in 160 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 (13)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,076,610$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. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference.
Net profit
+7.83%
$78,322.40
Buy and hold
+102.5%
same period
Closed trades
31
13 won · 18 lost
Profitable
41.9%
of closed trades
Profit factor
1.86
gross profit ÷ gross loss
Max drawdown
5.11%
−$54,549.60

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

    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
Sourceclosesourcevud1 vdd1 VAR DEMA WWMA zxEMAData ZLEMA lrc lrc1 TSF HMA T3e1 ma MA12 vud11 vdd11 VAR1 DEMA1 WWMA1 zxEMAData1 ZLEMA1 lrc11 TSF1 HMA1 T3e11 ma1 MA26
Short Moving Average Length12int · min 1valpha VAR DEMA wwalpha WWMA zxLag ZLEMA lrc TSF HMA T3e1 T3e2 T3e3 T3e4 T3e5 T3e6 ma MA12 lrc1
Long Moving Average Length26int · min 1lrc1 valpha1 VAR1 DEMA1 wwalpha1 WWMA1 zxLag1 ZLEMA1 lrc11 TSF1 HMA1 T3e11 T3e21 T3e31 T3e41 T3e51 T3e61 ma1 MA26
Trigger Length9int · min 1valpha2 VAR2 DEMA2 wwalpha2 WWMA2 zxLag2 ZLEMA2 lrc2 lrc12 TSF2 HMA2 T3e12 T3e22 T3e32 T3e42 T3e52 T3e62 ma2 MATR
TILLSON T3 Volume Factor0.7float · step 0.1T3c1 T3c2 T3c3 T3c4 T3c11 T3c21 T3c31 T3c41 T3c12 T3c22 T3c32 T3c42
Bar Coloring On/Off ?trueboolbarcolor
Moving Average TypeVARstring · options ['SMA', 'EMA', 'WMA', 'DEMA', 'TMA', 'VAR', 'WWMA', 'ZLEMA', 'TSF', 'HULL', 'TILL']line 59 line 62 line 65 line 68 line 71 line 74 line 77 line 80 line 83 line 86 line 89 line 139 line 142 line 145 line 148 line 151 line 154 line 157 line 160 line 163 line 166 line 169 line 220 line 223 line 226 line 229 line 232 line 235 line 238 line 241 line 244 line 247 line 250
From Month9int · min 1 · max 12start
From Day1int · min 1 · max 31start
From Year2018int · min 999start
To Month1int · min 1 · max 12finish
To Day1int · min 1 · max 31finish
To Year9999int · min 999finish

What it calculates

  • EMASource (close), Short Moving Average Length (12)DEMA · line 25
  • LinregSource (close), Short Moving Average Length (12), 0lrc · line 39
  • LinregSource (close), Long Moving Average Length (26), 0lrc1 · line 119
  • WMA2 * ta.wma(src, length / 2) - ta.wma(src, length), math.round(math.sqrt(length))HMA · line 45
  • EMASource (close), Short Moving Average Length (12)T3e1 · line 46
  • EMAT3e1, Short Moving Average Length (12)T3e2 · line 47
  • EMAT3e2, Short Moving Average Length (12)T3e3 · line 48
  • EMAT3e3, Short Moving Average Length (12)T3e4 · line 49
  • EMAT3e4, Short Moving Average Length (12)T3e5 · line 50
  • EMAT3e5, Short Moving Average Length (12)T3e6 · line 51
  • SMA / EMA / WMASource (close), Short Moving Average Length (12)ma · line 60
  • EMASource (close), Long Moving Average Length (26)DEMA1 · line 105
  • LinregSource (close), Long Moving Average Length (26), 1lrc11 · line 120
  • WMA2 * ta.wma(src, length1 / 2) - ta.wma(src, length1), math.round(math.sqrt(length1))HMA1 · line 125
  • EMASource (close), Long Moving Average Length (26)T3e11 · line 126
  • EMAT3e11, Long Moving Average Length (26)T3e21 · line 127
  • EMAT3e21, Long Moving Average Length (26)T3e31 · line 128
  • EMAT3e31, Long Moving Average Length (26)T3e41 · line 129
  • EMAT3e41, Long Moving Average Length (26)T3e51 · line 130
  • EMAT3e51, Long Moving Average Length (26)T3e61 · line 131
  • SMA / EMA / WMASource (close), Long Moving Average Length (26)ma1 · line 140
  • EMAsrc2, Trigger Length (9)DEMA2 · line 186
  • Linregsrc2, Trigger Length (9), 0lrc2 · line 200
  • Linregsrc2, Trigger Length (9), 1lrc12 · line 201
  • WMA2 * ta.wma(src2, length2 / 2) - ta.wma(src2, length2), math.round(math.sqrt(length2))HMA2 · line 206
  • EMAsrc2, Trigger Length (9)T3e12 · line 207
  • EMAT3e12, Trigger Length (9)T3e22 · line 208
  • EMAT3e22, Trigger Length (9)T3e32 · line 209
  • EMAT3e32, Trigger Length (9)T3e42 · line 210
  • EMAT3e42, Trigger Length (9)T3e52 · line 211
  • EMAT3e52, Trigger Length (9)T3e62 · line 212
  • SMA / EMA / WMAsrc2, Trigger Length (9)ma2 · line 221
  • Crossoverhist, 0buySignal · line 266
  • Crossunderhist, 0sellSignal · line 269
  • BarssincebuySignalbuy1 · line 272
  • BarssincesellSignalsell1 · line 273

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.

The script has 83 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open MacdLong longta.crossover(hist, 0)On268
Open MacdShort shortta.crossunder(hist, 0)On271

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.

6/6trades 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+7.8%+102.5%3142%1.865.1%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+1.7%+5.5%3241%1.571.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.6%+9.8%3142%2.560.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%3625%1.380.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.0%+16.7%3339%1.560.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%3435%1.520.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%3336%1.300.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%3639%1.150.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 market1136%−$7,562.48
Sideways market1540%$61,422.20
Falling market560%$24,462.60

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

How bad could the drawdown be?

4.7%

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

0%5%
All 31 trades
SideEntryExitBarsP&L
long4 Feb 2024 43,011.109 Mar 2024 68,124.2034$25,113.10
short9 Mar 2024 68,124.2022 May 2024 70,148.3074−$2,024.14
long22 May 2024 70,148.3024 May 2024 67,969.702−$2,178.68
short24 May 2024 67,969.7017 Jul 2024 65,044.0054$2,925.66
long17 Jul 2024 65,044.004 Aug 2024 60,698.0018−$4,346.01
short4 Aug 2024 60,698.0024 Aug 2024 64,037.2020−$3,339.25
long24 Aug 2024 64,037.202 Sep 2024 57,301.809−$6,735.47
short2 Sep 2024 57,301.8016 Sep 2024 59,132.0014−$1,830.23
long16 Sep 2024 59,132.0010 Oct 2024 60,636.0024$1,504.01
short10 Oct 2024 60,636.0014 Oct 2024 62,870.004−$2,234.01
long14 Oct 2024 62,870.0022 Dec 2024 97,292.0069$34,422.00
short22 Dec 2024 97,292.0019 Jan 2025 104,556.0028−$7,264.23
long19 Jan 2025 104,556.0020 Jan 2025 101,332.001−$3,224.66
short20 Jan 2025 101,332.0018 Apr 2025 84,947.9088$16,383.70
long18 Apr 2025 84,947.901 Jun 2025 104,592.0044$19,644.00
short1 Jun 2025 104,592.0010 Jul 2025 111,234.0039−$6,642.12
long10 Jul 2025 111,234.001 Aug 2025 115,764.0022$4,530.07
short1 Aug 2025 115,764.0014 Aug 2025 123,306.0013−$7,542.37
long14 Aug 2025 123,306.0020 Aug 2025 112,873.006−$10,433.50
short20 Aug 2025 112,873.0017 Sep 2025 116,789.0028−$3,916.01
long17 Sep 2025 116,789.0023 Sep 2025 112,651.006−$4,137.97
short23 Sep 2025 112,651.003 Oct 2025 120,529.0010−$7,878.36
long3 Oct 2025 120,529.0013 Oct 2025 114,959.0010−$5,570.54
short13 Oct 2025 114,959.005 Dec 2025 92,078.1053$22,880.80
long5 Dec 2025 92,078.1031 Jan 2026 84,260.5057−$7,817.56
short31 Jan 2026 84,260.505 Mar 2026 72,666.8033$11,593.70
long5 Mar 2026 72,666.8023 May 2026 75,539.5079$2,872.73
short23 May 2026 75,539.505 Jul 2026 63,144.0043$12,395.50
long5 Jul 2026 63,144.0014 Sep 2026 76,842.0071$13,698.00
short14 Sep 2026 76,842.0021 Sep 2026 81,178.007−$4,336.00
long21 Sep 2026 81,178.0011 Oct 2026 82,988.4020$1,810.34

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 ReLoaded STRATEGY this page—v5 strategy+7.8%315.1%
Linear Regression MA - Strategy by lazy_capitalistsma linreg emav5 strategy−1,240.4%10318.7%
Forex SWING Trader by SoftKill21wma ema smav4 strategyNo trades on this market
Twin Optimized Trend Tracker Strategy TOTT by KivancOzbilgiclinreg sma barssincev5 strategy+4.5%81.4%
Dazzling Bolts by OrcChieftainsma ema barssincev4 strategy+8.5%1413.0%
High-Low Channel Multi averages Crypto Swing strategy by exlux99sma ema wma linregv4 strategyNo trades on this market

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.

  • 2 settings use the untyped input() (line 7, 12). 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 31 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 7: input() → input.source()
  • Line 12: input() → input.bool()
⋯strategy('MACD ReLoaded', 'MACDReSt', overlay=true)-src = input(close, title='Source')+src = input.source(close, title='Source')length = input.int(12, 'Short Moving Average Length', minval=1)⋯T3a1 = input.float(0.7, 'TILLSON T3 Volume Factor', step=0.1)-barcoloring = input(title='Bar Coloring On/Off ?', defval=true)+barcoloring = input.bool(title='Bar Coloring On/Off ?', defval=true)mav = input.string(title='Moving Average Type', defval='VAR', options=['SMA', 'EMA', 'WMA', 'DEMA', 'TMA', 'VAR', 'WWMA', 'ZLEMA', 'TSF', 'HULL', 'TILL'])⋯

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

-//@version=5+//@version=6// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 81 msYes 1,000 bars in 160 msNot measured
PineTSNot testedNot testedNot 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.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

//@version=5// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © KivancOzbilgic//developer: Gerald Appel//author: @kivancozbilgicstrategy('MACD ReLoaded', 'MACDReSt', overlay=true)src = input(close, title='Source')length = input.int(12, 'Short Moving Average Length', minval=1)length1 = input.int(26, 'Long Moving Average Length', minval=1)length2 = input.int(9, 'Trigger Length', minval=1)T3a1 = input.float(0.7, 'TILLSON T3 Volume Factor', step=0.1)barcoloring = input(title='Bar Coloring On/Off ?', defval=true)mav = input.string(title='Moving Average Type', defval='VAR', options=['SMA', 'EMA', 'WMA', 'DEMA', 'TMA', 'VAR', 'WWMA', 'ZLEMA', 'TSF', 'HULL', 'TILL'])Var_Func(src, length) =>    valpha = 2 / (length + 1)    vud1 = src > src[1] ? src - src[1] : 0    vdd1 = src < src[1] ? src[1] - src : 0    vUD = math.sum(vud1, 9)    vDD = math.sum(vdd1, 9)    vCMO = nz((vUD - vDD) / (vUD + vDD))    VAR = 0.0    VAR := nz(valpha * math.abs(vCMO) * src) + (1 - valpha * math.abs(vCMO)) * nz(VAR[1])    VARVAR = Var_Func(src, length)DEMA = 2 * ta.ema(src, length) - ta.ema(ta.ema(src, length), length)Wwma_Func(src, length) =>    wwalpha = 1 / length    WWMA = 0.0    WWMA := wwalpha * src + (1 - wwalpha) * nz(WWMA[1])    WWMAWWMA = Wwma_Func(src, length)Zlema_Func(src, length) =>    zxLag = length / 2 == math.round(length / 2) ? length / 2 : (length - 1) / 2    zxEMAData = src + src - src[zxLag]    ZLEMA = ta.ema(zxEMAData, length)    ZLEMAZLEMA = Zlema_Func(src, length)Tsf_Func(src, length) =>    lrc = ta.linreg(src, length, 0)    lrc1 = ta.linreg(src, length, 1)    lrs = lrc - lrc1    TSF = ta.linreg(src, length, 0) + lrs    TSFTSF = Tsf_Func(src, length)HMA = ta.wma(2 * ta.wma(src, length / 2) - ta.wma(src, length), math.round(math.sqrt(length)))T3e1 = ta.ema(src, length)T3e2 = ta.ema(T3e1, length)T3e3 = ta.ema(T3e2, length)T3e4 = ta.ema(T3e3, length)T3e5 = ta.ema(T3e4, length)T3e6 = ta.ema(T3e5, length)T3c1 = -T3a1 * T3a1 * T3a1T3c2 = 3 * T3a1 * T3a1 + 3 * T3a1 * T3a1 * T3a1T3c3 = -6 * T3a1 * T3a1 - 3 * T3a1 - 3 * T3a1 * T3a1 * T3a1T3c4 = 1 + 3 * T3a1 + T3a1 * T3a1 * T3a1 + 3 * T3a1 * T3a1T3 = T3c1 * T3e6 + T3c2 * T3e5 + T3c3 * T3e4 + T3c4 * T3e3getMA(src, length) =>    ma = 0.0    if mav == 'SMA'        ma := ta.sma(src, length)        ma    if mav == 'EMA'        ma := ta.ema(src, length)        ma    if mav == 'WMA'        ma := ta.wma(src, length)        ma    if mav == 'DEMA'        ma := DEMA        ma    if mav == 'TMA'        ma := ta.sma(ta.sma(src, math.ceil(length / 2)), math.floor(length / 2) + 1)        ma    if mav == 'VAR'        ma := VAR        ma    if mav == 'WWMA'        ma := WWMA        ma    if mav == 'ZLEMA'        ma := ZLEMA        ma    if mav == 'TSF'        ma := TSF        ma    if mav == 'HULL'        ma := HMA        ma    if mav == 'TILL'        ma := T3        ma    maMA12 = getMA(src, length)Var_Func1(src, length1) =>    valpha1 = 2 / (length1 + 1)    vud11 = src > src[1] ? src - src[1] : 0    vdd11 = src < src[1] ? src[1] - src : 0    vUD1 = math.sum(vud11, 9)    vDD1 = math.sum(vdd11, 9)    vCMO1 = nz((vUD1 - vDD1) / (vUD1 + vDD1))    VAR1 = 0.0    VAR1 := nz(valpha1 * math.abs(vCMO1) * src) + (1 - valpha1 * math.abs(vCMO1)) * nz(VAR1[1])    VAR1VAR1 = Var_Func1(src, length1)DEMA1 = 2 * ta.ema(src, length1) - ta.ema(ta.ema(src, length1), length1)Wwma_Func1(src, length1) =>    wwalpha1 = 1 / length1    WWMA1 = 0.0    WWMA1 := wwalpha1 * src + (1 - wwalpha1) * nz(WWMA1[1])    WWMA1WWMA1 = Wwma_Func1(src, length1)Zlema_Func1(src, length1) =>    zxLag1 = length1 / 2 == math.round(length1 / 2) ? length1 / 2 : (length1 - 1) / 2    zxEMAData1 = src + src - src[zxLag1]    ZLEMA1 = ta.ema(zxEMAData1, length1)    ZLEMA1ZLEMA1 = Zlema_Func1(src, length1)Tsf_Func1(src, length1) =>    lrc1 = ta.linreg(src, length1, 0)    lrc11 = ta.linreg(src, length1, 1)    lrs1 = lrc1 - lrc11    TSF1 = ta.linreg(src, length1, 0) + lrs1    TSF1TSF1 = Tsf_Func1(src, length1)HMA1 = ta.wma(2 * ta.wma(src, length1 / 2) - ta.wma(src, length1), math.round(math.sqrt(length1)))T3e11 = ta.ema(src, length1)T3e21 = ta.ema(T3e11, length1)T3e31 = ta.ema(T3e21, length1)T3e41 = ta.ema(T3e31, length1)T3e51 = ta.ema(T3e41, length1)T3e61 = ta.ema(T3e51, length1)T3c11 = -T3a1 * T3a1 * T3a1T3c21 = 3 * T3a1 * T3a1 + 3 * T3a1 * T3a1 * T3a1T3c31 = -6 * T3a1 * T3a1 - 3 * T3a1 - 3 * T3a1 * T3a1 * T3a1T3c41 = 1 + 3 * T3a1 + T3a1 * T3a1 * T3a1 + 3 * T3a1 * T3a1T31 = T3c11 * T3e61 + T3c21 * T3e51 + T3c31 * T3e41 + T3c41 * T3e31getMA1(src, length1) =>    ma1 = 0.0    if mav == 'SMA'        ma1 := ta.sma(src, length1)        ma1    if mav == 'EMA'        ma1 := ta.ema(src, length1)        ma1    if mav == 'WMA'        ma1 := ta.wma(src, length1)        ma1    if mav == 'DEMA'        ma1 := DEMA1        ma1    if mav == 'TMA'        ma1 := ta.sma(ta.sma(src, math.ceil(length1 / 2)), math.floor(length1 / 2) + 1)        ma1    if mav == 'VAR'        ma1 := VAR1        ma1    if mav == 'WWMA'        ma1 := WWMA1        ma1    if mav == 'ZLEMA'        ma1 := ZLEMA1        ma1    if mav == 'TSF'        ma1 := TSF1        ma1    if mav == 'HULL'        ma1 := HMA1        ma1    if mav == 'TILL'        ma1 := T31        ma1    ma1MA26 = getMA1(src, length1)src2 = MA12 - MA26Var_Func2(src2, length2) =>    valpha2 = 2 / (length2 + 1)    vud12 = src2 > src2[1] ? src2 - src2[1] : 0    vdd12 = src2 < src2[1] ? src2[1] - src2 : 0    vUD2 = math.sum(vud12, 9)    vDD2 = math.sum(vdd12, 9)    vCMO2 = nz((vUD2 - vDD2) / (vUD2 + vDD2))    VAR2 = 0.0    VAR2 := nz(valpha2 * math.abs(vCMO2) * src2) + (1 - valpha2 * math.abs(vCMO2)) * nz(VAR2[1])    VAR2VAR2 = Var_Func2(src2, length2)DEMA2 = 2 * ta.ema(src2, length2) - ta.ema(ta.ema(src2, length2), length2)Wwma_Func2(src2, length2) =>    wwalpha2 = 1 / length2    WWMA2 = 0.0    WWMA2 := wwalpha2 * src2 + (1 - wwalpha2) * nz(WWMA2[1])    WWMA2WWMA2 = Wwma_Func2(src2, length2)Zlema_Func2(src2, length2) =>    zxLag2 = length2 / 2 == math.round(length2 / 2) ? length2 / 2 : (length2 - 1) / 2    zxEMAData2 = src2 + src2 - src2[zxLag2]    ZLEMA2 = ta.ema(zxEMAData2, length2)    ZLEMA2ZLEMA2 = Zlema_Func2(src2, length2)Tsf_Func2(src2, length2) =>    lrc2 = ta.linreg(src2, length2, 0)    lrc12 = ta.linreg(src2, length2, 1)    lrs2 = lrc2 - lrc12    TSF2 = ta.linreg(src2, length2, 0) + lrs2    TSF2TSF2 = Tsf_Func2(src2, length2)HMA2 = ta.wma(2 * ta.wma(src2, length2 / 2) - ta.wma(src2, length2), math.round(math.sqrt(length2)))T3e12 = ta.ema(src2, length2)T3e22 = ta.ema(T3e12, length2)T3e32 = ta.ema(T3e22, length2)T3e42 = ta.ema(T3e32, length2)T3e52 = ta.ema(T3e42, length2)T3e62 = ta.ema(T3e52, length2)T3c12 = -T3a1 * T3a1 * T3a1T3c22 = 3 * T3a1 * T3a1 + 3 * T3a1 * T3a1 * T3a1T3c32 = -6 * T3a1 * T3a1 - 3 * T3a1 - 3 * T3a1 * T3a1 * T3a1T3c42 = 1 + 3 * T3a1 + T3a1 * T3a1 * T3a1 + 3 * T3a1 * T3a1T32 = T3c12 * T3e62 + T3c22 * T3e52 + T3c32 * T3e42 + T3c42 * T3e32getMA2(src2, length2) =>    ma2 = 0.0    if mav == 'SMA'        ma2 := ta.sma(src2, length2)        ma2    if mav == 'EMA'        ma2 := ta.ema(src2, length2)        ma2    if mav == 'WMA'        ma2 := ta.wma(src2, length2)        ma2    if mav == 'DEMA'        ma2 := DEMA2        ma2    if mav == 'TMA'        ma2 := ta.sma(ta.sma(src2, math.ceil(length2 / 2)), math.floor(length2 / 2) + 1)        ma2    if mav == 'VAR'        ma2 := VAR2        ma2    if mav == 'WWMA'        ma2 := WWMA2        ma2    if mav == 'ZLEMA'        ma2 := ZLEMA2        ma2    if mav == 'TSF'        ma2 := TSF2        ma2    if mav == 'HULL'        ma2 := HMA2        ma2    if mav == 'TILL'        ma2 := T32        ma2    ma2MATR = getMA2(MA12 - MA26, length2)hist = src2 - MATRFromMonth = input.int(defval=9, title='From Month', minval=1, maxval=12)FromDay = input.int(defval=1, title='From Day', minval=1, maxval=31)FromYear = input.int(defval=2018, title='From Year', minval=999)ToMonth = input.int(defval=1, title='To Month', minval=1, maxval=12)ToDay = input.int(defval=1, title='To Day', minval=1, maxval=31)ToYear = input.int(defval=9999, title='To Year', minval=999)start = timestamp(FromYear, FromMonth, FromDay, 00, 00)finish = timestamp(ToYear, ToMonth, ToDay, 23, 59)window() =>    time >= start and time <= finish ? true : falsebuySignal = ta.crossover(hist, 0)if ta.crossover(hist, 0)    strategy.entry('MacdLong', strategy.long, comment='MacdLong')sellSignal = ta.crossunder(hist, 0)if ta.crossunder(hist, 0)    strategy.entry('MacdShort', strategy.short, comment='MacdShort')buy1 = ta.barssince(buySignal)sell1 = ta.barssince(sellSignal)color1 = buy1[1] < sell1[1] ? color.green : buy1[1] > sell1[1] ? color.red : nabarcolor(barcoloring ? color1 : na)//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)