Estratégia de negociação de pontuação com múltiplos indicadores

Autora:ChaoZhang, Data: 2023-11-07 16:16:45
Tags:

img

Resumo

A estratégia de negociação de pontuação de múltiplos indicadores integra a pontuação de indicadores técnicos para identificar a direção da tendência e a força para a negociação automatizada. Ele considera um grupo de indicadores, incluindo Ichimoku Cloud, HMA, RSI, Stoch, CCI e MACD. Cada resultado do indicador é pontuado e a pontuação geral é calculada pela média de todos os indicadores. Quando a pontuação geral está acima do limiar, vá longo. Quando abaixo do limiar, vá curto.

Estratégia lógica

A estratégia consiste em várias partes:

  1. Calcule um grupo de indicadores, incluindo Ichimoku Cloud, Hull Moving Average, Relative Strength Index, Stochastic, Commodity Channel Index e Moving Average Convergence Divergence.

  2. Dê uma pontuação positiva para o sinal de alta e uma pontuação negativa para o sinal de baixa.

  3. Somar e mediar todas as pontuações dos indicadores para obter uma pontuação global.

  4. Compare a pontuação geral com o limiar pré-definido para determinar a direção geral da tendência.

  5. Posições abertas baseadas em julgamento, longas quando altas, curtas quando baixas.

  6. Configure stop loss e take profit com base no ATR.

A estratégia faz pleno uso das vantagens de múltiplos indicadores para determinar a tendência do mercado.

Análise das vantagens

As vantagens desta estratégia incluem:

  1. A combinação de múltiplos indicadores melhora a precisão do sinal.

  2. Utilize os pontos fortes dos indicadores para identificar tendência e impulso. Por exemplo, Ichimoku Cloud para tendência, Stochastics para sobrecompra e sobrevenda.

  3. A negociação automatizada evita impactos emocionais e segue estritamente os sinais de estratégia.

  4. Usar ATR para stop loss e take profit ajuda a gestão de riscos.

  5. Os parâmetros e o limiar de pontuação podem ser otimizados para diferentes produtos.

  6. Lógica simples e clara, fácil de entender e modificar.

Análise de riscos

Os riscos desta estratégia:

  1. Múltiples indicadores combinados não são necessariamente melhores do que um único, são necessários testes repetitivos para encontrar parâmetros ideais.

  2. As pontuações médias não podem evitar completamente as perdas quando os indicadores dão sinais errados.

  3. As paradas do ATR podem ser demasiado próximas ou demasiado soltas.

  4. Evite a sobreajuste por otimizações excessivas.

  5. A alta frequência de negociação aumenta os custos de transacção que também afectam o rendimento final.

Orientações de otimização

A estratégia pode ser otimizada nos seguintes aspectos:

  1. Teste mais combinações de indicadores para encontrar a selecção ideal para um produto específico.

  2. Ajustar os índices de pontuação, otimizar o algoritmo de pontuação.

  3. Parâmetros ATR dinâmicos para se adequarem melhor à volatilidade do mercado.

  4. Adicionar filtros de negociação para reduzir a frequência de negociação desnecessária, tais como filtro de tendência ou filtro de volume.

  5. Otimize passo a passo para encontrar a faixa de parâmetros, em seguida, otimize aleatório / grade para o melhor conjunto de parâmetros.

  6. Teste a robustez em vários produtos e prazos para evitar a sobreajuste.

  7. Combinar com outras estratégias de negociação eficazes para carteira.

Conclusão

A estratégia de pontuação de múltiplos indicadores melhora a precisão e a confiabilidade do sinal através da média de pontuações de indicadores. Com grande espaço de otimização, pode ser otimizado para bons resultados em diferentes produtos. Os riscos de sobreajuste precisam de atenção para manter a otimização de parâmetros e o teste de estratégia científico. Como uma ideia de estratégia com amplas direções de otimização, merece mais pesquisa e aplicação.


/*backtest
start: 2022-10-31 00:00:00
end: 2023-11-06 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy(title="Ichi HMA RSI Stoch CCI MACD Technicals Rating Strategy",shorttitle="TRSv420",overlay=true,default_qty_type=strategy.percent_of_equity,default_qty_value=50,commission_type=strategy.commission.percent,commission_value=0.05)
res = input("", title="Indicator Timeframe", type=input.resolution)
Period = input(defval = 14, title = "Period Length", minval = 2)
MinSignalStrength= input(title="Minimum Signal Strength", type=input.float, defval=1.1, minval=0.00, maxval=2.00, step=0.1)
Price = input(defval=open, title="Price Source", type=input.source)
Use_Only_Buy= input(false, title = "Use ONLY BUY mode",type=input.bool)
Use_Only_Sell= input(false, title = "Use ONLY SELL mode",type=input.bool)
Use_ATR_SL_TP= input(true, title = "Use ATR for TP & SL",type=input.bool)
Use_Ichimoku= input(true, title = "Use Ichimoku",type=input.bool)
Use_HMA= input(true, title = "Use Hull MA",type=input.bool)
Use_RSI= input(true, title = "Use RSI",type=input.bool)
Use_Stoch= input(true, title = "Use Stoch",type=input.bool)
Use_CCI= input(true, title = "Use CCI",type=input.bool)
Use_MACD= input(true, title = "Use MacD",type=input.bool)
// Ichimoku Cloud
donchian(len) => avg(lowest(len), highest(len))
ichimoku_cloud() =>
    conversionLine = donchian(9)
    baseLine = donchian(26)
    leadLine1 = avg(conversionLine, baseLine)
    leadLine2 = donchian(52)
    [conversionLine, baseLine, leadLine1, leadLine2]
[IC_CLine, IC_BLine, IC_Lead1, IC_Lead2] = ichimoku_cloud()    
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() =>
    //============== HMA =================
    HMA10 = hma(Price, Period)
    HMA20 = hma(Price, 20)
    HMA30 = hma(Price, 30)
    HMA50 = hma(Price, 50)
    HMA100 = hma(Price, 100)
    HMA200 = hma(Price, 200)
    // Relative Strength Index, RSI
    RSI = rsi(Price,14)
    // Stochastic
    lengthStoch = 14
    smoothKStoch = 3
    smoothDStoch = 3
    kStoch = sma(stoch(Price, high, low, lengthStoch), smoothKStoch)
    dStoch = sma(kStoch, smoothDStoch)
    // Commodity Channel Index, CCI
    CCI = cci(Price, 20)
    // Moving Average Convergence/Divergence, MACD
    [macdMACD, signalMACD, _] = macd(Price, 12, 26, 9)
    // -------------------------------------------
    PriceAvg = hma(Price, Period)
    DownTrend = Price < PriceAvg
    UpTrend = Price > PriceAvg
    float ratingMA = 0
    float ratingMAC = 0
    if(Use_HMA)
        if not na(HMA10)
            ratingMA := ratingMA + calcRatingMA(HMA10, Price)
            ratingMAC := ratingMAC + 1
        if not na(HMA20)
            ratingMA := ratingMA + calcRatingMA(HMA20, Price)
            ratingMAC := ratingMAC + 1
        if not na(HMA30)
            ratingMA := ratingMA + calcRatingMA(HMA30, Price)
            ratingMAC := ratingMAC + 1
        if not na(HMA50)
            ratingMA := ratingMA + calcRatingMA(HMA50, Price)
            ratingMAC := ratingMAC + 1
        if not na(HMA100)
            ratingMA := ratingMA + calcRatingMA(HMA100, Price)
            ratingMAC := ratingMAC + 1
        if not na(HMA200)
            ratingMA := ratingMA + calcRatingMA(HMA200, Price)
            ratingMAC := ratingMAC + 1
    if(Use_Ichimoku)
        float ratingIC = na
        if not (na(IC_Lead1) or na(IC_Lead2) or na(Price) or na(Price[1]) or na(IC_BLine) or na(IC_CLine))
            ratingIC := calcRating(
             IC_Lead1 > IC_Lead2 and Price > IC_Lead1 and Price < IC_BLine and Price[1] < IC_CLine and Price > IC_CLine,
             IC_Lead2 > IC_Lead1 and Price < IC_Lead2 and Price > IC_BLine and Price[1] > IC_CLine and Price < IC_CLine)
        if not na(ratingIC)
            ratingMA := ratingMA + ratingIC
            ratingMAC := ratingMAC + 1
    ratingMA := ratingMAC > 0 ? ratingMA / ratingMAC : na
    float ratingOther = 0
    float ratingOtherC = 0
    if(Use_RSI)
        ratingRSI = RSI
        if not(na(ratingRSI) or na(ratingRSI[1]))
            ratingOtherC := ratingOtherC + 1
            ratingOther := ratingOther + calcRating(ratingRSI < 30 and ratingRSI[1] < ratingRSI, ratingRSI > 70 and ratingRSI[1] > ratingRSI)
    if(Use_Stoch)
        if not(na(kStoch) or na(dStoch) or na(kStoch[1]) or na(dStoch[1]))
            ratingOtherC := ratingOtherC + 1
            ratingOther := ratingOther + calcRating(kStoch < 20 and dStoch < 20 and kStoch > dStoch and kStoch[1] < dStoch[1], kStoch > 80 and dStoch > 80 and kStoch < dStoch and kStoch[1] > dStoch[1])
    if(Use_CCI)
        ratingCCI = CCI
        if not(na(ratingCCI) or na(ratingCCI[1]))
            ratingOtherC := ratingOtherC + 1
            ratingOther := ratingOther + calcRating(ratingCCI < -100 and ratingCCI > ratingCCI[1], ratingCCI > 100 and ratingCCI < ratingCCI[1])
    if(Use_MACD)
        if not(na(macdMACD) or na(signalMACD))
            ratingOtherC := ratingOtherC + 1
            ratingOther := ratingOther + calcRating(macdMACD > signalMACD, macdMACD < signalMACD)
    ratingOther := ratingOtherC > 0 ? ratingOther / ratingOtherC : na
    float ratingTotal = 0
    float ratingTotalC = 0
    if not na(ratingMA)
        ratingTotal := ratingTotal + ratingMA
        ratingTotalC := ratingTotalC + 1
        ratingTotal := ratingTotal + ratingOther
        ratingTotalC := ratingTotalC + 1
    ratingTotal := ratingTotalC > 0 ? ratingTotal / ratingTotalC : na
    [ratingTotal, ratingOther, ratingMA, ratingOtherC, ratingMAC]
[ratingTotal, ratingOther, ratingMA, ratingOtherC, ratingMAC]  = security(syminfo.tickerid, res, calcRatingAll(), lookahead=false)
tradeSignal = ratingTotal+ratingOther+ratingMA
dynSLpoints(factor) => factor * atr(14) / syminfo.mintick
if not (Use_Only_Sell)
    strategy.entry("long", strategy.long, when = tradeSignal > MinSignalStrength)
if not (Use_Only_Buy)    
    strategy.entry("short", strategy.short, when = tradeSignal < -MinSignalStrength)
if(Use_ATR_SL_TP)
    strategy.exit("sl/tp", loss = dynSLpoints(3), trail_points = dynSLpoints(5), trail_offset = dynSLpoints(2))

Mais.