STOP TRADE EN COURS APRES X CHANDELIERS

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #216391 quote
    RICOU
    Participant
    New

    Bonjour,

    je recherche un petit code qui me permettrais de clôture un trade automatiquement après X bars dans un sens comme dans l’autre, auriez vous une idée.

    Par avance merci,

    #216395 quote
    fifi743
    Participant
    Master

    comme ceci apres 20 bars

     

    if barindex-tradeindex>20 then
    sell at market
    exitshort at market
    endif
    #216400 quote
    RICOU
    Participant
    New

    Merci beaucoup fifi743,

    et pour une clôture après X bars en short uniquement ça donnerait quoi?

    #216404 quote
    GraHal
    Participant
    Master
    if barindex-tradeindex>20 then
    exitshort at market
    endif
    #216405 quote
    JC_Bywan
    Moderator
    Master

    Bjr,

    Sujet concernant du code proorder, déplacé du forum “support plateforme” au forum “proorder”. Merci aussi de ne pas faire de “double post” pour ne pas créer de confusions ou de conversations parallèles, l’autre copie du même message est supprimée. Les règles d’usage des forums PRC peuvent être retrouvées dans l’encart à fond jaune clair en bas de cette page, merci.

    Astuce “gain de temps” en cas de message déplacé dans un autre forum, qu’on ne retrouve plus dans le forum de départ, l’auteur peut le retrouver plus rapidement via sa page profil, soit dans l’onglet “topic” soit dans l’onglet “replies”: https://www.prorealcode.com/user/ricou/?view=forums-topics

    #216767 quote
    RICOU
    Participant
    New

    Bonjour,

    j’ai bien essayé d’intégrer ces lignes de code dans ma stratégie mais quand je fais de back test cela ne fonctionne pas ??? ou est mon erreur ?

    merci de me corriger SVP

     

    DEFPARAM CumulateOrders = False
    parabolic = SAR[0.02,0.02,0.2]
    sto = Stochastic[5,3](close)
    signal = average[3](sto)
    mac = MACD[12,26,9](close)
    c1 = (parabolic < close)
    c2 = (signal > 50)
    c3 = (parabolic[1] > close[1])
    IF c1 AND c2 AND c3 and mac >0 THEN
    BUY 3 CONTRACT AT MARKET
    ENDIF
    c4 = (close < parabolic)
    IF c4 THEN
    SELL AT MARKET
    ENDIF
    c5 = (parabolic > close)
    c6 = (parabolic[1] < close[1])
    if not c2 and c5 and c6 and mac < 0 then
    Sellshort 3 contract at market
    endif
    c7 = (close > parabolic)
    IF c7 THEN
    EXITSHORT AT MARKET
    ENDIF
    if barindex-tradeindex>10 then
    exitshort at market
    endif
    SET STOP pTRAILING 40
    #216768 quote
    RICOU
    Participant
    New

    avec la PJ

    Code.jpg Code.jpg
    #216808 quote
    Nicolas
    Keymaster
    Master

    Avec cette version peut être ? Où je créer une variable qui stocke le barindex de ton entrée short, ensuite on fait une différence et si >=10 alors on sort.

    DEFPARAM CumulateOrders = False
    parabolic = SAR[0.02,0.02,0.2]
    sto = Stochastic[5,3](close)
    signal = average[3](sto)
    mac = MACD[12,26,9](close)
    c1 = (parabolic < close)
    c2 = (signal > 50)
    c3 = (parabolic[1] > close[1])
    IF c1 AND c2 AND c3 and mac >0 THEN
    BUY 3 CONTRACT AT MARKET
    ENDIF
    c4 = (close < parabolic)
    IF c4 THEN
    SELL AT MARKET
    ENDIF
    c5 = (parabolic > close)
    c6 = (parabolic[1] < close[1])
    if not c2 and c5 and c6 and mac < 0 then
    Sellshort 3 contract at market
    sellbar=barindex
    endif
    c7 = (close > parabolic)
    IF c7 THEN
    EXITSHORT AT MARKET
    ENDIF
    if barindex-sellbar>=10 then
    exitshort at market
    endif
    SET STOP pTRAILING 40
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

STOP TRADE EN COURS APRES X CHANDELIERS


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
RICOU @ricou Participant
Summary

This topic contains 7 replies,
has 5 voices, and was last updated by Nicolas
2 years, 8 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 06/17/2023
Status: Active
Attachments: 1 files
Logo Logo
Loading...