Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Ultra Moving Average Rating Trend Strategy

A Pine Script v5 strategy built on EMA (src, len), WMA (src, len) and Change (src, len). 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. 3 settings; defaults include Rating for long 0.95 and Rating for short 0.75.

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 Ultra Moving Average Rating Trend Strategy repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Ultra Moving Average Rating Trend Strategy do on BTCUSDT 1D with default settings?
+2.80%
From 26 Jan 2024 to 21 Oct 2026, over 5 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Ultra Moving Average Rating Trend 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: 5 before, 8 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 Ultra Moving Average Rating Trend Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Ultra Moving Average Rating Trend Strategy run in Zeal Terminal?
Yes
It compiles in 809 ms and runs 1,000 bars in 2,640 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 (3)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,034,400$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
+2.80%
$28,044.50
Buy and hold
+102.5%
same period
Closed trades
5
3 won · 2 lost
Profitable
60.0%
of closed trades
Profit factor
2.09
gross profit ÷ gross loss
Max drawdown
2.38%
−$24,073.10

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

    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.

  • Note

    Uses an argument v6 removed

    when = on line 776, 777. 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
Indicator TimeframetimeframeratingMA ratingTotal
Entry Rating %
Rating for long0.95float · step 0.05long
Rating for short0.75float · step 0.05short

What it calculates

  • EMAsrc, lendema · line 8
  • WMA2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len))hullma · line 12
  • Changesrc, lenchange · line 16
  • Changesrcvolatility · line 17
  • EMAsrc, lene · line 27
  • EMAe, lentema · line 28
  • EMAzlemadata_1, lenzlema · line 34
  • Highest / LowestNN3 · line 51
  • HighestN / 2 - 1HH · line 52
  • LowestN / 2 - 1LL · line 53
  • Changesrcmom · line 82
  • EMAsrc, lenema1 · line 109
  • EMAema1, lenema2 · line 110
  • EMAema2, lenema3 · line 111
  • EMAema3, lenema4 · line 112
  • EMAema4, lenema5 · line 113
  • EMAema5, lenema6 · line 114
  • SMAta.sma(src, Nm), NmTRIMA · line 125
  • Changehighup · line 129
  • Changelowdown · line 130
  • RMAta.tr, lentruerange · line 133
  • RMAmath.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlenadx · line 140
  • SMAclose, 10SMA10 · line 158
  • SMAclose, 20SMA20 · line 159
  • SMAclose, 30SMA30 · line 160
  • SMAclose, 50SMA50 · line 161
  • SMAclose, 100SMA100 · line 162
  • SMAclose, 200SMA200 · line 163
  • EMAclose, 10EMA10 · line 164
  • EMAclose, 20EMA20 · line 165
  • EMAclose, 30EMA30 · line 166
  • EMAclose, 50EMA50 · line 167
  • EMAclose, 100EMA100 · line 168
  • EMAclose, 200EMA200 · line 169
  • ALMAclose, 10, 0.85, 6ALMA10 · line 171
  • ALMAclose, 20, 0.85, 6ALMA20 · line 172
  • ALMAclose, 50, 0.85, 6ALMA50 · line 173
  • ALMAclose, 100, 0.85, 6ALMA100 · line 174
  • ALMAclose, 200, 0.85, 6ALMA200 · line 175
  • RMAclose, 10SMMA10 · line 177
  • RMAclose, 20SMMA20 · line 178
  • RMAclose, 50SMMA50 · line 179
  • RMAclose, 100SMMA100 · line 180
  • RMAclose, 200SMMA200 · line 181
  • Linregclose, 10, 0LSMA10 · line 182
  • Linregclose, 20, 0LSMA20 · line 183
  • Linregclose, 50, 0LSMA50 · line 184
  • Linregclose, 100, 0LSMA100 · line 185
  • Linregclose, 200, 0LSMA200 · line 186
  • VWMAclose, 10VWMA10 · line 187
  • VWMAclose, 20VWMA20 · line 188
  • VWMAclose, 50VWMA50 · line 189
  • VWMAclose, 100VWMA100 · line 190
  • VWMAclose, 200VWMA200 · line 191
  • HMAclose, 10HMA10 · line 198
  • HMAclose, 20HMA20 · line 199
  • HMAclose, 50HMA50 · line 200
  • HMAclose, 100HMA100 · line 201
  • HMAclose, 200HMA200 · line 202
  • EMAclose, 50PriceAvg · line 254

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

Order rules

OrderFires whenBy defaultLine
Open long longlongtradeSignal >= rating_entryOn776
Open short shortshorttradeSignal <= rating_exitOn777

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe data1 request.security call(s), none with lookahead on.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

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+2.8%+102.5%560%2.092.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+1.4%+5.5%1127%2.120.8%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.2%+9.8%560%15.140.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%838%2.000.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%1520%0.430.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%1040%1.820.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%1030%1.280.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%838%1.270.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 market10%−$6,809.02
Sideways market475%$34,853.50
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?

2.5%

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

0%3%
All 5 trades
SideEntryExitBarsP&L
short2 May 2024 58,365.0027 Sep 2024 65,174.00148−$6,809.02
long27 Sep 2024 65,174.0027 Feb 2025 84,250.10153$19,076.10
short27 Feb 2025 84,250.109 May 2025 103,262.0071−$19,011.50
long9 May 2025 103,262.0017 Oct 2025 108,194.00161$4,932.66
short17 Oct 2025 108,194.0022 Aug 2026 78,338.00309$29,856.20

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
Ultra Moving Average Rating Trend Strategy this page—v5 strategy+2.8%52.4%
Multi Trend Cross Strategy Template by TradeAutomationalma ema hma linreg rma sma vwma wma highest lowestv5 strategy+33.0%37.3%
Multi MA Trend Following Strategy Template by TradeAutomationalma ema hma linreg rma sma vwma wma highest lowestv5 strategy+12.3%326.9%
High-Low Channel Multi averages Crypto Swing strategy by exlux99sma ema wma alma rma linreg vwmav4 strategyNo trades on this market
VCP pivot buy by perrycc007sma ema rma vwma wma lowest highestv4 strategydoes not run in Zeal Terminal
MACD Willy Strategy by PtGamblerrma sma ema highest lowest wmav5 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 strategy calls use the when = argument (line 776, 777). 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 5 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 776: when = long → if block
  • Line 777: when = short → if block
⋯short = tradeSignal <= rating_exit-strategy.entry("long",strategy.long,when=long)+if long+    strategy.entry("long",strategy.long)-strategy.entry('short',strategy.short,when=short)+if short+    strategy.entry('short',strategy.short)

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: 5 before, 8 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.

⋯// © exlux99-//@version=5+//@version=6strategy(title='Ultra Moving Average Rating Trend Strategy', overlay=true)  //,  pyramiding=1,initial_capital = 1000, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.03)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 809 msYes 1,000 bars in 2,640 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/// © exlux99//@version=5strategy(title='Ultra Moving Average Rating Trend Strategy', overlay=true)  //,  pyramiding=1,initial_capital = 1000, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.03)// ////==========DEMAgetDEMA(src, len) =>    dema = 2 * ta.ema(src, len) - ta.ema(ta.ema(src, len), len)    dema//==========HMAgetHULLMA(src, len) =>    hullma = ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len)))    hullma//==========KAMAgetKAMA(src, len, k1, k2) =>    change = math.abs(ta.change(src, len))    volatility = math.sum(math.abs(ta.change(src)), len)    efficiency_ratio = volatility != 0 ? change / volatility : 0    kama = 0.0    fast = 2 / (k1 + 1)    slow = 2 / (k2 + 1)    smooth_const = math.pow(efficiency_ratio * (fast - slow) + slow, 2)    kama := nz(kama[1]) + smooth_const * (src - nz(kama[1]))    kama//==========TEMAgetTEMA(src, len) =>    e = ta.ema(src, len)    tema = 3 * (e - ta.ema(e, len)) + ta.ema(ta.ema(e, len), len)    tema//==========ZLEMAgetZLEMA(src, len) =>    zlemalag_1 = (len - 1) / 2    zlemadata_1 = src + src - src[zlemalag_1]    zlema = ta.ema(zlemadata_1, len)    zlema//==========FRAMAgetFRAMA(src, len) =>    Price = src    N = len    if N % 2 != 0        N += 1        N    N1 = 0.0    N2 = 0.0    N3 = 0.0    HH = 0.0    LL = 0.0    Dimen = 0.0    alpha = 0.0    Filt = 0.0    N3 := (ta.highest(N) - ta.lowest(N)) / N    HH := ta.highest(N / 2 - 1)    LL := ta.lowest(N / 2 - 1)    N1 := (HH - LL) / (N / 2)    HH := high[N / 2]    LL := low[N / 2]    for i = N / 2 to N - 1 by 1        if high[i] > HH            HH := high[i]            HH        if low[i] < LL            LL := low[i]            LL    N2 := (HH - LL) / (N / 2)    if N1 > 0 and N2 > 0 and N3 > 0        Dimen := (math.log(N1 + N2) - math.log(N3)) / math.log(2)        Dimen    alpha := math.exp(-4.6 * (Dimen - 1))    if alpha < .01        alpha := .01        alpha    if alpha > 1        alpha := 1        alpha    Filt := alpha * Price + (1 - alpha) * nz(Filt[1], 1)    if bar_index < N + 1        Filt := Price        Filt    Filt//==========VIDYAgetVIDYA(src, len) =>    mom = ta.change(src)    upSum = math.sum(math.max(mom, 0), len)    downSum = math.sum(-math.min(mom, 0), len)    out = (upSum - downSum) / (upSum + downSum)    cmo = math.abs(out)    alpha = 2 / (len + 1)    vidya = 0.0    vidya := src * alpha * cmo + nz(vidya[1]) * (1 - alpha * cmo)    vidya//==========JMAgetJMA(src, len, power, phase) =>    phase_ratio = phase < -100 ? 0.5 : phase > 100 ? 2.5 : phase / 100 + 1.5    beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2)    alpha = math.pow(beta, power)    MA1 = 0.0    Det0 = 0.0    MA2 = 0.0    Det1 = 0.0    JMA = 0.0    MA1 := (1 - alpha) * src + alpha * nz(MA1[1])    Det0 := (src - MA1) * (1 - beta) + beta * nz(Det0[1])    MA2 := MA1 + phase_ratio * Det0    Det1 := (MA2 - nz(JMA[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(Det1[1])    JMA := nz(JMA[1]) + Det1    JMA//==========T3getT3(src, len, vFactor) =>    ema1 = ta.ema(src, len)    ema2 = ta.ema(ema1, len)    ema3 = ta.ema(ema2, len)    ema4 = ta.ema(ema3, len)    ema5 = ta.ema(ema4, len)    ema6 = ta.ema(ema5, len)    c1 = -1 * math.pow(vFactor, 3)    c2 = 3 * math.pow(vFactor, 2) + 3 * math.pow(vFactor, 3)    c3 = -6 * math.pow(vFactor, 2) - 3 * vFactor - 3 * math.pow(vFactor, 3)    c4 = 1 + 3 * vFactor + math.pow(vFactor, 3) + 3 * math.pow(vFactor, 2)    T3 = c1 * ema6 + c2 * ema5 + c3 * ema4 + c4 * ema3    T3//==========TRIMAgetTRIMA(src, len) =>    N = len + 1    Nm = math.round(N / 2)    TRIMA = ta.sma(ta.sma(src, Nm), Nm)    TRIMA//-------------- FUNCTIONS dirmov(len) =>    up = ta.change(high)    down = -ta.change(low)    plusDM = na(up) ? na : up > down and up > 0 ? up : 0    minusDM = na(down) ? na : down > up and down > 0 ? down : 0    truerange = ta.rma(ta.tr, len)    plus = fixnan(100 * ta.rma(plusDM, len) / truerange)    minus = fixnan(100 * ta.rma(minusDM, len) / truerange)    [plus, minus]adx(dilen, adxlen) =>    [plus, minus] = dirmov(dilen)    sum = plus + minus    adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)    adxsrc = closeres = input.timeframe("", title="Indicator Timeframe")// Ichimoku Clouddonchian(len) => math.avg(ta.lowest(len), ta.highest(len))ichimoku_cloud() =>    conversionLine = donchian(9)    baseLine = donchian(26)    leadLine1 = math.avg(conversionLine, baseLine)    leadLine2 = donchian(52)    [conversionLine, baseLine, leadLine1, leadLine2]calcRatingMA(ma, src) => na(ma) or na(src) ? na : (ma == src ? 0 : ( ma < src ? 1 : -1 ))calcRating(buy, sell) => buy ? 1 : ( sell ? -1 : 0 )calcRatingAll() =>    //============== MA =================            SMA10 = ta.sma(close, 10)    SMA20 = ta.sma(close, 20)    SMA30 = ta.sma(close, 30)    SMA50 = ta.sma(close, 50)    SMA100 = ta.sma(close, 100)    SMA200 = ta.sma(close, 200)    EMA10 = ta.ema(close, 10)    EMA20 = ta.ema(close, 20)    EMA30 = ta.ema(close, 30)    EMA50 = ta.ema(close, 50)    EMA100 = ta.ema(close, 100)    EMA200 = ta.ema(close, 200)        ALMA10 = ta.alma(close, 10, 0.85, 6)    ALMA20 = ta.alma(close, 20, 0.85, 6)    ALMA50 = ta.alma(close, 50, 0.85, 6)    ALMA100 = ta.alma(close, 100, 0.85, 6)    ALMA200 = ta.alma(close, 200, 0.85, 6)        SMMA10 = ta.rma(close, 10)    SMMA20 = ta.rma(close, 20)    SMMA50 = ta.rma(close, 50)    SMMA100 = ta.rma(close, 100)    SMMA200 = ta.rma(close, 200)    LSMA10 = ta.linreg(close, 10, 0)    LSMA20 = ta.linreg(close, 20, 0)    LSMA50 = ta.linreg(close, 50, 0)    LSMA100 = ta.linreg(close, 100, 0)    LSMA200 = ta.linreg(close, 200, 0)    VWMA10 = ta.vwma(close, 10)    VWMA20 = ta.vwma(close, 20)    VWMA50 = ta.vwma(close, 50)    VWMA100 = ta.vwma(close, 100)    VWMA200 = ta.vwma(close, 200)    DEMA10 = getDEMA(close, 10)    DEMA20 = getDEMA(close, 20)    DEMA50 = getDEMA(close, 50)    DEMA100 =getDEMA(close, 100)    DEMA200 = getDEMA(close, 200)        HMA10 =  ta.hma(close, 10)    HMA20 =  ta.hma(close, 20)    HMA50 =  ta.hma(close, 50)    HMA100 = ta.hma(close, 100)    HMA200 = ta.hma(close, 200)        KAMA10 =   getKAMA(close, 10, 2, 30)    KAMA20 =   getKAMA(close, 20, 2, 30)    KAMA50 =   getKAMA(close, 50, 2, 30)    KAMA100 =  getKAMA(close, 100, 2, 30)    KAMA200 =  getKAMA(close, 200 , 2, 30)        FRAMA10 = getFRAMA(close, 10)    FRAMA20 = getFRAMA(close, 20)    FRAMA50 = getFRAMA(close, 50)    FRAMA100 =getFRAMA(close, 100)    FRAMA200 = getFRAMA(close, 200)    VIDMA10 = getVIDYA(close, 10)    VIDMA20 = getVIDYA(close, 20)    VIDMA50 = getVIDYA(close, 50)    VIDMA100 =getVIDYA(close, 100)    VIDMA200 = getVIDYA(close, 200)        JMA10 = getJMA(close, 10, 2, 50)    JMA20 = getJMA(close, 20, 2, 50)    JMA50 = getJMA(close, 50, 2, 50)    JMA100 =getJMA(close, 100, 2, 50)    JMA200 = getJMA(close, 200, 2, 50)        TEMA10 = getTEMA(close, 10)    TEMA20 = getTEMA(close, 20)    TEMA50 = getTEMA(close, 50)    TEMA100 =getTEMA(close, 100)    TEMA200 = getTEMA(close, 200)        ZLEMA10 = getZLEMA(close, 10)    ZLEMA20 = getZLEMA(close, 20)    ZLEMA50 = getZLEMA(close, 50)    ZLEMA100 =getZLEMA(close, 100)    ZLEMA200 = getZLEMA(close, 200)        TRIMA10 = getTRIMA(close, 10)    TRIMA20 = getTRIMA(close, 20)    TRIMA50 = getTRIMA(close, 50)    TRIMA100 =getTRIMA(close, 100)    TRIMA200 = getTRIMA(close, 200)        T3MA10 = getT3(close, 10, 0.7)    T3MA20 = getT3(close, 20, 0.7)    T3MA50 = getT3(close, 50, 0.7)    T3MA100 =getT3(close, 100, 0.7)    T3MA200 = getT3(close, 200, 0.7)        [IC_CLine, IC_BLine, IC_Lead1, IC_Lead2] = ichimoku_cloud()     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    PriceAvg = ta.ema(close, 50)    DownTrend = close < PriceAvg    UpTrend = close > PriceAvg    // calculate trading recommendation based on SMA/EMA    float ratingMA = 0    float ratingMAC = 0    float ratingSMA10 = na    if not na(SMA10)        ratingSMA10 := calcRatingMA(SMA10, close)        ratingMA := ratingMA + ratingSMA10        ratingMAC := ratingMAC + 1    float ratingSMA20 = na    if not na(SMA20)        ratingSMA20 := calcRatingMA(SMA20, close)        ratingMA := ratingMA + ratingSMA20        ratingMAC := ratingMAC + 1    float ratingSMA30 = na    if not na(SMA30)        ratingSMA30 := calcRatingMA(SMA30, close)        ratingMA := ratingMA + ratingSMA30        ratingMAC := ratingMAC + 1    float ratingSMA50 = na    if not na(SMA50)        ratingSMA50 := calcRatingMA(SMA50, close)        ratingMA := ratingMA + ratingSMA50        ratingMAC := ratingMAC + 1    float ratingSMA100 = na    if not na(SMA100)        ratingSMA100 := calcRatingMA(SMA100, close)        ratingMA := ratingMA + ratingSMA100        ratingMAC := ratingMAC + 1    float ratingSMA200 = na    if not na(SMA200)        ratingSMA200 := calcRatingMA(SMA200, close)        ratingMA := ratingMA + ratingSMA200        ratingMAC := ratingMAC + 1    float ratingEMA10 = na    if not na(EMA10)        ratingEMA10 := calcRatingMA(EMA10, close)        ratingMA := ratingMA + ratingEMA10        ratingMAC := ratingMAC + 1    float ratingEMA20 = na    if not na(EMA20)        ratingEMA20 := calcRatingMA(EMA20, close)        ratingMA := ratingMA + ratingEMA20        ratingMAC := ratingMAC + 1    float ratingEMA30 = na    if not na(EMA30)        ratingEMA30 := calcRatingMA(EMA30, close)        ratingMA := ratingMA + ratingEMA30        ratingMAC := ratingMAC + 1    float ratingEMA50 = na    if not na(EMA50)        ratingEMA50 := calcRatingMA(EMA50, close)        ratingMA := ratingMA + ratingEMA50        ratingMAC := ratingMAC + 1    float ratingEMA100 = na    if not na(EMA100)        ratingEMA100 := calcRatingMA(EMA100, close)        ratingMA := ratingMA + ratingEMA100        ratingMAC := ratingMAC + 1    float ratingEMA200 = na    if not na(EMA200)        ratingEMA200 := calcRatingMA(EMA200, close)        ratingMA := ratingMA + ratingEMA200        ratingMAC := ratingMAC + 1///////////////////////////    float ratingALMA10 = na    if not na(ALMA10)        ratingALMA10 := calcRatingMA(ALMA10, close)        ratingMA := ratingMA + ratingALMA10        ratingMAC := ratingMAC + 1            float ratingALMA20 = na    if not na(ALMA20)        ratingALMA20 := calcRatingMA(ALMA20, close)        ratingMA := ratingMA + ratingALMA20        ratingMAC := ratingMAC + 1            float ratingALMA50 = na    if not na(ALMA50)        ratingALMA50 := calcRatingMA(ALMA50, close)        ratingMA := ratingMA + ratingALMA50        ratingMAC := ratingMAC + 1            float ratingALMA100 = na    if not na(ALMA100)        ratingALMA100 := calcRatingMA(ALMA100, close)        ratingMA := ratingMA + ratingALMA100        ratingMAC := ratingMAC + 1    float ratingALMA200 = na    if not na(ALMA200)        ratingALMA200 := calcRatingMA(ALMA200, close)        ratingMA := ratingMA + ratingALMA200        ratingMAC := ratingMAC + 1///////////////////////////////////////////////////////////////////////////////    float ratingSMMA10 = na    if not na(SMMA10)        ratingSMMA10 := calcRatingMA(SMMA10, close)        ratingMA := ratingMA + ratingSMMA10        ratingMAC := ratingMAC + 1            float ratingSMMA20 = na    if not na(SMMA20)        ratingSMMA20 := calcRatingMA(SMMA20, close)        ratingMA := ratingMA + ratingSMMA20        ratingMAC := ratingMAC + 1            float ratingSMMA50 = na    if not na(SMMA50)        ratingSMMA50 := calcRatingMA(SMMA50, close)        ratingMA := ratingMA + ratingSMMA50        ratingMAC := ratingMAC + 1            float ratingSMMA100 = na    if not na(SMMA100)        ratingSMMA100 := calcRatingMA(SMMA100, close)        ratingMA := ratingMA + ratingSMMA100        ratingMAC := ratingMAC + 1    float ratingSMMA200 = na    if not na(SMMA200)        ratingSMMA200 := calcRatingMA(SMMA200, close)        ratingMA := ratingMA + ratingSMMA200        ratingMAC := ratingMAC + 1///////////////////////////////////////////////////////////////////////////////    float ratingLSMA10 = na    if not na(LSMA10)        ratingLSMA10 := calcRatingMA(LSMA10, close)        ratingMA := ratingMA + ratingLSMA10        ratingMAC := ratingMAC + 1            float ratingLSMA20 = na    if not na(LSMA20)        ratingLSMA20 := calcRatingMA(LSMA20, close)        ratingMA := ratingMA + ratingLSMA20        ratingMAC := ratingMAC + 1            float ratingLSMA50 = na    if not na(LSMA50)        ratingLSMA50 := calcRatingMA(LSMA50, close)        ratingMA := ratingMA + ratingLSMA50        ratingMAC := ratingMAC + 1            float ratingLSMA100 = na    if not na(LSMA100)        ratingLSMA100 := calcRatingMA(LSMA100, close)        ratingMA := ratingMA + ratingLSMA100        ratingMAC := ratingMAC + 1    float ratingLSMA200 = na    if not na(LSMA200)        ratingLSMA200 := calcRatingMA(LSMA200, close)        ratingMA := ratingMA + ratingLSMA200        ratingMAC := ratingMAC + 1///////////////////////////////////////////////////////////////////////////////    float ratingVWMA10 = na    if not na(VWMA10)        ratingVWMA10 := calcRatingMA(VWMA10, close)        ratingMA := ratingMA + ratingVWMA10        ratingMAC := ratingMAC + 1            float ratingVWMA20 = na    if not na(VWMA20)        ratingVWMA20 := calcRatingMA(VWMA20, close)        ratingMA := ratingMA + ratingVWMA20        ratingMAC := ratingMAC + 1            float ratingVWMA50 = na    if not na(VWMA50)        ratingVWMA50 := calcRatingMA(VWMA50, close)        ratingMA := ratingMA + ratingVWMA50        ratingMAC := ratingMAC + 1            float ratingVWMA100 = na    if not na(VWMA100)        ratingVWMA100 := calcRatingMA(VWMA100, close)        ratingMA := ratingMA + ratingVWMA100        ratingMAC := ratingMAC + 1    float ratingVWMA200 = na    if not na(VWMA200)        ratingVWMA200 := calcRatingMA(VWMA200, close)        ratingMA := ratingMA + ratingVWMA200        ratingMAC := ratingMAC + 1///////////////////////////////////////////////////////////////////////////////    float ratingDEMA10 = na    if not na(DEMA10)        ratingDEMA10 := calcRatingMA(DEMA10, close)        ratingMA := ratingMA + ratingDEMA10        ratingMAC := ratingMAC + 1            float ratingDEMA20 = na    if not na(DEMA20)        ratingDEMA20 := calcRatingMA(DEMA20, close)        ratingMA := ratingMA + ratingDEMA20        ratingMAC := ratingMAC + 1            float ratingDEMA50 = na    if not na(DEMA50)        ratingDEMA50 := calcRatingMA(DEMA50, close)        ratingMA := ratingMA + ratingDEMA50        ratingMAC := ratingMAC + 1            float ratingDEMA100 = na    if not na(DEMA100)        ratingDEMA100 := calcRatingMA(DEMA100, close)        ratingMA := ratingMA + ratingDEMA100        ratingMAC := ratingMAC + 1    float ratingDEMA200 = na    if not na(DEMA200)        ratingDEMA200 := calcRatingMA(DEMA200, close)        ratingMA := ratingMA + ratingDEMA200        ratingMAC := ratingMAC + 1////////////////////////////////////////////////////    float ratingHMA10 = na    if not na(HMA10)        ratingHMA10 := calcRatingMA(HMA10, close)        ratingMA := ratingMA + ratingHMA10        ratingMAC := ratingMAC + 1            float ratingHMA20 = na    if not na(HMA20)        ratingHMA20 := calcRatingMA(HMA20, close)        ratingMA := ratingMA + ratingHMA20        ratingMAC := ratingMAC + 1            float ratingHMA50 = na    if not na(HMA50)        ratingHMA50 := calcRatingMA(HMA50, close)        ratingMA := ratingMA + ratingHMA50        ratingMAC := ratingMAC + 1            float ratingHMA100 = na    if not na(HMA100)        ratingHMA100 := calcRatingMA(HMA100, close)        ratingMA := ratingMA + ratingHMA100        ratingMAC := ratingMAC + 1    float ratingHMA200 = na    if not na(HMA200)        ratingHMA200 := calcRatingMA(HMA200, close)        ratingMA := ratingMA + ratingHMA200        ratingMAC := ratingMAC + 1///////////////////////////////////////////////////////////////////////////////    float ratingKAMA10 = na    if not na(KAMA10)        ratingKAMA10 := calcRatingMA(KAMA10, close)        ratingMA := ratingMA + ratingKAMA10        ratingMAC := ratingMAC + 1            float ratingKAMA20 = na    if not na(KAMA20)        ratingKAMA20 := calcRatingMA(KAMA20, close)        ratingMA := ratingMA + ratingKAMA20        ratingMAC := ratingMAC + 1            float ratingKAMA50 = na    if not na(KAMA50)        ratingKAMA50 := calcRatingMA(KAMA50, close)        ratingMA := ratingMA + ratingKAMA50        ratingMAC := ratingMAC + 1            float ratingKAMA100 = na    if not na(KAMA100)        ratingKAMA100 := calcRatingMA(KAMA100, close)        ratingMA := ratingMA + ratingKAMA100        ratingMAC := ratingMAC + 1    float ratingKAMA200 = na    if not na(KAMA200)        ratingKAMA200 := calcRatingMA(KAMA200, close)        ratingMA := ratingMA + ratingKAMA200        ratingMAC := ratingMAC + 1///////////////////////////////////////////////////////////////////////////////    float ratingFRAMA10 = na    if not na(FRAMA10)        ratingFRAMA10 := calcRatingMA(FRAMA10, close)        ratingMA := ratingMA + ratingFRAMA10        ratingMAC := ratingMAC + 1            float ratingFRAMA20 = na    if not na(FRAMA20)        ratingFRAMA20 := calcRatingMA(FRAMA20, close)        ratingMA := ratingMA + ratingFRAMA20        ratingMAC := ratingMAC + 1            float ratingFRAMA50 = na    if not na(FRAMA50)        ratingFRAMA50 := calcRatingMA(FRAMA50, close)        ratingMA := ratingMA + ratingFRAMA50        ratingMAC := ratingMAC + 1            float ratingFRAMA100 = na    if not na(FRAMA100)        ratingFRAMA100 := calcRatingMA(FRAMA100, close)        ratingMA := ratingMA + ratingFRAMA100        ratingMAC := ratingMAC + 1    float ratingFRAMA200 = na    if not na(FRAMA200)        ratingFRAMA200 := calcRatingMA(FRAMA200, close)        ratingMA := ratingMA + ratingFRAMA200        ratingMAC := ratingMAC + 1///////////////////////////////////////////////////////////////////////////////    float ratingVIDMA10 = na    if not na(VIDMA10)        ratingVIDMA10 := calcRatingMA(VIDMA10, close)        ratingMA := ratingMA + ratingVIDMA10        ratingMAC := ratingMAC + 1            float ratingVIDMA20 = na    if not na(VIDMA20)        ratingVIDMA20 := calcRatingMA(VIDMA20, close)        ratingMA := ratingMA + ratingVIDMA20        ratingMAC := ratingMAC + 1            float ratingVIDMA50 = na    if not na(VIDMA50)        ratingVIDMA50 := calcRatingMA(VIDMA50, close)        ratingMA := ratingMA + ratingVIDMA50        ratingMAC := ratingMAC + 1            float ratingVIDMA100 = na    if not na(VIDMA100)        ratingVIDMA100 := calcRatingMA(VIDMA100, close)        ratingMA := ratingMA + ratingVIDMA100        ratingMAC := ratingMAC + 1    float ratingVIDMA200 = na       if not na(VIDMA200)        ratingVIDMA200 := calcRatingMA(VIDMA200, close)        ratingMA := ratingMA + ratingVIDMA200        ratingMAC := ratingMAC + 1////////////////////////////////////////////////////    float ratingJMA10 = na    if not na(JMA10)        ratingJMA10 := calcRatingMA(JMA10, close)        ratingMA := ratingMA + ratingJMA10        ratingMAC := ratingMAC + 1            float ratingJMA20 = na    if not na(JMA20)        ratingJMA20 := calcRatingMA(JMA20, close)        ratingMA := ratingMA + ratingJMA20        ratingMAC := ratingMAC + 1            float ratingJMA50 = na    if not na(JMA50)        ratingJMA50 := calcRatingMA(JMA50, close)        ratingMA := ratingMA + ratingJMA50        ratingMAC := ratingMAC + 1            float ratingJMA100 = na    if not na(JMA100)        ratingJMA100 := calcRatingMA(JMA100, close)        ratingMA := ratingMA + ratingJMA100        ratingMAC := ratingMAC + 1    float ratingJMA200 = na    if not na(JMA200)        ratingJMA200 := calcRatingMA(JMA200, close)        ratingMA := ratingMA + ratingJMA200        ratingMAC := ratingMAC + 1///////////////////////////////////////////////////////////////////////////////    float ratingTEMA10 = na    if not na(TEMA10)        ratingTEMA10 := calcRatingMA(TEMA10, close)        ratingMA := ratingMA + ratingTEMA10        ratingMAC := ratingMAC + 1            float ratingTEMA20 = na    if not na(TEMA20)        ratingTEMA20 := calcRatingMA(TEMA20, close)        ratingMA := ratingMA + ratingTEMA20        ratingMAC := ratingMAC + 1            float ratingTEMA50 = na    if not na(TEMA50)        ratingTEMA50 := calcRatingMA(TEMA50, close)        ratingMA := ratingMA + ratingTEMA50        ratingMAC := ratingMAC + 1            float ratingTEMA100 = na    if not na(TEMA100)        ratingTEMA100 := calcRatingMA(TEMA100, close)        ratingMA := ratingMA + ratingTEMA100        ratingMAC := ratingMAC + 1    float ratingTEMA200 = na    if not na(TEMA200)        ratingTEMA200 := calcRatingMA(TEMA200, close)        ratingMA := ratingMA + ratingTEMA200        ratingMAC := ratingMAC + 1////////////////////////////////////////////////////    float ratingZLEMA10 = na    if not na(ZLEMA10)        ratingZLEMA10 := calcRatingMA(ZLEMA10, close)        ratingMA := ratingMA + ratingZLEMA10        ratingMAC := ratingMAC + 1            float ratingZLEMA20 = na    if not na(ZLEMA20)        ratingZLEMA20 := calcRatingMA(ZLEMA20, close)        ratingMA := ratingMA + ratingZLEMA20        ratingMAC := ratingMAC + 1            float ratingZLEMA50 = na    if not na(ZLEMA50)        ratingZLEMA50 := calcRatingMA(ZLEMA50, close)        ratingMA := ratingMA + ratingZLEMA50        ratingMAC := ratingMAC + 1            float ratingZLEMA100 = na    if not na(ZLEMA100)        ratingZLEMA100 := calcRatingMA(ZLEMA100, close)        ratingMA := ratingMA + ratingZLEMA100        ratingMAC := ratingMAC + 1    float ratingZLEMA200 = na    if not na(ZLEMA200)        ratingZLEMA200 := calcRatingMA(ZLEMA200, close)        ratingMA := ratingMA + ratingZLEMA200        ratingMAC := ratingMAC + 1///////////////////////////////////////////////////////////////////////////////    float ratingTRIMA10 = na    if not na(TRIMA10)        ratingTRIMA10 := calcRatingMA(TRIMA10, close)        ratingMA := ratingMA + ratingTRIMA10        ratingMAC := ratingMAC + 1            float ratingTRIMA20 = na    if not na(TRIMA20)        ratingTRIMA20 := calcRatingMA(TRIMA20, close)        ratingMA := ratingMA + ratingTRIMA20        ratingMAC := ratingMAC + 1            float ratingTRIMA50 = na    if not na(TRIMA50)        ratingTRIMA50 := calcRatingMA(TRIMA50, close)        ratingMA := ratingMA + ratingTRIMA50        ratingMAC := ratingMAC + 1            float ratingTRIMA100 = na    if not na(TRIMA100)        ratingTRIMA100 := calcRatingMA(TRIMA100, close)        ratingMA := ratingMA + ratingTRIMA100        ratingMAC := ratingMAC + 1    float ratingTRIMA200 = na    if not na(TRIMA200)        ratingTRIMA200 := calcRatingMA(TRIMA200, close)        ratingMA := ratingMA + ratingTRIMA200        ratingMAC := ratingMAC + 1////////////////////////////////////////////////////    float ratingT3MA10 = na    if not na(T3MA10)        ratingT3MA10 := calcRatingMA(T3MA10, close)        ratingMA := ratingMA + ratingT3MA10        ratingMAC := ratingMAC + 1            float ratingT3MA20 = na    if not na(T3MA20)        ratingT3MA20 := calcRatingMA(T3MA20, close)        ratingMA := ratingMA + ratingT3MA20        ratingMAC := ratingMAC + 1            float ratingT3MA50 = na    if not na(T3MA50)        ratingT3MA50 := calcRatingMA(T3MA50, close)        ratingMA := ratingMA + ratingT3MA50        ratingMAC := ratingMAC + 1            float ratingT3MA100 = na    if not na(T3MA100)        ratingT3MA100 := calcRatingMA(T3MA100, close)        ratingMA := ratingMA + ratingT3MA100        ratingMAC := ratingMAC + 1    float ratingT3MA200 = na    if not na(T3MA200)        ratingT3MA200 := calcRatingMA(T3MA200, close)        ratingMA := ratingMA + ratingT3MA200        ratingMAC := ratingMAC + 1        //////////////////////////////////////////    float ratingIC = na    if not (na(IC_Lead1) or na(IC_Lead2) or na(close) or na(close[1]) or na(IC_BLine) or na(IC_CLine))        ratingIC := calcRating(         IC_Lead1 > IC_Lead2 and close > IC_Lead1 and close < IC_BLine and close[1] < IC_CLine and close > IC_CLine,         IC_Lead2 > IC_Lead1 and close < IC_Lead2 and close > IC_BLine and close[1] > IC_CLine and close < IC_CLine)    if not na(ratingIC)        ratingMA := ratingMA + ratingIC        ratingMAC := ratingMAC + 1    ratingMA := ratingMAC > 0 ? ratingMA / ratingMAC : na    float ratingTotal = 0    float ratingTotalC = 0    if not na(ratingMA)        ratingTotal := ratingTotal + ratingMA        ratingTotalC := ratingTotalC + 1    ratingTotal := ratingTotalC > 0 ? ratingTotal / ratingTotalC : na    [ratingTotal,  ratingMA]getSignal2(ratingTotal,  ratingMA) =>    float _res = ratingTotal    _res := ratingMA    [ratingTotal, ratingMA]  = request.security(syminfo.tickerid, res, calcRatingAll())tradeSignal = getSignal2(ratingTotal,  ratingMA)rating_entry = input.float(0.95, title='Rating for long', group="Entry Rating %", step=0.05)rating_exit = input.float(0.75, title='Rating for short', group="Entry Rating %", step=0.05) * -1long = tradeSignal >= rating_entry  short = tradeSignal <= rating_exitstrategy.entry("long",strategy.long,when=long)strategy.entry('short',strategy.short,when=short)