Programmer une sortie partielle

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #224915 quote
    netskiss
    Participant
    Average

    Bonjour,

    Je souhaiterai programmer une sortie partielle à 20 pts au dessus de l’entrée du trade puis à 40 pts mais cela ne fonctionne pas.

    DEFPARAM CumulateOrders= false
    
    debut = 090000
    fin = 180000
    niveau1 = 15000
    if intradaybarindex=0 then
    count = 0
    activeniveau1 = 0
    endif
    
    if time >= debut and time <= fin THEN
    maxorders = 1
    tradefinimemebougie= COUNTOFPOSITION=0 and COUNTOFPOSITION[1]=0 and (longtriggered or shorttriggered)
    
    if NOT ONMARKET and close[5] > niveau1 and activeniveau1 = 0 and open[1] > niveau1 and close[1] > niveau1  and count<maxorders and tradefinimemebougie = 0   THEN
    BUY 1 CONTRACTS AT niveau1 LIMIT
    ENDIF
    
    if (onmarket and lastindex<>tradeindex) OR (tradefinimemebougie = 1) then
    count=count+1
    lastindex=tradeindex
    endif
    ENDIF
    
    SELL 0.5 CONTRACTS AT TRADEPRICE+20 LIMIT 
    SELL 0.5 CONTRACTS AT TRADEPRICE+40 LIMIT 
    
    SET STOP pLoss sl

    Je ne comprends pas pourquoi il sort du trade à 15032.4 et 15024 (voir pièce jointe)

    Merci beaucoup.
    Très bonne journée

    #224919 quote
    netskiss
    Participant
    Average

    La bonne pièce jointe est la 2e

    #224932 quote
    LucasBest
    Participant
    Junior

    Lorsque la 1ère vente partielle se fait tradeprice n’est plus égale au prix d’achat initial, mais au dernier prix de vente partiel…

    Il y a plusieurs manières de régler le problème :

    DEFPARAM CumulateOrders= false
    
    debut = 090000
    fin = 180000
    niveau1 = 15000
    if intradaybarindex=0 then
    count = 0
    activeniveau1 = 0
    endif
    
    if time >= debut and time <= fin THEN
    maxorders = 1
    tradefinimemebougie= COUNTOFPOSITION=0 and COUNTOFPOSITION[1]=0 and (longtriggered or shorttriggered)
    
    if NOT ONMARKET and close[5] > niveau1 and activeniveau1 = 0 and open[1] > niveau1 and close[1] > niveau1  and count<maxorders and tradefinimemebougie = 0   THEN
    BUY 1 CONTRACTS AT niveau1 LIMIT
    Set Target Price niveau1+40 // Ajouter directement le target final
    ENDIF
    
    if (onmarket and lastindex<>tradeindex) OR (tradefinimemebougie = 1) then
    count=count+1
    lastindex=tradeindex
    endif
    ENDIF
    
    SELL 0.5 CONTRACTS AT TRADEPRICE+20 LIMIT 
    
    SET STOP pLoss sl

    Sinon, pour être plus rigoureux :

    DEFPARAM CumulateOrders= false
    
    debut = 090000
    fin = 180000
    niveau1 = 15000
    if intradaybarindex=0 then
    count = 0
    activeniveau1 = 0
    endif
    
    if time >= debut and time <= fin THEN
    maxorders = 1
    tradefinimemebougie= COUNTOFPOSITION=0 and COUNTOFPOSITION[1]=0 and (longtriggered or shorttriggered)
    
    if NOT ONMARKET and close[5] > niveau1 and activeniveau1 = 0 and open[1] > niveau1 and close[1] > niveau1  and count<maxorders and tradefinimemebougie = 0   THEN
    BUY 1 CONTRACTS AT niveau1 LIMIT
    ENDIF
    
    // s'assurer du vrai prix d'achat
    If COUNTOFPOSITION = 1 then
    Prixdachat = tradeprice
    Endif
    
    if (onmarket and lastindex<>tradeindex) OR (tradefinimemebougie = 1) then
    count=count+1
    lastindex=tradeindex
    endif
    ENDIF
    
    // programmer les ventes partielles en fonction de ce qui reste de la position
    If COUNTOFPOSITION = 1 then
    SELL 0.5 CONTRACTS AT Prixdachat+20 LIMIT
    Endif
    
    If COUNTOFPOSITION = 0.5 then
    SELL 0.5 CONTRACTS AT Prixdachat+40 LIMIT
    Endif
    
    SET STOP pLoss sl
    netskiss thanked this post
    #224942 quote
    netskiss
    Participant
    Average

    Merci beaucoup pour la réponse.
    Mais il semblerait qu’il y ait toujours un probème.

    J’ai utilisé la 2ème solution :

    Entrée à 14992.4 :
    Le premier trade sort à 15024 alors qu’il devrait sortir à 14012.4 (+20pts)
    Le 2ème trade sort à 15055 alors qu’il devrait sortir à 15032.4 (+40pts)

    🙂

    #224948 quote
    LucasBest
    Participant
    Junior

    Il faudrait afficher avec graphonprice à la fin du code, à la fois tradeprice et Prixdachat pour voir ce qui se passe exactement…

    #224950 quote
    LucasBest
    Participant
    Junior

    Merci beaucoup pour la réponse.

    Mais il semblerait qu’il y ait toujours un probème.

    J’ai utilisé la 2ème solution :

    Entrée à 14992.4 :

    Le premier trade sort à 15024 alors qu’il devrait sortir à 14012.4 (+20pts)

    Le 2ème trade sort à 15055 alors qu’il devrait sortir à 15032.4 (+40pts)

    🙂

    La seconde vente partielle est bonne : 14992.4 + 40 = 15032.4
    La 1ère est normale aussi car la vente ne peut être mise en place qu’à la bougie suivante (si je ne dis pas de bêtise)

    #224953 quote
    netskiss
    Participant
    Average

    Le 2ème trade sort à 15055 alors qu’il devrait sortir à 15032.4 🙂

    En fait ils sortent à la cloture de la bougie suivante apparemment, moi je souhaiterai qu’il puisse cloturer dans la bougie en cours s’il atteint le niveau indiqué :-(, est-ce possible ?

    #224955 quote
    LucasBest
    Participant
    Junior

    L’instruction : “Set Target Price niveau1+40” permet de sortir au prix limite indiqué, mais ne permet pas de faire une vente partielle, à part si la position a déjà été soldée partiellement…

    Soit tu as des target plus important et ça vendra au prix limite que tu veux, soit il faut se mettre dans un time frame plus petite… Car là le prix limite est déjà atteint lors du passage d’ordre alors la vente se fait à un prix plus important (ce qui n’est pas si mal en fin de compte? 🙂 )

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

Programmer une sortie partielle


Support ProOrder

New Reply
Author
author-avatar
netskiss @netskiss Participant
Summary

This topic contains 7 replies,
has 2 voices, and was last updated by LucasBest
2 years, 1 month ago.

Topic Details
Forum: Support ProOrder
Language: French
Started: 12/06/2023
Status: Active
Attachments: 3 files
Logo Logo
Loading...