Esta estrategia analiza las tendencias de precios desde múltiples ángulos mediante la adopción de varios tipos de promedios móviles, formando una señal de calificación integral para determinar la dirección de apertura. La estrategia tiene las siguientes ventajas: 1) Múltiples promedios móviles forman un sistema de calificación para mejorar la precisión del juicio; 2) Ajuste flexible de los parámetros del sistema de calificación para adaptarse a diferentes variedades; 3) Condiciones de calificación de entrada configurables para controlar riesgos.
La estrategia utiliza un total de 17 tipos diferentes de medias móviles, incluidos SMA, EMA, ALMA, SMMA, LSMA, VWMA, DEMA, HMA, KAMA, TEMA, ZLEMA, TRIMA, T3, etc.
Para cada promedio móvil, juzgue su relación con el precio de cierre. Si el promedio móvil es menor que el precio de cierre, dé 1 punto de calificación. Si es mayor, dé -1 punto de calificación. Si no puede determinar, no dé ninguna calificación.
Sumar todas las calificaciones de las medias móviles, y dividir por el número de medias móviles cuotasbles, para obtener una calificación completa.
Compare la calificación global con el umbral de calificación de entrada para determinar la dirección de apertura. Si la calificación global alcanza el umbral largo, vaya largo. Si alcanza el umbral corto, vaya corto.
La adopción de promedios móviles de diferentes períodos puede juzgar las tendencias a corto y largo plazo.
Las medias móviles múltiples mejoran la precisión
En comparación con los promedios móviles únicos o pocos, la estrategia utiliza 17 promedios móviles diferentes para la calificación, que pueden juzgar mejor la dirección de la tendencia del mercado desde más ángulos, reduciendo las desviaciones de cualquier indicador individual.
Los parámetros configurables del sistema de calificación se adaptan a las diferentes variedades
Los períodos de media móvil y los umbrales de calificación en el sistema de calificación pueden configurarse mediante parámetros, lo que hace que la estrategia sea adaptable a las diferentes características de las variedades de negociación, lo que es beneficioso para la optimización.
Condiciones de calificación de entrada configurables para controlar los riesgos
La estrategia permite configurar umbrales de calificación de entrada largos y cortos. Las señales se generan solo cuando la calificación global alcanza el umbral, evitando una apertura incorrecta durante condiciones de mercado poco claras.
El efecto puede ser débil para cada variedad
La solución es optimizar los parámetros por separado para diferentes variedades.
Mayor tasa de error en mercados de tendencias mixtas
La estrategia tiende a generar señales erróneas cuando el mercado está mezclado. La solución es elevar el umbral de calificación de entrada para reducir las operaciones en tales condiciones de mercado.
Puede ser necesaria una optimización periódica de los parámetros para el funcionamiento a largo plazo
A medida que las condiciones del mercado siguen cambiando, los parámetros fijos pueden conducir a una disminución de la eficiencia de la estrategia.
Añadir otros indicadores para la calificación, como indicadores de volatilidad, indicadores de volumen, etc., para proporcionar más dimensiones de juicio.
Prueba y optimiza los parámetros por separado para diferentes variedades para mejorar la adaptabilidad.
Establezca períodos de prueba posterior más largos como medio año, un año, para observar la duración de la efectividad del parámetro.
Investigue los efectos reales de diferentes promedios móviles en diferentes períodos para seleccionar mejores combinaciones.
Prueba métodos de aprendizaje automático para optimizar parámetros automáticamente.
La estrategia establece un sistema de calificación de múltiples promedios móviles para lograr un juicio de múltiples ángulos de las tendencias del mercado. Tiene la ventaja de parámetros configurables para adaptarse de manera flexible a diferentes variedades y controlar los riesgos de la estrategia a través del ajuste de parámetros. Además, el sistema de calificación se puede optimizar y mejorar continuamente para mejorar aún más el rendimiento de la estrategia.
/*backtest start: 2023-10-09 00:00:00 end: 2023-10-12 02:00:00 period: 1m basePeriod: 1m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © exlux99 //@version=5 strategy(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) // // //==========DEMA getDEMA(src, len) => dema = 2 * ta.ema(src, len) - ta.ema(ta.ema(src, len), len) dema //==========HMA getHULLMA(src, len) => hullma = ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len))) hullma //==========KAMA getKAMA(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 //==========TEMA getTEMA(src, len) => e = ta.ema(src, len) tema = 3 * (e - ta.ema(e, len)) + ta.ema(ta.ema(e, len), len) tema //==========ZLEMA getZLEMA(src, len) => zlemalag_1 = (len - 1) / 2 zlemadata_1 = src + src - src[zlemalag_1] zlema = ta.ema(zlemadata_1, len) zlema //==========FRAMA getFRAMA(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 //==========VIDYA getVIDYA(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 //==========JMA getJMA(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 //==========T3 getT3(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 //==========TRIMA getTRIMA(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) adx src = close res = input.timeframe("", title="Indicator Timeframe") // Ichimoku Cloud donchian(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) * -1 long = tradeSignal >= rating_entry short = tradeSignal <= rating_exit strategy.entry("long",strategy.long,when=long) strategy.entry('short',strategy.short,when=short)