Tableau de statistiques danss un algo

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #240400 quote
    Michel_IMichel_I
    Participant
    Junior

    Bonjour !

    Désirant améliorer l’analyse d’une stratégie de trading sur indice, j’aurais besoin d’afficher un tableau (sur le graphique de préférence) qui présenterait certaines données sous la forme de statistiques : par exemple : le nombre de trades perdant de plus de 100$, le nombre de trades gagnants de plus de 100 $, … (i peut y avoir des dizaines de points interessants à analyser !).
    Est-il possible de coder cela (avec ou sans la fonction “$tableau”…) ?

    Merci de votre aide !

    Michel

    #240404 quote
    GraHalGraHal
    Participant
    Legend

    Nous pouvons voir les transactions perdantes, etc. pour chaque algorithme dans le rapport détaillé sous Transactions clôturées.

    Vous pouvez ensuite télécharger sur Excel.

    #240411 quote
    Michel_IMichel_I
    Participant
    Junior

    Merci de votre réponse. En fait je cherche à coder dans un BT (idéalement sous forme de tableau en fin de graphique) des données que l’on ne retrouve pas dans les rapports détaillés de PRT : par exemple, combien de trades shorts ont été déclenchés sur stop, pour quel montant de pertes ? combien de bougies se sont écoulées entre l’entrée et la sortie de trade ? … Bref des données d’analyse permettant d’adapter au mieux une stratégie.

    Il me semblait que le mode tableau permettait cela, mais je n’en suis pas sûr.

    Michel

    GraHal thanked this post
    #240412 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Si vous n’avez besoin que des totaux, il n’est pas nécessaire d’utiliser des tableaux, juste des variables communes que vous incrémentez à chaque fois (je ne l’ai pas essayé):

    ONCE LossesOver100  = 0
    ONCE GainsOver100   = 0
    ONCE Duration       = 0
    ONCE DurationAvg    = 0
    ONCE NumberOfTrades = 0
    
    // update winning and losing stats
    IF (StrategyProfit - StrategyProfit[1]) >= 100 THEN
       GainsOver100 = GainsOver100 + 1
    ELSIF (StrategyProfit - StrategyProfit[1]) <= -100 THEN
       LossesOver100 = LossesOver100 + 1
    ENDIF
    // update the duration of trades and calculate the average duration
    IF OnMarket THEN
       Duration    = Duration + 1
       DurationAvg = Duration / NumberOfTrades
    ENDIF
    // enter a Long position and update the number of trades
    IF MyLongConditions THEN
       BUY 1 CONTRACT AT MARKET
       NumberOfTrades = NumberOfTrades + 1
       SET STOP %LOSS 1
       SET TARGET %PROFIT 2
    ENDIF
    

    Si vous le souhaitez, vous pouvez également différencier les statistiques entre Long et Short:

    ONCE LONGLossesOver100  = 0
    ONCE LONGGainsOver100   = 0
    ONCE LONGDuration       = 0
    ONCE LONGDurationAvg    = 0
    ONCE LONGNumberOfTrades = 0
    //
    ONCE SHORTLossesOver100  = 0
    ONCE SHORTGainsOver100   = 0
    ONCE SHORTDuration       = 0
    ONCE SHORTDurationAvg    = 0
    ONCE SHORTNumberOfTrades = 0
    // update winning and losing stats
    IF (StrategyProfit - StrategyProfit[1]) >= 100 THEN
       IF LongOnMarket[1] THEN
          LONGGainsOver100 = LONGGainsOver100 + 1
       ElSIF ShortOnMarket[1] THEN
          SHORTGainsOver100 = SHORTGainsOver100 + 1
    ELSIF (StrategyProfit - StrategyProfit[1]) <= -100 THEN
       IF LongOnMarket[1] THEN
          LONGLossesOver100 = LONGLossesOver100 + 1
       ElSIF ShortOnMarket[1] THEN
          SHORTLossesOver100 = SHORTLossesOver100 + 1
    ENDIF
    // update the duration of trades and calculate the average duration
    IF LongOnMarket THEN
       LONGDuration    = LONGDuration + 1
       LONGDurationAvg = LONGDuration / LONGNumberOfTrades
    ELSIF ShortOnMarket THEN
       SHORTDuration    = SHORTDuration + 1
       SHORTDurationAvg = SHORTDuration / SHORTNumberOfTrades
    ENDIF
    // enter a Long position and update the number of trades
    IF MyLongConditions THEN
       BUY 1 CONTRACT AT MARKET
       LONGNumberOfTrades = LONGNumberOfTrades + 1
       SET STOP   %LOSS   1
       SET TARGET %PROFIT 2
    ENDIF
    // enter a Short position and update the number of trades
    IF MyShortConditions THEN
       SELLSHORT 1 CONTRACT AT MARKET
       SHORTNumberOfTrades = SHORTNumberOfTrades + 1
       SET STOP   %LOSS   1
       SET TARGET %PROFIT 2
    ENDIF

    Si toutefois vous souhaitez mémoriser les résultats de chaque opération alors vous devrez utiliser des tableaux au lieu de variables.

    Iván González thanked this post
    #240478 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Si vous souhaitez calculer des statistiques, vous pouvez utiliser cet indicateur. Il vous suffit de modifier les conditions d'entrée et de sortie.

    DEFPARAM DRAWONLASTBARONLY = true
    REM INDICADORES Y PARÁMETROS DEL SISTEMA
    ONCE DENTRO = 0
    RSI5 = RSI[5](CLOSE)
    ///////////ESTRATEGIA LARGOS///////////////////
    c1 = RSI5 CROSSES OVER 30
    entrada= c1
    IF DENTRO=0 AND entrada[1] and high>high[1] THEN
    DENTRO = 1
    BUYPRICE = max(high[1],open)
    STOPLOSS = BUYPRICE*0.94
    TAKEPROFIT = 1*(BUYPRICE-STOPLOSS)+BUYPRICE
    REM CALCULAMOS EL NÚMERO DE ACCIONES QUE HAY QUE COMPRAR
    TITULOS = ROUND(10000/BUYPRICE)
    ENDIF
    //////////////////CONDICIONES SALIDA///////////////////
    S1 = HIGH > TAKEPROFIT
    S2 = LOW < STOPLOSS
    S3 = rsi5 crosses over 70
    
    SETUPOUT = (S1 OR S2 OR S3)
    IF DENTRO=1 AND SETUPOUT THEN
    DENTRO=0
    REM VEMOS A QUÉ PRECIO SALIMOS EN FUNCIÓN DE LA CONDICIÓN DE SALIDA
    IF S1 AND OPEN > TAKEPROFIT THEN
    SELLPRICE = OPEN
    ELSIF S1 AND OPEN <= TAKEPROFIT THEN
    SELLPRICE = TAKEPROFIT
    ELSIF S3 THEN
    SELLPRICE = close
    ELSE
    IF OPEN < STOPLOSS THEN
    SELLPRICE = OPEN
    ELSE
    SELLPRICE = STOPLOSS
    ENDIF
    ENDIF
    REM ALMACENAMOS LOS RESULTADOS DE LA OPERACIÓN
    RESULTADO2 = (SELLPRICE-BUYPRICE)*TITULOS
    REM CALCULAMOS EL CAPITAL DESPUÉS DE LA OPERACIÓN
    CAPITAL = CAPITAL[1]+RESULTADO2
    ENDIF
    REM CALCULAMOS EL RESULTADO
    RESULTADO = CAPITAL - CAPITAL[1]
    REM ESTADÍSTICAS DE GANADORAS
    IF RESULTADO > 0 THEN
    NUMGANADORAS = NUMGANADORAS[1]+1
    RESULTADOGANADORAS = RESULTADO+RESULTADOGANADORAS[1]
    MEDIAGANADORAS = ROUND(RESULTADOGANADORAS/NUMGANADORAS)
    REM ESTADÍSTICAS DE PERDEDORAS
    ELSIF RESULTADO < 0 THEN
    NUMPERDEDORAS = NUMPERDEDORAS[1]+1
    RESULTADOPERDEDORAS = RESULTADO + RESULTADOPERDEDORAS[1]
    MEDIAPERDEDORAS = ROUND(RESULTADOPERDEDORAS/NUMPERDEDORAS)
    ENDIF
    //NUMERO OPERACIONES TOTAL
    NUMTOTAL = NUMGANADORAS+NUMPERDEDORAS
    //BENEFICIO NETO
    BENEFICIO = round(RESULTADOGANADORAS+RESULTADOPERDEDORAS)
    //BENEFICIO POR OPERACIÓN
    MEDIAOPERACION = ROUND(BENEFICIO/NUMTOTAL)
    //MÁXIMO DRAWDOWN $
    T = BARINDEX+1
    MAXIMOCAPITAL = HIGHEST[T](CAPITAL)
    DRAWDOWN = CAPITAL-MAXIMOCAPITAL
    MAXIMODRAWDOWN = ROUND(LOWEST[T](DRAWDOWN))
    //PROFITFACTOR
    PROFITFACTOR = RESULTADOGANADORAS/ABS(RESULTADOPERDEDORAS)
    //PORCENTAJE ACIERTO
    ACIERTO = round(NUMGANADORAS/NUMTOTAL*100)
    //PAYOFF RATIO
    PAYOFF = MEDIAGANADORAS/ABS(MEDIAPERDEDORAS)
    //EXPECTATIVA
    EXPECTATIVA = (1+PAYOFF)*ACIERTO/100-1
    DRAWTEXT("Beneficio = #BENEFICIO# $", -100,-10)ANCHOR(TOPRIGHT,XSHIFT,YSHIFT)
    DRAWTEXT("Ganancia Media = #MEDIAOPERACION# $/op", -100,-30)ANCHOR(TOPRIGHT,XSHIFT,YSHIFT)
    DRAWTEXT("Operaciones = #NUMTOTAL#", -100,-50)ANCHOR(TOPRIGHT,XSHIFT,YSHIFT)
    DRAWTEXT("% acierto = #ACIERTO# %", -100,-70)ANCHOR(TOPRIGHT,XSHIFT,YSHIFT)
    DRAWTEXT("MDD = #MAXIMODRAWDOWN# $", -100,-90)ANCHOR(TOPRIGHT,XSHIFT,YSHIFT)
    DRAWTEXT("PF = #PROFITFACTOR#", -100,-110)ANCHOR(TOPRIGHT,XSHIFT,YSHIFT)
    DRAWTEXT("PAYOFF = #PAYOFF#", -100,-130)ANCHOR(TOPRIGHT,XSHIFT,YSHIFT)
    DRAWTEXT("EXPECTATIVA = #EXPECTATIVA#", -100,-150)ANCHOR(TOPRIGHT,XSHIFT,YSHIFT)
    
    RETURN 
    
    robertogozzi thanked this post
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Tableau de statistiques danss un algo


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
Michel_I @michel_i Participant
Summary

This topic contains 4 replies,
has 4 voices, and was last updated by Iván GonzálezIván González
1 year, 11 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 11/15/2024
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...