Profit partiel OK – existe-il une perte partielle

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #205920 quote
    vanaerde
    Participant
    Junior

    Bonsoir à tous. (c’est mon premier post)

    Ce code de prise de profit partielle (merci Nicolas) que j’utilise sur presque tous mes algos fonctionne très bien.

    Existe-il un mécanisme permettant une sortie en perte partielle ?

    D’avance merci

    Pivana

    // Stops et objectifs
    SET STOP pLOSS 190
    SET TARGET pPROFIT 262
    partial = 0

    // sortie partielle
    if longonmarket and positionperf > (0.8/100) and partial=0 then
    sell countofposition/2 contract at market
    partial = 1
    endif

    #205948 quote
    fifi743
    Participant
    Master

    comme ceci

     

    // Stops et objectifs
    SET STOP pLOSS 190
    SET TARGET pPROFIT 262
    perte = 0
    
    // sortie partielle en perte
    si longonmarket et positionperf < (0.8/100) and perte =0 then
    sell countofposition/2 contract at market
    perte  = 1
    endif
    vanaerde thanked this post
    #206102 quote
    vanaerde
    Participant
    Junior

    Hello,

    Désolé pour la présentation de mon post – merci beaucoup pour la réponse qui me va bien

    Bonnes Fêtes

    #206222 quote
    vanaerde
    Participant
    Junior

    Bonjour à tous,

    Voilà une stratégie qui fonctionne plutôt bien avec l’indicateur supertrend.

    Pour augmenter le pourcentage de réussite du trade, la routine de vente partielle fonctionne, elle aussi, très bien.

    Sauf que  – elle ne fonctionne que sur les longs

    J’ai affiché l’instruction : graph positionperf … qui indique bien une augmentation en cas de réussite du trade en short.

    Mais impossible de prendre des profits partiels en short (vs longs)

    Quelqu’un aurait-il une idée ?

    Bonnes fêtes à tous

    Pivana

     

    DEFPARAM CumulateOrders = false // Cumul des positions désactivé
    Defparam preloadbars = 5000
    
    // variables supertrend
    Sup = SuperTrend[9.8,38] // 9.8-38
    supa = close crosses over sup
    
    Supo = SuperTrend[7.3,31] // 7.3-31
    supv = close crosses under supo
    
    //--------------------------------------------------------
    
    // Conditions pour ouvrir une position acheteuse
    if supa  then
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions pour fermer une position d'achat
    if supv  then
    SELL AT MARKET
    ENDIF
    
    //--------------------------------------------------------
    
    // Conditions pour ouvrir une position en vente à découvert
    if supv  then
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions pour fermer une position en vente à découvert
    if supa  then
    EXITSHORT AT MARKET
    ENDIF
    
    //--------------------------------------------------------
    
    // Stops et objectifs
    SET STOP pLOSS 134
    SET TARGET pPROFIT 420
    partial = 0
    
    // sortie partielle
    if longonmarket and positionperf > (0.5/100) and partial=0 then
    sell countofposition/2 contract at market
    partial = 1
    endif
    #206223 quote
    JC_Bywan
    Moderator
    Master

    Bjr, le if longonmarket de la ligne 43 limite la sortie partielle aux longs… il faut écrire une portion de code équivalente avec if shortonmarket pour gérer la partie sortie partielle de short, sans oublier d’utiliser un exitshort au lieu d’un sell

    vanaerde thanked this post
    #206247 quote
    vanaerde
    Participant
    Junior
    IF c3 THEN
    SELLSHORT n CONTRACT AT MARKET
    if close < (tradeprice - nn)  then
    exitshort n/2 contract at market
    ENDIF
    endif

    Bonsoir,

    Finalement, rien ne fonctionne avec positionperf en short

    Alors, voila ce que j’ai imaginé et qui semble bien fonctionner (C3 = conditions d’entrée en position et nn la valeur de la target en short)

    Bons trades et bonnes fêtes à tous

    Pivana

    #206284 quote
    fifi743
    Participant
    Master

    countposition est positif pour le long et negatif pour le short

    DEFPARAM CumulateOrders = false // Cumul des positions désactivé
    Defparam preloadbars = 5000
    
    // variables supertrend
    Sup = SuperTrend[9.8,38] // 9.8-38
    supa = close crosses over sup
    
    Supo = SuperTrend[7.3,31] // 7.3-31
    supv = close crosses under supo
    if not onmarket then
    partial = 0
    partialS=0
    endif
    //--------------------------------------------------------
    
    // Conditions pour ouvrir une position acheteuse
    if supa  then
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions pour fermer une position d'achat
    if supv  then
    SELL AT MARKET
    ENDIF
    
    //--------------------------------------------------------
    
    // Conditions pour ouvrir une position en vente à découvert
    if supv  then
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions pour fermer une position en vente à découvert
    if supa  then
    EXITSHORT AT MARKET
    ENDIF
    
    //--------------------------------------------------------
    
    // Stops et objectifs
    SET STOP pLOSS 134
    SET TARGET pPROFIT 420
    
    // sortie partielle
    if longonmarket and positionperf > (0.5/100) and partial=0 then
    sell countofposition/2 contract at market
    partial = 1
    endif
    if shortonmarket and positionperf > (0.5/100) and partials=0 then
    exitshort abs(countofposition)/2 contract at market
    partials = 1
    endif
    
    
    #206334 quote
    vanaerde
    Participant
    Junior

    Merci Fifi … c’est l’erreur que je cherchais !

    Bonnes fêtes

    #206335 quote
    Marlaynicolas
    Participant
    New

    Bonjour sur quelle unité de temps utilise tu ton algo et quel indice s’il te plait

    #206380 quote
    vanaerde
    Participant
    Junior

    Bonjour Nicolas,

    Pour répondre à ta question, il me semble que c’est un morceau de code sur Nasdaq 1 ou 2mn.

    Puisque je me suis appuyé sur ton algo €/$ 3mn (100% de réussite) merci pour le partage, je t’ai transposé l’idée sur le même UT.

    Le résultat est en PJ : 94% de réussite sur 100 000 barres.

    Bonne fêtes

    E-3mn-avec-supertrend.png E-3mn-avec-supertrend.png
    #206472 quote
    Marlaynicolas
    Participant
    New

    Bonjour j’ai copier ta stratégie mais en 2 minutes le résultat est très négatif sur nasdaq

    #207223 quote
    vanaerde
    Participant
    Junior

    @fifi : encore merci – bonne année avec tes super conseils

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.

Profit partiel OK – existe-il une perte partielle


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
vanaerde @vanaerde Participant
Summary

This topic contains 11 replies,
has 4 voices, and was last updated by vanaerde
3 years, 1 month ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 12/16/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...