arrêt d'une stratégie pendant x périodes après une perte

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #49026 quote
    AlexMarlier
    Participant
    Average

    Bonjour,

     

    j’ai pas mal cherché sur le blog, les manuels et le forum mais je n’arrive pas à trouver un code qui puisse être adapter à mon exemple.

    Je souhaite intégrer à ma stratégie le principe suivant: après une perte je souhaite que ma stratégie s’arrête pendant X périodes/barres et reprenne ensuite.

    un grand merci par avance pour votre retour

    #49032 quote
    Nicolas
    Keymaster
    Master

    Test si la position qui vient de fermer est négative, si oui on enregistre le numéro de la barre qui a vu le trade se fermer:

    if not onmarket and onmarket[1] and positionperf(1)<0 then
     mybar = barindex[1]
    endif

     

    Si on est situé à plus de X bougies depuis cette dernière position négative alors on autorise le trading :

    if barindex-mybar>X then
     autorisetrading = 1
    else
     autorisetrading = 0
    endif

     

    Si le trading est autorisé alors on peut initier de nouvelles positions :

    if autorisetrading then
     //ACHAT
     if conditionachat then
      buy 1 contract at market
     endif
     //VENTE
     if conditionvente then
      sellshort 1 contract at market
     endif
    endif

     

    Pas testé, merci de vérifier le fonctionnement.

    #49050 quote
    AlexMarlier
    Participant
    Average

    et bien, cela marche parfaitement ! merci Nicolas

    #125827 quote
    deleted2104
    Member
    New

    Bonjour, SVP demande d’intégration dans une strategie …,  je sais pas comment faire et ou l’introduire dans ma srategie, merci de m’aider s’il vous plait

    bien cordialement yann

    strategie en PJ

    if not onmarket and onmarket[1] and positionperf(1)<0 then
       mybar = barindex[1]
    endif
    X=5
    if barindex-mybar>X then
       autorisetrading = 1
    else
       autorisetrading = 0
    endif
    if autorisetrading then
    //ACHAT
    if conditionachat then
       buy 1 contract at market
    endif
    //VENTE
    if conditionvente then
       sellshort 1 contract at market
    endif
    endif
    Vectorial-DAX-M5-_Resized.itf Capture.jpg Capture.jpg
    #125861 quote
    JC_Bywan
    Moderator
    Master

    Je reformate le code du message ci-dessus au format PRT. Voir images ci-joint si on ne sait pas faire, à la fois là où c’était demandé “avant” si on ne retrouve plus les règles en haut des messages là où on avait l’habitude de les lire, et là où c’est demandé maintenant depuis la mise à jour récente.

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

arrêt d'une stratégie pendant x périodes après une perte


ProOrder : Trading Automatique & Backtests

New Reply
Author
Summary

This topic contains 4 replies,
has 4 voices, and was last updated by JC_Bywan
5 years, 10 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 10/11/2017
Status: Active
Attachments: 4 files
Logo Logo
Loading...