Cloture partielle de position avec mise à breakeven

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #204790 quote
    EzelEzel
    Participant
    New

    Bonjour a tous,

    n’ayant pas trouver de réponse a ce sujet pendant plusieurs années, je vous partage ma petite technique pour pouvoir cloturer partiellement un position avec vos robot de trading :

    je met généralement cette ligne de code au début par simplicité de lecture

    IF init=not onmarket THEN
    step=0
    init=1
    ENDIF

     

    et généralement je fais une cloture de position au moment du passage au breackeven, donc mon code de BE se note comme ceci :

    // BREAKEVEN------------------------------------------------------------------------------------------------
    
    startBreakeven0 = 24
    PointsToKeep0 = 5
    
    IF NOT ONMARKET THEN
    breakevenLevel=0
    ENDIF
    
    // BE FOR LONG---------------------------------------------------------------------------------------------
    
    IF longonmarket and step = 0 and close - tradeprice(1) >= StartBreakeven0 * pipsize THEN
    BreakevenLevel = tradeprice(1) + PointsToKeep0 * pipsize
    step = 1
    ENDIF

     

    pour pouvoir faire cloturer partiellement une position je rajoute juste après :

    IF step = 1 THEN
    sell X contracts at market //(avec X le nombre de contrat a cloturer)
    step = 2
    endif
    
    IF breakevenLevel>0 THEN
    sell AT breakevenLevel STOP
    ENDIF

     

    En espérant que cela vous aura été utile

    Nicolas thanked this post
    #204793 quote
    NicolasNicolas
    Keymaster
    Legend

    Merci beaucoup pour la référence qui sera utile à plus d’un j’en suis persuadé 😉

    Désormais, pour le breakeven, on peut utiliser une nouvelle instruction qui place le stoploss au prix d’entrée: SET STOP BREAKEVEN

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

Cloture partielle de position avec mise à breakeven


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
Ezel @ezel Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by NicolasNicolas
3 years, 11 months ago.

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