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
- 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Date Range | |||
| Start Time | timestamp('01 Jan 2019 05:00 +0000') | time | InDateRange |
| End Time | timestamp('01 Jan 2099 00:00 +0000') | time | InDateRange |
| Core Settings | |||
| Trend SelectorSelect your moving average | JMA | string · 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 on | close | source | ALMA 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 on | 200 | int · step 5 | ALMA 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 trend | 2 | int | plot |
| Individual MA Settings | |||
| ALMA OffsetThis only applies when ALMA is selected | 0.85 | float | ALMA |
| ALMA SigmaThis only applies when ALMA is selected | 6 | float | ALMA |
| ATR Multiplier For SuperTrendThis only applies when SuperTrend is selected | 3 | float | Signal |
| ATR Length For SuperTrendThis only applies when SuperTrend is selected | 12 | int | ATR |
| JMA Power ParameterThis only applies when JMA is selected | 2 | int | alpha |
| JMA Phase ParameterThis only applies when JMA is selected | -45 | int · min -110 · max 110 · step 10 | phaseRatio |
| KAMA's AlphaThis only applies when KAMA is selected | 3 | float · min 1 · step 0.5 | fastAlpha |
| Linear Regression OffsetThis only applies when Linear Regression is selected | 0 | int | LinReg |
| VAMA Volatility lookbackThis only applies when VAMA is selected | 12 | int | vol_up vol_down |
| DSMA Super Smoother Filter LengthThis only applies when EDSMA is selected | 20 | int · min 1 | ssf |
| DSMA Super Smoother Filter PolesThis only applies when EDSMA is selected | 2 | int · options [2, 3] | ssf |
| Model Long Trades | true | bool | entry Long close Long line 176 |
| Model Short Trades | false | bool | entry 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) + 1
TMA · 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
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | ta.crossover(AccuTrend, AccuTrend[1]) | On | 177 |
| Close Long | ta.crossunder(AccuTrend, AccuTrend[1]) | On | 178 |
| Open Short short | ta.crossunder(AccuTrend, AccuTrend[1]) | On | 180 |
| Close Short | ta.crossover(AccuTrend, AccuTrend[1]) | On | 181 |
| Close | (not InDateRange) | On | 183 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +12.3% | +102.5% | 3 | 67% | 1.50 | 26.9% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +10.1% | +5.5% | 4 | 75% | 4.20 | 3.9% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −26.5% | +9.8% | 3 | 33% | 0.47 | 36.8% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +2.6% | +8.4% | 5 | 40% | 1.17 | 10.2% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −8.8% | +16.7% | 3 | 33% | 0.07 | 28.9% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +46.0% | +21.5% | 3 | 67% | 86.36 | 7.3% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +27.0% | +148.3% | 3 | 67% | 2.19 | 19.7% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +16.4% | +17.1% | 3 | 33% | 3.66 | 5.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 0 | — | $0.00 |
| Sideways market | 3 | 67% | $122,547.00 |
| Falling market | 0 | — | $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.
All 3 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 19 Oct 2024 68,378.00 | 7 Mar 2025 86,801.80 | 139 | $269,438.00 |
| long | 14 May 2025 103,508.00 | 25 Oct 2025 111,646.00 | 164 | $99,809.40 |
| long | 5 May 2026 80,905.50 | 15 Jun 2026 66,328.70 | 41 | −$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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Multi MA Trend Following Strategy Template this page | — | v5 strategy | +12.3% | 3 | 26.9% |
| Multi Trend Cross Strategy Template by TradeAutomation | alma ema hma linreg rma sma vwma wma stdev highest lowest | v5 strategy | +33.0% | 3 | 7.3% |
| Ultra Moving Average Rating Trend Strategy by exlux99 | ema wma highest lowest sma rma alma linreg vwma hma | v5 strategy | +2.8% | 5 | 2.4% |
| High-Low Channel Multi averages Crypto Swing strategy by exlux99 | sma ema wma alma rma linreg vwma | v4 strategy | No trades on this market | ||
| Open Close Cross Strategy plus Explorer by roses27 | sma ema wma vwma linreg alma atr | v4 strategy | does not run in Zeal Terminal | ||
| VCP pivot buy by perrycc007 | sma ema rma vwma wma lowest highest | v4 strategy | does 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.
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.
// 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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 67 ms | Yes 1,000 bars in 133 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
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()