mise a niveau breakeven, probleme de fermeture immediate de l’ordre !

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #171502 quote
    Yvan63
    Participant
    Senior

    Bonjour,

    Je rencontre un problème pour le moins curieux, j’ai codé une petite stratégie pour faire des essais, hier encore elle fonctionnait (les ordres s’exécutaient correctement), aujourd’hui
    elle ne fonctionne plus du tout !!
    Explication: le code ci-dessous place un STOP LOSS temporaire puis l’ajuste une fois le TRIDEPRICE connu, ensuite un BE est placé au niveau du TRIDEPRICE+1.4 , cela ne fonctionne plus, pas
    un seul ordre de vente STOP n’est respecté, de plus le programme vend à présent systématiquement à la bougie suivant l’achat, comme si le SELL AT PRIX STOP n’était pas respecté.

    Une idée ?

    Code:

    /////////////////////////////////////////////////////////////////////////////////
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    //Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
    DEFPARAM FLATBEFORE = 080000
    ////////// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
    DEFPARAM FLATAFTER = 200000
    DEFPARAM Preloadbars = 1000
    
    ONCE LongHH = 1
    ONCE MEMSTOPPRICE = 0
    ONCE MEMOSTOP = 0
    
    MM30H = Average[30,7](Close)
    
    If not Onmarket Then
    step = 0
    MemoIndex = 0
    Endif
    
    graph STEP COLOURED(50,50,75)
    // CAPITAL //
    
    CapitalInitial = 1000 // Capital initial
    CapitalReinvest = CapitalInitial+Strategyprofit
    
    // nombre de contrat
    
    TailleContrat = 1 // Nbr lot (minimum 0.5)
    
    // réinvestissement des gains
    
    ReinvestActif = 1 // activé ?
    
    If ReinvestActif = 0 then
    nblot = TailleContrat
    endif
    
    If ReinvestActif = 1 then
    nblot = (CapitalReinvest/CapitalInitial)*TailleContrat
    Endif
    
    If nblot < 0.5 then
    nblot = 0.5
    Endif
    
    //-+------------------------------------------------------------------+-//
    // | Heikin Ashi | //
    //-+------------------------------------------------------------------+-//
    if barindex>1 then
    haclose=(open+close+low+high)/4
    haopen=(haopen[1]+haclose[1])/2
    //xHigh = Max(haOpen, haClose)
    xLow = Min(haOpen, haClose)
    //hahigh = Max(High,xHigh)
    halow = Min(Low,xLow)
    endif
    //-+------------------------------------------------------------------+-//
    
    //Calcul BB inférieure et supérieure
    PeriodBB = 500
    dev = 2.3 // Ecart type
    BollInf = Average[PeriodBB](close)-dev*std[PeriodBB](close)
    
    If LongHH then // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    b1 = RSI[7](close) < 20 or RSI[7](close[1]) < 20 or RSI[7](close[2]) < 20
    
    b2 = haclose < BollInf
    
    b3 = 1
    
    b4 = haclose > haopen // bougie verte
    
    b5 = 1
    
    b6 = 1
    
    b7 = 1
    
    Btotal = b1 and b2 and b3 and b4 and b5 and b6 and b7 and Not OnMarket
    
    IF btotal THEN
    BUY nblot CONTRACT AT MARKET
    Set Target pprofit 0
    SET STOP LOSS 9 // Temporaire
    MEMSTOPPRICE = DonchianChannelDown[100]-3 // à l'instant T pour calcul ultérieur du STOPLOSS
    
    ENDIF
    
    EndIf // LongHH // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    // Ajustement du STOPLOSS une fois le prix d'ouverture de la bougie d'ordre connue
    
    IF Longonmarket and BarIndex = TradeIndex(1) and step = 0 then
    
    MEMOSTOP = Tradeprice(1)-MEMSTOPPRICE // STOPLOSS en Nbr de point
    SET STOP LOSS MEMOSTOP
    BuyN1 = Tradeprice(1)
    MemBE = BuyN1+1.4
    step = 1
    Endif
    
    ////STOP remonté à BE dés que possible
    If Longonmarket and step = 1 Then
    SELL AT MemBE STOP
    step = 2
    EndIf
    #171514 quote
    GraHal
    Participant
    Master

    Qu’entend-on par ci-dessous qui sont en pointillés ici et là dans le code… par exemple la ligne 42 et la ligne 49 ?

    < and > 

    J’ai réussi à faire fonctionner votre code en remplaçant &lt;  avec < et &gt; avec >, mais je me trompe peut-être ?? 🙂

    #171515 quote
    Yvan63
    Participant
    Senior

    &lt; and &gt ont été créés lors du copier/coller du code. Effectivement il faut les remplacer par les signes < et >

    Le problème n’est pas là, si vous avez pu faire fonctionner le code, arrivez-vous à placer l’ordre “sell AT stop” correctement ?

    Car chez moi il est exécuté immédiatement après l’achat, ce qui n’est pas normal.

    Information: il faut faire fonctionner ce code en timeframe 5 secondes

    #171517 quote
    Yvan63
    Participant
    Senior

    Voici le code sans le problème de coller:

    /////////////////////////////////////////////////////////////////////////////////
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    //Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
    DEFPARAM FLATBEFORE = 080000
    ////////// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
    DEFPARAM FLATAFTER = 200000
    DEFPARAM Preloadbars = 1000
    
    ONCE LongHH = 1
    ONCE MEMSTOPPRICE = 0
    ONCE MEMOSTOP = 0
    
    MM30H = Average[30,7](Close)
    
    If not Onmarket Then
    step = 0
    MemoIndex = 0
    Endif
    
    graph STEP COLOURED(50,50,75)
    // CAPITAL //
    
    CapitalInitial = 1000 // Capital initial
    CapitalReinvest = CapitalInitial+Strategyprofit
    
    // nombre de contrat
    
    TailleContrat = 1 // Nbr lot (minimum 0.5)
    
    // réinvestissement des gains
    
    ReinvestActif = 1 // activé ?
    
    If ReinvestActif = 0 then
    nblot = TailleContrat
    endif
    
    If ReinvestActif = 1 then
    nblot = (CapitalReinvest/CapitalInitial)*TailleContrat
    Endif
    
    If nblot < 0.5 then
    nblot = 0.5
    Endif
    
    
    //-+------------------------------------------------------------------+-//
    // | Heikin Ashi                                                      | //
    //-+------------------------------------------------------------------+-//
    if barindex>1 then
    haclose=(open+close+low+high)/4
    haopen=(haopen[1]+haclose[1])/2
    //xHigh = Max(haOpen, haClose)
    xLow = Min(haOpen, haClose)
    //hahigh = Max(High,xHigh)
    halow = Min(Low,xLow)
    endif
    //-+------------------------------------------------------------------+-//
    
    //Calcul BB inférieure et supérieure
    PeriodBB = 500
    dev = 2.3 // Ecart type
    BollInf = Average[PeriodBB](close)-dev*std[PeriodBB](close)
    
    If LongHH then // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    b1 = RSI[7](close) < 20 or RSI[7](close[1]) < 20 or RSI[7](close[2]) < 20
    
    b2 = haclose < BollInf
    
    b3 = 1
    
    b4 = haclose > haopen // bougie verte
    
    b5 = 1
    
    b6 = 1
    
    b7 = 1
    
    Btotal = b1 and b2 and b3 and b4 and b5 and b6 and b7 and Not OnMarket
    
    IF btotal  THEN
    BUY nblot CONTRACT AT MARKET
    Set Target pprofit 0
    SET STOP LOSS 9 //  Temporaire
    MEMSTOPPRICE = DonchianChannelDown[100]-3 // à l'instant T pour calcul ultérieur du STOPLOSS
    
    ENDIF
    
    EndIf // LongHH // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    
    // Ajustement du STOPLOSS une fois le prix d'ouverture de la bougie d'ordre connue
    
    IF Longonmarket and BarIndex = TradeIndex(1) and step = 0 then
    
    MEMOSTOP = Tradeprice(1)-MEMSTOPPRICE // STOPLOSS en Nbr de point
    SET STOP LOSS MEMOSTOP
    BuyN1 = Tradeprice(1)
    MemBE = BuyN1+1.4
    step = 1
    graph MemBE coloured (100,100,100) as "BE1"
    Endif
    
    ////STOP remonté à BE dés que possible
    If Longonmarket and step = 1 Then
    SELL AT MemBE STOP
    graph MemBE coloured (50,100,100) as "BE2"
    step = 2
    EndIf
    #171518 quote
    GraHal
    Participant
    Master

    Ci-joint ce que j’obtiens sur DJI, 5 Sec TF sur 100K barres, propagation = 5

    #171520 quote
    Yvan63
    Participant
    Senior

    Voilà, si tu zoom sur les ordres tu constateras que l’ordre est fermé à la bougie suivante, alors que le code place un ordre limité à TRADEPRICE+1.4 !!!!

    #171522 quote
    GraHal
    Participant
    Master

    Vous avez ci-dessous à la ligne 85, donc une transaction se clôturera à 0 profit

    Set Target pprofit 0

    #171525 quote
    Yvan63
    Participant
    Senior

    Même en supprimant cette ligne ça ne fonctionne pas…

    #171539 quote
    GraHal
    Participant
    Master

    Je l’ai fait pour plus d’une barre comme ci-joint en changeant les lignes 84, 85 et 99 comme indiqué dans le fichier .itf ci-joint.

    Je ne comprends pas le code (ni le français ! 🙂 ) donc je ne peux pas faire grand chose de plus, mais peut-être que mes modifications vous aideront à vous remettre sur la bonne voie ? 

    Yvan63 thanked this post
    #171542 quote
    Yvan63
    Participant
    Senior

    Hello,

    I’ll try it in English.
    The problem with this code is that the STOP at BREAKEVEN does not work, the SELL AT (PRICE) STOP order is not executed at the right price!
    In the code I provide, the SELL order is executed immediately after the buy order, this is not normal.
    When the price exceeds the entry price + 1.4 points, a STOP sell order is placed, but it is not respected.

    #171548 quote
    Nicolas
    Keymaster
    Master

    Il n’y a pas de bug, dans ton code, dés que la première bougie se ferme, tu calcules un niveau de breakeven (+1.4), que tu enregistres, mais à aucun comment tu testes si ce niveau se situe bien en dessous du prix actuel ! donc dés que tu places ton ordre STOP à un niveau situé au dessus du prix, le système ferme ton ordre ! (voir image)

    Pour les prochains sujets, il faudrait écrire un titre en raccord avec le problème, sinon on va vite avoir X dizaines de messages : “PRT BUG!” , je change le titre.

    Yvan63 thanked this post
    #171554 quote
    Yvan63
    Participant
    Senior

    Merci pour cette explication et désolé pour le titre 😉

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

mise a niveau breakeven, probleme de fermeture immediate de l’ordre !


Support ProOrder

New Reply
Author
author-avatar
Yvan63 @yvan63 Participant
Summary

This topic contains 11 replies,
has 3 voices, and was last updated by Yvan63
4 years, 7 months ago.

Topic Details
Forum: Support ProOrder
Language: French
Started: 06/09/2021
Status: Active
Attachments: 5 files
Logo Logo
Loading...