Stratégie de négociation de notation multi-indicateur

Auteur:ChaoZhang est là., Date: 2023-11-07 16:16:45 Je vous en prie.
Les étiquettes:

img

Résumé

La stratégie de trading de notation multi-indicateur intègre des indicateurs techniques pour identifier la direction et la force de la tendance pour le trading automatisé. Elle prend en compte un groupe d'indicateurs, notamment Ichimoku Cloud, HMA, RSI, Stoch, CCI et MACD. Chaque résultat d'indicateur est noté et le score global est calculé en faisant la moyenne de tous les scores des indicateurs. Lorsque le score global est supérieur au seuil, allez long. Lorsque le seuil est inférieur, allez court.

La logique de la stratégie

La stratégie est composée de plusieurs parties:

  1. Calculer un groupe d'indicateurs comprenant le nuage d'Ichimoku, la moyenne mobile de la coque, l'indice de force relative, le stochastique, l'indice du canal des produits de base et la divergence de convergence de la moyenne mobile.

  2. Donnez un score positif pour le signal haussier et un score négatif pour le signal baissier.

  3. La somme et la moyenne des scores de tous les indicateurs permettent d'obtenir un score global.

  4. Comparez le score global avec le seuil prédéfini pour déterminer la direction générale de la tendance.

  5. Une position ouverte basée sur un jugement, longue en hausse, courte en baisse.

  6. Mettez un stop-loss et un profit basé sur ATR.

La stratégie utilise pleinement les avantages de plusieurs indicateurs pour déterminer l'évolution du marché.

Analyse des avantages

Les avantages de cette stratégie sont les suivants:

  1. La combinaison de plusieurs indicateurs améliore la précision du signal.

  2. Utilisez les indicateurs forces pour identifier la tendance et l'élan. Par exemple, Ichimoku Cloud pour la tendance, Stochastics pour le surachat et le survente.

  3. Le trading automatisé évite les impacts émotionnels et suit strictement les signaux de stratégie.

  4. L'utilisation de l'ATR pour le stop loss et le take profit aide à la gestion des risques.

  5. Les paramètres et le seuil de score peuvent être optimisés pour différents produits.

  6. Une logique simple et claire, facile à comprendre et à modifier.

Analyse des risques

Les risques de cette stratégie:

  1. Plusieurs indicateurs combinés ne sont pas forcément meilleurs qu'un seul. Il faut des tests répétitifs pour trouver les paramètres optimaux.

  2. Les scores moyens ne peuvent pas éviter complètement les pertes lorsque les indicateurs donnent de mauvais signaux.

  3. Les arrêts ATR peuvent être trop rapprochés ou trop lâches et doivent être ajustés en fonction du type de produit.

  4. Évitez les surajustements dus à des optimisations excessives. Testez la robustesse sur différents produits et périodes.

  5. Une fréquence de négociation élevée augmente les coûts de transaction qui affectent également le rendement final.

Directions d'optimisation

La stratégie peut être optimisée dans les aspects suivants:

  1. Testez plus de combinaisons d'indicateurs pour trouver la sélection optimale pour un produit spécifique.

  2. Ajustez les poids des indicateurs, optimisez l'algorithme.

  3. Paramètres ATR dynamiques pour mieux adapter la volatilité du marché.

  4. Ajouter des filtres de négociation pour réduire la fréquence de négociation inutile, tels que le filtre de tendance ou le filtre de volume.

  5. Optimiser par étapes pour trouver la plage de paramètres, puis optimiser au hasard / grille pour le meilleur ensemble de paramètres.

  6. Test de robustesse sur plusieurs produits et sur plusieurs délais afin d'éviter un surajustement.

  7. Combiner avec d'autres stratégies commerciales efficaces pour le portefeuille.

Conclusion

La stratégie de notation multi-indicateur améliore la précision et la fiabilité du signal en faisant la moyenne des scores des indicateurs. Avec un grand espace d'optimisation, elle peut être optimisée pour de bons résultats sur différents produits.


/*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))

Plus de