reinvestir 50% sur fonction backtest

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #250352 quote
    GigiGigi
    Participant
    Senior

    Bonjour,

    je voudrai si c’est possible une ligne de code pour réinvestir 50% de la + value de la stratégie.

    Ci joint mes lignes de backtests actuels. Par avance, merci.

    DEFPARAM CumulateOrders = false
    Defparam cumulateorders = false
    // TAILLE DES POSITIONS : 3 VARIABLES A PARAMÉTRER
    CAPITALInit = 2000 // Capital initial
    LEVIER = 1
    REINV = 0 // 0 = sans réinvestir / 1 = réinvestir les gains
    IF REINV = 0 THEN
    n = (CapitalInit / close) * levier
    ELSIF REINV = 1 THEN
    capital = (CAPITALinit + strategyprofit)
    n = (capital/close) * levier
    ENDIF
    n = round(n) // nombre entier

    #250370 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Oui, c’est possible.
    Il suffit d’ajouter un troisième cas dans votre code, par exemple REINV = 2, pour réinvestir seulement 50% de la plus-value :
    REINV = 0 → sans réinvestir
    REINV = 1 → réinvestir 100% des gains
    REINV = 2 → réinvestir 50% des gains
    Ainsi vous pouvez facilement choisir le mode de calcul de la taille de vos positions.

    DEFPARAM CumulateOrders = false
    // --- VARIABLES À PARAMÉTRER ---
    CAPITALInit = 2000 // Capital initial
    LEVIER = 1
    REINV = 2          // 0 = sans réinvestir / 1 = réinvestir 100% / 2 = réinvestir 50%
    
    // --- CALCUL DE LA TAILLE DES POSITIONS ---
    IF REINV = 0 THEN
    n = (CapitalInit / close) * levier
    ELSIF REINV = 1 THEN
    capital = (CAPITALinit + strategyprofit)                // 100% des gains réinvestis
    n = (capital / close) * levier
    ELSIF REINV = 2 THEN
    capital = (CAPITALinit + strategyprofit *0.5)          // Seulement 50% des gains réinvestis
    n = (capital / close) * levier
    ENDIF
    
    n = round(n) // nombre entier
    robertogozzi thanked this post
Viewing 2 posts - 1 through 2 (of 2 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

reinvestir 50% sur fonction backtest


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
Gigi @gigi Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván GonzálezIván González
1 year, 1 month ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 09/04/2025
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...