Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Multi MA Trend Following Strategy Template

A Pine Script v5 strategy built on ALMA (close, 200), EMA (close, 200) and HMA (close, 200). 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 100% of equity and pays 1 commission. 19 settings; defaults include Trend Selector JMA, Source close and MA Length 200.

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 Multi MA Trend Following Strategy Template repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
How did Multi MA Trend Following Strategy Template do on BTCUSDT 1D with default settings?
+12.25%
From 26 Jan 2024 to 21 Oct 2026, over 3 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Multi MA Trend Following Strategy Template run in Pine Script v6?
Yes
Same 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does Multi MA Trend Following Strategy Template use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Multi MA Trend Following Strategy Template run in Zeal Terminal?
Yes
It compiles in 67 ms and runs 1,000 bars in 133 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 (19)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$1,215,480$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.
Net profit
+12.25%
$122,546.00
Buy and hold
+102.5%
same period
Closed trades
3
2 won · 1 lost
Profitable
66.7%
of closed trades
Profit factor
1.50
gross profit ÷ gross loss
Max drawdown
26.91%
−$368,515.00

One run with the author's default settings, $1,000,000 starting capital, commission as the script sets it. A long 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

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    Uses an argument v6 removed

    when = on line 177, 178, 180, 181. The upgraded version below moves each call inside an if block.

Settings

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

SettingDefaultType and rangeFeeds
Date Range
Start Timetimestamp('01 Jan 2019 05:00 +0000')timeInDateRange
End Timetimestamp('01 Jan 2099 00:00 +0000')timeInDateRange
Core Settings
Trend SelectorSelect your moving averageJMAstring · options ["ALMA", "DEMA", "DSMA", "EMA", "HMA", "JMA", "KAMA", "Linear Regression (LSMA)", "RMA", "SMA", "SMMA", "Source", "SuperTrend", "TEMA", "TMA", "VAMA", "VIDYA", "VMA", "VWMA", "WMA", "WWMA", "ZLEMA"]Trend
SourceThis is the price source being used for the moving averages to calculate based onclosesourceALMA EMA HMA LinReg RMA SMA VWMA WMA de1 zeros EDSMA e0 e1 KAMA momentum volatility SMMA SuperTrend t1 TMA mid dev VIDYA ud1 dd1 pdm mdm VMA WWMA EMA1 Trend ssf
MA LengthThis is the amount of historical bars being used for the moving averages to calculate based on200int · step 5ALMA EMA HMA LinReg RMA SMA VWMA WMA de1 de2 arg stdev alpha1 beta momentum volatility SMMA t1 t2 t3 TMA mid VIDYA VMAalpha sc hhv llv VMA WWMA EMA1 EMA2
Line WidthThis is the width of the line plotted that represents the selected trend2intplot
Individual MA Settings
ALMA OffsetThis only applies when ALMA is selected0.85floatALMA
ALMA SigmaThis only applies when ALMA is selected6floatALMA
ATR Multiplier For SuperTrendThis only applies when SuperTrend is selected3floatSignal
ATR Length For SuperTrendThis only applies when SuperTrend is selected12intATR
JMA Power ParameterThis only applies when JMA is selected2intalpha
JMA Phase ParameterThis only applies when JMA is selected-45int · min -110 · max 110 · step 10phaseRatio
KAMA's AlphaThis only applies when KAMA is selected3float · min 1 · step 0.5fastAlpha
Linear Regression OffsetThis only applies when Linear Regression is selected0intLinReg
VAMA Volatility lookbackThis only applies when VAMA is selected12intvol_up vol_down
DSMA Super Smoother Filter LengthThis only applies when EDSMA is selected20int · min 1ssf
DSMA Super Smoother Filter PolesThis only applies when EDSMA is selected2int · options [2, 3]ssf
Model Long Tradestrueboolentry Long close Long line 176
Model Short Tradesfalseboolentry Short close Short line 179

What it calculates

  • ALMASource (close), MA Length (200), ALMA Offset (0.85), ALMA Sigma (6)ALMA · line 27
  • EMASource (close), MA Length (200)EMA · line 28
  • HMASource (close), MA Length (200)HMA · line 29
  • LinregSource (close), MA Length (200), Linear Regression Offset (0)LinReg · line 30
  • RMASource (close), MA Length (200)RMA · line 31
  • SMASource (close), MA Length (200)SMA · line 32
  • VWMASource (close), MA Length (200)VWMA · line 33
  • WMASource (close), MA Length (200)WMA · line 34
  • EMASource (close), MA Length (200)de1 · line 37
  • EMAde1, MA Length (200)de2 · line 38
  • Stdevssf, MA Length (200)stdev · line 69
  • ChangeSource (close), MA Length (200)momentum · line 92
  • ChangeSource (close)volatility · line 93
  • SMASource (close), MA Length (200)SMMA · line 99
  • ATRATR Length For SuperTrend (12)ATR · line 101
  • EMASource (close), MA Length (200)t1 · line 113
  • EMAt1, MA Length (200)t2 · line 114
  • EMAt2, MA Length (200)t3 · line 115
  • SMAta.sma(src, math.ceil(length / 2)), math.floor(length / 2) + 1TMA · line 118
  • EMASource (close), MA Length (200)mid · line 120
  • Highestdev, VAMA Volatility lookback (12)vol_up · line 122
  • Lowestdev, VAMA Volatility lookback (12)vol_down · line 123
  • SMASource (close), MA Length (200)VIDYA · line 133
  • HighestiS, MA Length (200)hhv · line 153
  • LowestiS, MA Length (200)llv · line 154
  • SMASource (close), MA Length (200)VMA · line 158
  • EMASource (close), MA Length (200)EMA1 · line 163
  • EMAEMA1, MA Length (200)EMA2 · line 164

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 102 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open Long longta.crossover(AccuTrend, AccuTrend[1])On177
Close Longta.crossunder(AccuTrend, AccuTrend[1])On178
Open Short shortta.crossunder(AccuTrend, AccuTrend[1])On180
Close Shortta.crossover(AccuTrend, AccuTrend[1])On181
Close (not InDateRange)On183

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.

1/1trades 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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.

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+12.3%+102.5%367%1.5026.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+10.1%+5.5%475%4.203.9%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−26.5%+9.8%333%0.4736.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+2.6%+8.4%540%1.1710.2%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−8.8%+16.7%333%0.0728.9%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+46.0%+21.5%367%86.367.3%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+27.0%+148.3%367%2.1919.7%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+16.4%+17.1%333%3.665.8%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 market0—$0.00
Sideways market367%$122,547.00
Falling market0—$0.00

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

How bad could the drawdown be?

18.0%

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

0%21%
All 3 trades
SideEntryExitBarsP&L
long19 Oct 2024 68,378.007 Mar 2025 86,801.80139$269,438.00
long14 May 2025 103,508.0025 Oct 2025 111,646.00164$99,809.40
long5 May 2026 80,905.5015 Jun 2026 66,328.7041−$246,700.00

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
Multi MA Trend Following Strategy Template this page—v5 strategy+12.3%326.9%
Multi Trend Cross Strategy Template by TradeAutomationalma ema hma linreg rma sma vwma wma stdev highest lowestv5 strategy+33.0%37.3%
Ultra Moving Average Rating Trend Strategy by exlux99ema wma highest lowest sma rma alma linreg vwma hmav5 strategy+2.8%52.4%
High-Low Channel Multi averages Crypto Swing strategy by exlux99sma ema wma alma rma linreg vwmav4 strategyNo trades on this market
Open Close Cross Strategy plus Explorer by roses27sma ema wma vwma linreg alma atrv4 strategydoes not run in Zeal Terminal
VCP pivot buy by perrycc007sma ema rma vwma wma lowest highestv4 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 strategy calls use the when = argument (line 177, 178, 180, 181). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

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

  • Line 177: when = ta.crossover(AccuTrend, AccuTrend[1]) → if block
  • Line 178: when = ta.crossunder(AccuTrend, AccuTrend[1]) → if block
  • Line 180: when = ta.crossunder(AccuTrend, AccuTrend[1]) → if block
  • Line 181: when = ta.crossover(AccuTrend, AccuTrend[1]) → if block
⋯if (InDateRange and Long==true)-    strategy.entry("Long", strategy.long, when = ta.crossover(AccuTrend, AccuTrend[1]))+    if ta.crossover(AccuTrend, AccuTrend[1])+        strategy.entry("Long", strategy.long)-    strategy.close("Long", when = ta.crossunder(AccuTrend, AccuTrend[1]))+    if ta.crossunder(AccuTrend, AccuTrend[1])+        strategy.close("Long")if (InDateRange and Short==true)-    strategy.entry("Short", strategy.short, when = ta.crossunder(AccuTrend, AccuTrend[1]))+    if ta.crossunder(AccuTrend, AccuTrend[1])+        strategy.entry("Short", strategy.short)-    strategy.close("Short", when = ta.crossover(AccuTrend, AccuTrend[1]))  +    if ta.crossover(AccuTrend, AccuTrend[1])+        strategy.close("Short")  if (not InDateRange)⋯

Does it run in Pine Script v6?

Yes

Same 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

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

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 67 msYes 1,000 bars in 133 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.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// @version=5// Author = TradeAutomationstrategy(title="Multi MA Trend Following Strategy", shorttitle="Multi Trend", process_orders_on_close=true, overlay=true, commission_type=strategy.commission.cash_per_order, commission_value=1, slippage = 0, margin_short = 75, margin_long = 75, initial_capital = 1000000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)// Backtest Date Range Inputs // StartTime = input.time(defval=timestamp('01 Jan 2019 05:00 +0000'), group="Date Range", title='Start Time')EndTime = input.time(defval=timestamp('01 Jan 2099 00:00 +0000'), group="Date Range", title='End Time')InDateRange = time>=StartTime and time<=EndTime// Trend Selector //TrendSelectorInput = input.string(title="Trend Selector", defval="JMA", group="Core Settings", options=["ALMA", "DEMA", "DSMA", "EMA", "HMA", "JMA", "KAMA", "Linear Regression (LSMA)", "RMA", "SMA", "SMMA", "Source", "SuperTrend", "TEMA", "TMA", "VAMA", "VIDYA", "VMA", "VWMA", "WMA", "WWMA", "ZLEMA"], tooltip="Select your moving average")src = input.source(close, "Source", group="Core Settings", tooltip="This is the price source being used for the moving averages to calculate based on")length = input.int(200, "MA Length", group="Core Settings", tooltip="This is the amount of historical bars being used for the moving averages to calculate based on", step=5)LineWidth = input.int(2, "Line Width", group="Core Settings", tooltip="This is the width of the line plotted that represents the selected trend")// Individual Moving Average / Regression Setting //AlmaOffset = input.float(0.85, "ALMA Offset", group="Individual MA Settings", tooltip="This only applies when ALMA is selected")AlmaSigma = input.float(6, "ALMA Sigma", group="Individual MA Settings", tooltip="This only applies when ALMA is selected")ATRFactor = input.float(3, "ATR Multiplier For SuperTrend", group="Individual MA Settings", tooltip="This only applies when SuperTrend is selected")ATRLength = input.int(12, "ATR Length For SuperTrend", group="Individual MA Settings", tooltip="This only applies when SuperTrend is selected")ssfLength = input.int(20, "DSMA Super Smoother Filter Length", minval=1, defval=20, tooltip="This only applies when EDSMA is selected")ssfPoles = input.int(2, "DSMA Super Smoother Filter Poles", options=[2, 3], tooltip="This only applies when EDSMA is selected")JMApower = input.int(2, "JMA Power Parameter", group="Individual MA Settings", tooltip="This only applies when JMA is selected")phase = input.int(-45, title="JMA Phase Parameter", step=10, minval=-110, maxval=110, group="Individual MA Settings", tooltip="This only applies when JMA is selected")KamaAlpha = input.float(3, "KAMA's Alpha", minval=1,step=0.5, group="Individual MA Settings", tooltip="This only applies when KAMA is selected")LinRegOffset = input.int(0, "Linear Regression Offset", group="Individual MA Settings", tooltip="This only applies when Linear Regression is selected")VAMALookback =input.int(12, "VAMA Volatility lookback", group="Individual MA Settings", tooltip="This only applies when VAMA is selected")// Trend Indicators in Library //ALMA = ta.alma(src, length, AlmaOffset, AlmaSigma) EMA = ta.ema(src, length)HMA = ta.hma(src, length)LinReg = ta.linreg(src, length, LinRegOffset)RMA = ta.rma(src, length)SMA = ta.sma(src, length)VWMA = ta.vwma(src, length)WMA = ta.wma(src, length)// Additional Trend Indicators Written and/or Open Sourced ////DEMAde1 = ta.ema(src, length)de2 = ta.ema(de1, length)DEMA = 2 * de1 - de2// Ehlers Deviation-Scaled Moving Average - DSMA [Everget]PI = 2 * math.asin(1)get2PoleSSF(src, length) =>    arg = math.sqrt(2) * PI / length    a1 = math.exp(-arg)    b1 = 2 * a1 * math.cos(arg)    c2 = b1    c3 = -math.pow(a1, 2)    c1 = 1 - c2 - c3    ssf = 0.0    ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2])get3PoleSSF(src, length) =>    arg = PI / length    a1 = math.exp(-arg)    b1 = 2 * a1 * math.cos(1.738 * arg)    c1 = math.pow(a1, 2)    coef2 = b1 + c1    coef3 = -(c1 + b1 * c1)    coef4 = math.pow(c1, 2)    coef1 = 1 - coef2 - coef3 - coef4    ssf = 0.0    ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3])zeros = src - nz(src[2])avgZeros = (zeros + zeros[1]) / 2// Ehlers Super Smoother Filter ssf = ssfPoles == 2     ? get2PoleSSF(avgZeros, ssfLength)     : get3PoleSSF(avgZeros, ssfLength)// Rescale filter in terms of Standard Deviationsstdev = ta.stdev(ssf, length)scaledFilter = stdev != 0     ? ssf / stdev     : 0alpha1 = 5 * math.abs(scaledFilter) / lengthEDSMA = 0.0EDSMA := alpha1 * src + (1 - alpha1) * nz(EDSMA[1])//JMA [Everget]phaseRatio = phase < -100 ? 0.5 : phase > 100 ? 2.5 : phase / 100 + 1.5beta = 0.45 * (length - 1) / (0.45 * (length - 1) + 2)alpha = math.pow(beta, JMApower)var JMA = 0.0var e0 = 0.0e0 := (1 - alpha) * src + alpha * nz(e0[1])var e1 = 0.0e1 := (src - e0) * (1 - beta) + beta * nz(e1[1])var e2 = 0.0e2 := (e0 + phaseRatio * e1 - nz(JMA[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(e2[1])JMA := e2 + nz(JMA[1])//KAMAvar KAMA = 0.0fastAlpha = 2.0 / (KamaAlpha + 1)slowAlpha = 2.0 / 31momentum = math.abs(ta.change(src, length))volatility = math.sum(math.abs(ta.change(src)), length)efficiencyRatio = volatility != 0 ? momentum / volatility : 0smoothingConstant = math.pow((efficiencyRatio * (fastAlpha - slowAlpha)) + slowAlpha, 2)KAMA := nz(KAMA[1], src) + smoothingConstant * (src - nz(KAMA[1], src))//SMMAvar SMMA = 0.0SMMA := na(SMMA[1]) ? ta.sma(src, length) : (SMMA[1] * (length - 1) + src) / length//SuperTrendATR = ta.atr(ATRLength)Signal = ATRFactor*ATRvar SuperTrend = 0.0SuperTrend := if src>SuperTrend[1] and src[1]>SuperTrend[1]    math.max(SuperTrend[1], src-Signal)else if src<SuperTrend[1] and src[1]<SuperTrend[1]    math.min(SuperTrend[1], src+Signal)else if src>SuperTrend[1]    src-Signal else     src+Signal//TEMAt1 = ta.ema(src, length)t2 = ta.ema(t1, length)t3 = ta.ema(t2, length)TEMA = 3 * (t1 - t2) + t3//TMATMA = ta.sma(ta.sma(src, math.ceil(length / 2)), math.floor(length / 2) + 1)//VAMAmid=ta.ema(src,length)dev=src-midvol_up=ta.highest(dev,VAMALookback)vol_down=ta.lowest(dev,VAMALookback)VAMA = mid+math.avg(vol_up,vol_down)//VIDYA [KivancOzbilgic]var VIDYA=0.0VMAalpha=2/(length+1)ud1=src>src[1] ? src-src[1] : 0dd1=src<src[1] ? src[1]-src : 0UD=math.sum(ud1,9)DD=math.sum(dd1,9)CMO=nz((UD-DD)/(UD+DD))VIDYA := na(VIDYA[1]) ? ta.sma(src, length) : nz(VMAalpha*math.abs(CMO)*src)+(1-VMAalpha*math.abs(CMO))*nz(VIDYA[1])//VMA [LazyBear]sc = 1/lengthpdm = math.max((src - src[1]), 0)mdm = math.max((src[1] - src), 0)var pdmS = 0.0var mdmS = 0.0pdmS := ((1 - sc)*nz(pdmS[1]) + sc*pdm)mdmS := ((1 - sc)*nz(mdmS[1]) + sc*mdm)s = pdmS + mdmSpdi = pdmS/smdi = mdmS/svar pdiS = 0.0var mdiS = 0.0pdiS := ((1 - sc)*nz(pdiS[1]) + sc*pdi)mdiS := ((1 - sc)*nz(mdiS[1]) + sc*mdi)d = math.abs(pdiS - mdiS)s1 = pdiS + mdiSvar iS = 0.0iS := ((1 - sc)*nz(iS[1]) + sc*d/s1)hhv = ta.highest(iS, length) llv = ta.lowest(iS, length) d1 = hhv - llvvi = (iS - llv)/d1var VMA=0.0VMA := na(VMA[1]) ? ta.sma(src, length) : sc*vi*src + (1 - sc*vi)*nz(VMA[1])//WWMAvar WWMA=0.0WWMA := (1/length)*src + (1-(1/length))*nz(WWMA[1])//Zero Lag EMAEMA1 = ta.ema(src,length)EMA2 = ta.ema(EMA1,length)Diff = EMA1 - EMA2ZLEMA = EMA1 + Diff// Trend Mapping and Plotting //Trend = TrendSelectorInput == "ALMA" ? ALMA : TrendSelectorInput == "DEMA" ? DEMA : TrendSelectorInput == "DSMA" ? EDSMA : TrendSelectorInput == "EMA" ? EMA : TrendSelectorInput == "HMA" ? HMA : TrendSelectorInput == "JMA" ? JMA : TrendSelectorInput == "KAMA" ? KAMA : TrendSelectorInput == "Linear Regression (LSMA)" ? LinReg : TrendSelectorInput == "RMA" ? RMA : TrendSelectorInput == "SMA" ? SMA : TrendSelectorInput == "SMMA" ? SMMA : TrendSelectorInput == "Source" ? src : TrendSelectorInput == "SuperTrend" ? SuperTrend : TrendSelectorInput == "TEMA" ? TEMA : TrendSelectorInput == "TMA" ? TMA : TrendSelectorInput == "VAMA" ? VAMA : TrendSelectorInput == "VIDYA" ? VIDYA : TrendSelectorInput == "VMA" ? VMA : TrendSelectorInput == "VWMA" ? VWMA : TrendSelectorInput == "WMA" ? WMA : TrendSelectorInput == "WWMA" ? WWMA : TrendSelectorInput == "ZLEMA" ? ZLEMA : SMAplot(Trend, color=(Trend>Trend[1]) ? color.green : (Trend<Trend[1]) ? color.red : (Trend==Trend[1]) ? color.gray : color.black, linewidth=LineWidth)//Short & Long OptionsLong = input.bool(true, "Model Long Trades")Short = input.bool(false, "Model Short Trades")//Increases Trend AccuracyAccuTrend = (Trend*1000)// Entry & Exit Functions //if (InDateRange and Long==true)    strategy.entry("Long", strategy.long, when = ta.crossover(AccuTrend, AccuTrend[1]))    strategy.close("Long", when = ta.crossunder(AccuTrend, AccuTrend[1]))if (InDateRange and Short==true)    strategy.entry("Short", strategy.short, when = ta.crossunder(AccuTrend, AccuTrend[1]))    strategy.close("Short", when = ta.crossover(AccuTrend, AccuTrend[1]))  if (not InDateRange)    strategy.close_all()